You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

45 lines
1.2 KiB

<?php
namespace App\Http\Controllers;
use App\Documents\PolicyDocument;
use App\Http\Resources\CollectionResource;
use App\Models\Collection;
use App\Utilities\Polices\BasePolicy;
use Illuminate\Http\Request;
class CollectionController extends Controller
{
public function show(Collection $collection)
{
BasePolicy::allow(app('modelDocument')?->getPolicy,$collection);
return new CollectionResource($collection);
}
public function store(Request $request)
{
BasePolicy::allow(app('modelDocument')?->storePolicy);
$collection = Collection::create($request->all());
return new CollectionResource($collection);
}
public function update(Request $request, Collection $collection)
{
BasePolicy::allow(app('modelDocument')?->updatePolicy, $collection);
$collection->update($request->all());
return new CollectionResource($collection);
}
public function destroy(Collection $collection)
{
BasePolicy::allow(app('modelDocument')?->{$collection->trashed() ? 'restorePolicy' : 'deletePolicy'},$collection);
if ($collection->trashed()) {
return $collection->restore();
}
return $collection->delete();
}
}