- add FK on arcadia_links to media.id and remove orphans - Refactored ArcadiaLinkController - Added comments on ArcadiaLink model - refactored arcadialinks.index
48 lines
1.3 KiB
PHP
48 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Models\ArcadiaLink;
|
|
use Illuminate\Contracts\Database\Eloquent\Builder;
|
|
|
|
class ArcadiaLinkController extends Controller
|
|
{
|
|
/**
|
|
* Display a listing of the resource.
|
|
*
|
|
* @return \Illuminate\Http\Response
|
|
*/
|
|
public function index()
|
|
{
|
|
/** @var \App\Models\User */
|
|
$user = auth()->user();
|
|
$user->authorizeRoles(config('roles.const.ADMIN'));
|
|
|
|
// * ArcadiaLink->Media is nullable
|
|
$arcadiaLinkList = ArcadiaLink::query()
|
|
->with('media', fn (Builder $q) => $q->withTrashed())
|
|
->where('created_at', '<', now()->subMinutes(15))
|
|
->orderBy('id', 'DESC')->get();
|
|
|
|
return view('arcadialinks.index', compact('arcadiaLinkList'));
|
|
}
|
|
|
|
/**
|
|
* Remove the specified resource from storage.
|
|
*
|
|
* @param \App\Models\ArcadiaLink $arcadia_link
|
|
* @return \Illuminate\Http\Response
|
|
*/
|
|
public function delete(ArcadiaLink $arcadia_link)
|
|
{
|
|
if ($arcadia_link->deleteOrFail()) {
|
|
return redirect()
|
|
->route('arcadialinks.index')
|
|
->with('warning', trans(
|
|
':model a bien été supprimé',
|
|
['model' => trans('ArcadiaLink')]
|
|
));
|
|
}
|
|
return back();
|
|
}
|
|
}
|