mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-04-18 16:22:14 +00:00
Edit client detail
This commit is contained in:
@@ -10,6 +10,7 @@ use App\Models\Oasis\Client;
|
||||
use Auth;
|
||||
use Illuminate\Contracts\Foundation\Application;
|
||||
use Illuminate\Contracts\Routing\ResponseFactory;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
|
||||
class ClientController extends Controller
|
||||
@@ -24,22 +25,6 @@ class ClientController extends Controller
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function search()
|
||||
{
|
||||
$query = remove_accents(request()->input('query'));
|
||||
|
||||
$results = Client::search($query)
|
||||
->where('user_id', request()->user()->id)
|
||||
->get();
|
||||
|
||||
return response(
|
||||
new OasisClientCollection($results), 200
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param StoreClientRequest $request
|
||||
* @return Application|ResponseFactory|Response
|
||||
@@ -67,6 +52,40 @@ class ClientController extends Controller
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Client $client
|
||||
* @return Application|ResponseFactory|Response
|
||||
*/
|
||||
public function show(Client $client)
|
||||
{
|
||||
return response(new OasisClientResource($client), 200);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Client $client
|
||||
* @param Request $request
|
||||
* @return Application|ResponseFactory|Response
|
||||
*/
|
||||
public function update(Client $client, Request $request)
|
||||
{
|
||||
// Store image if exist
|
||||
if ($request->hasFile($request->name)) {
|
||||
|
||||
// Find and update image path
|
||||
$client->update([
|
||||
$request->name => store_avatar($request, $request->name)
|
||||
]);
|
||||
|
||||
return response('Done', 204);
|
||||
}
|
||||
|
||||
$client->update(
|
||||
make_single_input($request)
|
||||
);
|
||||
|
||||
return response('Done', 204);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Client $client
|
||||
* @throws \Exception
|
||||
@@ -77,4 +96,20 @@ class ClientController extends Controller
|
||||
|
||||
return response('Done', 204);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function search()
|
||||
{
|
||||
$query = remove_accents(request()->input('query'));
|
||||
|
||||
$results = Client::search($query)
|
||||
->where('user_id', request()->user()->id)
|
||||
->get();
|
||||
|
||||
return response(
|
||||
new OasisClientCollection($results), 200
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,14 +23,24 @@ class OasisClientResource extends JsonResource
|
||||
->count();
|
||||
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'name' => $this->name,
|
||||
'email' => $this->email,
|
||||
'avatar' => $this->avatar,
|
||||
'id' => $this->id,
|
||||
'type' => 'client',
|
||||
'created_at' => format_date($this->created_at, '%d. %B %Y'),
|
||||
|
||||
'totalNet' => format_to_currency($total_net, 'CZK'),
|
||||
'totalInvoices' => $total_invoices,
|
||||
'type' => 'client',
|
||||
'created_at' => format_date($this->created_at, '%d. %B %Y'),
|
||||
|
||||
'avatar' => $this->avatar,
|
||||
'name' => $this->name,
|
||||
'email' => $this->email,
|
||||
'phone_number' => $this->phone_number,
|
||||
'address' => $this->address,
|
||||
'city' => $this->city,
|
||||
'postal_code' => $this->postal_code,
|
||||
'country' => $this->country,
|
||||
'ico' => $this->ico,
|
||||
'dic' => $this->dic,
|
||||
'ic_dph' => $this->ic_dph,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user