88 lines
2.5 KiB
PHP
88 lines
2.5 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Bo;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Models\Participation;
|
|
use Illuminate\Contracts\View\View;
|
|
use Illuminate\Http\RedirectResponse;
|
|
|
|
class ParticipationController extends Controller
|
|
{
|
|
/**
|
|
* Create the controller instance.
|
|
*/
|
|
public function __construct()
|
|
{
|
|
$this->authorizeResource(Participation::class);
|
|
}
|
|
|
|
/**
|
|
* View all winners
|
|
*
|
|
* @return \Illuminate\Contracts\View\View
|
|
*/
|
|
public function viewWinnerList(): View
|
|
{
|
|
$this->authorize('viewWinnerList', Participation::class);
|
|
|
|
/** @var \Illuminate\Database\Eloquent\Builder $participationModels */
|
|
$participationModels = Participation::query()->with(['customer', 'code', 'instantWin'])->whereHas('instantWin');
|
|
|
|
/** Sort columns with a query */
|
|
$this->sortQuery($participationModels);
|
|
|
|
/** Custom pagination */
|
|
$participationModels = $this->paginate($participationModels);
|
|
|
|
return view('back::pages.winners-list.index', compact(
|
|
'participationModels'
|
|
));
|
|
}
|
|
|
|
/**
|
|
* Display participation form
|
|
*
|
|
* @param \App\Models\Participation $participation
|
|
* @return \Illuminate\Contracts\View\View
|
|
*/
|
|
public function setComment(Participation $participation): View
|
|
{
|
|
$this->authorize('setComment', $participation);
|
|
return view('back::pages.winners-list.set-comment', [
|
|
'participationModel' => $participation
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* Set Comment
|
|
*
|
|
* @param \App\Models\Participation $participation
|
|
* @return \Illuminate\Http\RedirectResponse
|
|
*/
|
|
public function setCommentSubmit(Participation $participation): RedirectResponse
|
|
{
|
|
$this->authorize('setComment', $participation);
|
|
$participation->comment = request()->string('comment');
|
|
$participation->saveOrFail();
|
|
return back()->with('success', \trans(
|
|
'Le commentaire à bien été mis à jour'
|
|
));
|
|
}
|
|
|
|
/**
|
|
* Change prize sent
|
|
*
|
|
* @param \App\Models\Participation $participation
|
|
* @return \Illuminate\Http\RedirectResponse
|
|
*/
|
|
public function changePrizeSent(Participation $participation): RedirectResponse
|
|
{
|
|
$this->authorize('changePrizeSent', $participation);
|
|
$participation->prize_sent = true;
|
|
$participation->saveOrFail();
|
|
return back()->with('success', \trans(
|
|
'Le lot est bien marqué comme envoyé et une notification à été envoyé au gagant'
|
|
));
|
|
}
|
|
}
|