2020-11-04 11:49:43 +01:00
|
|
|
<?php
|
|
|
|
|
|
2022-01-10 14:02:25 +01:00
|
|
|
namespace App\Http\Controllers\Bo;
|
2020-11-04 11:49:43 +01:00
|
|
|
|
|
|
|
|
use App\Http\Controllers\Controller;
|
|
|
|
|
use App\Models\Participation;
|
2023-12-05 12:33:25 +01:00
|
|
|
use Illuminate\Contracts\View\View;
|
2023-12-13 15:47:48 +01:00
|
|
|
use Illuminate\Http\RedirectResponse;
|
2020-11-04 11:49:43 +01:00
|
|
|
|
2023-12-05 12:33:25 +01:00
|
|
|
class ParticipationController extends Controller
|
2020-11-04 11:49:43 +01:00
|
|
|
{
|
2023-08-23 10:38:11 +00:00
|
|
|
/**
|
2023-12-05 12:33:25 +01:00
|
|
|
* Create the controller instance.
|
|
|
|
|
*/
|
|
|
|
|
public function __construct()
|
|
|
|
|
{
|
|
|
|
|
$this->authorizeResource(Participation::class);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* View all winners
|
2023-08-23 10:38:11 +00:00
|
|
|
*
|
|
|
|
|
* @return \Illuminate\Contracts\View\View
|
|
|
|
|
*/
|
2023-12-05 12:33:25 +01:00
|
|
|
public function viewWinnerList(): View
|
2021-08-18 17:08:02 +02:00
|
|
|
{
|
2023-12-05 12:33:25 +01:00
|
|
|
$this->authorize('viewWinnerList', Participation::class);
|
|
|
|
|
|
2024-01-31 09:03:18 +00:00
|
|
|
/** @var \Illuminate\Database\Eloquent\Builder $participationModels */
|
2023-12-13 15:47:48 +01:00
|
|
|
$participationModels = Participation::query()->with(['customer', 'code', 'instantWin'])->whereHas('instantWin');
|
2020-11-20 15:18:31 +01:00
|
|
|
|
2023-08-23 10:38:11 +00:00
|
|
|
/** Sort columns with a query */
|
|
|
|
|
$this->sortQuery($participationModels);
|
2021-02-23 18:27:03 +01:00
|
|
|
|
2023-08-23 10:38:11 +00:00
|
|
|
/** Custom pagination */
|
2023-11-23 17:31:28 +01:00
|
|
|
$participationModels = $this->paginate($participationModels);
|
2020-11-20 15:18:31 +01:00
|
|
|
|
2023-11-20 17:22:24 +01:00
|
|
|
return view('back::pages.winners-list.index', compact(
|
2023-12-13 15:47:48 +01:00
|
|
|
'participationModels'
|
|
|
|
|
));
|
|
|
|
|
}
|
|
|
|
|
|
2023-12-13 16:47:28 +01:00
|
|
|
/**
|
|
|
|
|
* Display participation form
|
|
|
|
|
*
|
|
|
|
|
* @param \App\Models\Participation $participation
|
|
|
|
|
* @return \Illuminate\Contracts\View\View
|
|
|
|
|
*/
|
|
|
|
|
public function setComment(Participation $participation): View
|
|
|
|
|
{
|
2023-12-13 17:12:11 +01:00
|
|
|
$this->authorize('setComment', $participation);
|
2023-12-13 16:47:28 +01:00
|
|
|
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
|
|
|
|
|
{
|
2023-12-13 17:12:11 +01:00
|
|
|
$this->authorize('setComment', $participation);
|
2023-12-13 16:47:28 +01:00
|
|
|
$participation->comment = request()->string('comment');
|
|
|
|
|
$participation->saveOrFail();
|
|
|
|
|
return back()->with('success', \trans(
|
|
|
|
|
'Le commentaire à bien été mis à jour'
|
|
|
|
|
));
|
|
|
|
|
}
|
|
|
|
|
|
2023-12-13 15:47:48 +01:00
|
|
|
/**
|
|
|
|
|
* Change prize sent
|
|
|
|
|
*
|
|
|
|
|
* @param \App\Models\Participation $participation
|
|
|
|
|
* @return \Illuminate\Http\RedirectResponse
|
|
|
|
|
*/
|
|
|
|
|
public function changePrizeSent(Participation $participation): RedirectResponse
|
|
|
|
|
{
|
2023-12-13 17:12:11 +01:00
|
|
|
$this->authorize('changePrizeSent', $participation);
|
2023-12-13 15:47:48 +01:00
|
|
|
$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'
|
2023-08-23 10:38:11 +00:00
|
|
|
));
|
2020-11-20 15:18:31 +01:00
|
|
|
}
|
2020-11-04 11:49:43 +01:00
|
|
|
}
|