93 lines
2.5 KiB
PHP
93 lines
2.5 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Bo;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Models\Customer\Contact;
|
|
use Illuminate\Http\Request;
|
|
|
|
class ContactMessagesController extends Controller
|
|
{
|
|
/**
|
|
* Display a listing of the resource.
|
|
*
|
|
* @param \Illuminate\Http\Request $request
|
|
* @return \Illuminate\Contracts\View\View|\Illuminate\Contracts\View\Factory
|
|
*/
|
|
public function index(Request $request)
|
|
{
|
|
/** @var \Illuminate\Database\Eloquent\Builder $contactMessages */
|
|
$contactMessages = Contact::query();
|
|
|
|
if ($request->search) {
|
|
$this->searchQuery(
|
|
$contactMessages,
|
|
$request->search,
|
|
null,
|
|
'order_number',
|
|
'firstname',
|
|
'lastname',
|
|
'subject',
|
|
'email',
|
|
);
|
|
}
|
|
|
|
$this->sortQuery($contactMessages);
|
|
$searchFields = trans('Réf, Nom, Prénom, Objet, E-mail');
|
|
|
|
$contactMessages = $contactMessages->orderBy('done', 'ASC')
|
|
->orderBy('created_at', 'DESC')->paginate();
|
|
|
|
return view('back::pages.contacts.index', compact('contactMessages', 'searchFields'));
|
|
}
|
|
|
|
/**
|
|
* Show contact message
|
|
*
|
|
* @param Contact $contact
|
|
* @return \Illuminate\Contracts\View\View|\Illuminate\Contracts\View\Factory
|
|
*/
|
|
public function show(Contact $contact)
|
|
{
|
|
return view('back::pages.contacts.show', [
|
|
'contactMessage' => $contact
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* Show contact message
|
|
*
|
|
* @param Contact $contact
|
|
* @return \Illuminate\Contracts\View\View|\Illuminate\Contracts\View\Factory
|
|
*/
|
|
public function done(Contact $contact)
|
|
{
|
|
$contact->done = true;
|
|
if ($contact->saveOrFail()) {
|
|
return response()->redirectToRoute('bo.contacts.index')->with(
|
|
'bo.success',
|
|
trans('Le message à été marqué comme traité')
|
|
);
|
|
}
|
|
return back();
|
|
}
|
|
|
|
/**
|
|
* Remove the specified resource from storage.
|
|
*
|
|
* @param \App\Models\Customer\Contact $contact
|
|
* @return \Illuminate\Http\Response
|
|
*/
|
|
public function destroy(Contact $contact)
|
|
{
|
|
if ($contact->deleteOrFail()) {
|
|
return redirect()
|
|
->route('bo.contacts.index')
|
|
->with('bo.warning', trans(
|
|
':model a bien été supprimé',
|
|
['model' => __('Message de contact')]
|
|
));
|
|
}
|
|
return back();
|
|
}
|
|
}
|