fix(routes | controller show): delete
This commit is contained in:
parent
5879540d69
commit
ca005ebb0b
2 changed files with 25 additions and 13 deletions
|
@ -13,6 +13,7 @@ use App\Traits\Show\ShowDjTrait;
|
||||||
use App\Traits\Show\ShowInstancesTrait;
|
use App\Traits\Show\ShowInstancesTrait;
|
||||||
use App\Traits\Show\ShowTrait;
|
use App\Traits\Show\ShowTrait;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
use Exception;
|
||||||
|
|
||||||
# TODO Expose the show instance generation for user interaction and pypo queue
|
# TODO Expose the show instance generation for user interaction and pypo queue
|
||||||
# When pypo requests the schedule up to a certain date, generate the shows up to that date
|
# When pypo requests the schedule up to a certain date, generate the shows up to that date
|
||||||
|
@ -26,7 +27,7 @@ class ShowController extends Controller
|
||||||
|
|
||||||
public function index(ShowFilters $filters)
|
public function index(ShowFilters $filters)
|
||||||
{
|
{
|
||||||
if (!isset($filters->per_page) || is_null($filters)) {
|
if ( ! isset($filters->per_page) || is_null($filters)) {
|
||||||
$pagination = 20;
|
$pagination = 20;
|
||||||
} else {
|
} else {
|
||||||
$pagination = $filters->per_page;
|
$pagination = $filters->per_page;
|
||||||
|
@ -40,12 +41,17 @@ class ShowController extends Controller
|
||||||
*/
|
*/
|
||||||
public function store(Request $request)
|
public function store(Request $request)
|
||||||
{
|
{
|
||||||
$showInfos = $request->show;
|
try {
|
||||||
$showDaysRules = $request->showDaysRules;
|
$showInfos = $request->show;
|
||||||
$showDjs = $request->showDjs;
|
$showDaysRules = $request->showDaysRules;
|
||||||
$show = Show::firstOrCreate($showInfos);
|
$showDjs = $request->showDjs;
|
||||||
$this->manageShowDays($show, $showDaysRules);
|
$show = Show::firstOrCreate($showInfos);
|
||||||
$this->manageShowDjs($showDjs, $show);
|
$this->manageShowDays($show, $showDaysRules);
|
||||||
|
$this->manageShowDjs($showDjs, $show);
|
||||||
|
}catch(Exception $e){
|
||||||
|
return response()->json(['message' => $e->getMessage()], 500);
|
||||||
|
}
|
||||||
|
return response()->json(['message' => 'Show created successfully']);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function show(ShowResource $show)
|
public function show(ShowResource $show)
|
||||||
|
@ -55,21 +61,26 @@ class ShowController extends Controller
|
||||||
|
|
||||||
public function update(ShowRequest $request, Show $show)
|
public function update(ShowRequest $request, Show $show)
|
||||||
{
|
{
|
||||||
//Check if instances have to be resized
|
|
||||||
$show->update($request->validated());
|
$show->update($request->validated());
|
||||||
|
|
||||||
return new ShowResource($show);
|
return new ShowResource($show);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function destroy(ShowRequest $showRequest)
|
public function destroy(Request $request)
|
||||||
{
|
{
|
||||||
// TODO Delete show instances and hosts too
|
try {
|
||||||
$showRequest->delete();
|
$showIds = $request->input('showIds');
|
||||||
|
Show::destroy($showIds);
|
||||||
|
$responseMessage = 'Shows deleted';
|
||||||
|
} catch (Exception $e) {
|
||||||
|
return response()->json(['message' => $e->getMessage()], 500);
|
||||||
|
}
|
||||||
|
|
||||||
return response()->json();
|
return response()->json(['message' => $responseMessage]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSchedule(int $showId){
|
public function testSchedule(int $showId)
|
||||||
|
{
|
||||||
$show = Show::find($showId);
|
$show = Show::find($showId);
|
||||||
$this->manageShowSchedule($show);
|
$this->manageShowSchedule($show);
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,6 +36,7 @@ Route::resources([
|
||||||
'except' => 'create'
|
'except' => 'create'
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
Route::delete('/show', [ShowController::class, 'destroy']);
|
||||||
/**
|
/**
|
||||||
* Custom file route
|
* Custom file route
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue