2023-08-28 19:08:23 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Http\Controllers\Bo;
|
|
|
|
|
|
|
|
|
|
use App\Http\Controllers\Controller;
|
|
|
|
|
use App\Models\Contact;
|
|
|
|
|
use Illuminate\Http\Request;
|
|
|
|
|
|
|
|
|
|
class ContactController extends Controller
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* Display a listing of the resource.
|
|
|
|
|
*
|
|
|
|
|
* @param \Illuminate\Http\Request $request
|
|
|
|
|
* @return \Illuminate\Http\Response
|
|
|
|
|
*/
|
|
|
|
|
public function index(Request $request)
|
|
|
|
|
{
|
2023-08-29 09:39:34 +02:00
|
|
|
/** @var \Illuminate\Database\Eloquent\Builder $query */
|
|
|
|
|
$query = Contact::query();
|
2023-08-28 19:08:23 +02:00
|
|
|
|
|
|
|
|
/** @var string $search Search field */
|
|
|
|
|
if ($request->search) {
|
|
|
|
|
$this->searchQuery(
|
2023-08-29 09:39:34 +02:00
|
|
|
$query,
|
2023-08-28 19:08:23 +02:00
|
|
|
$request->search,
|
|
|
|
|
null,
|
|
|
|
|
'firstname',
|
|
|
|
|
'lastname',
|
|
|
|
|
'email',
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
$searchFields = \implode(',', [trans('Nom'), trans('Prénom'), trans('Email')]);
|
|
|
|
|
|
|
|
|
|
/** Sort columns with a query */
|
2023-08-29 09:39:34 +02:00
|
|
|
$this->sortQuery($query);
|
2023-08-28 19:08:23 +02:00
|
|
|
|
2023-08-29 09:39:34 +02:00
|
|
|
$contactModelList = $this->paginate($query);
|
2023-08-28 19:08:23 +02:00
|
|
|
|
|
|
|
|
return view('bo.pages.contacts.index', compact('contactModelList', 'searchFields'));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Display the specified resource.
|
|
|
|
|
*
|
|
|
|
|
* @param \App\Models\Contact $contact
|
|
|
|
|
* @return \Illuminate\Http\Response
|
|
|
|
|
*/
|
|
|
|
|
public function show(Contact $contact)
|
|
|
|
|
{
|
|
|
|
|
return \view('bo.pages.contacts.show', ['contactModel' => $contact]);
|
|
|
|
|
}
|
|
|
|
|
}
|