mirror of
https://github.com/jez500/pricebuddy.git
synced 2026-11-24 19:58:13 +01:00
48 lines
1.0 KiB
PHP
48 lines
1.0 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Resources\StoreResource\Api\Handlers;
|
|
|
|
use App\Filament\Resources\StoreResource;
|
|
use Dedoc\Scramble\Attributes\Group;
|
|
use Illuminate\Http\JsonResponse;
|
|
use Illuminate\Http\Request;
|
|
use Rupadana\ApiService\Http\Handlers;
|
|
|
|
#[Group(StoreResource::API_GROUP)]
|
|
class DeleteHandler extends Handlers
|
|
{
|
|
public static ?string $uri = '/{id}';
|
|
|
|
public static ?string $resource = StoreResource::class;
|
|
|
|
public static function getMethod()
|
|
{
|
|
return Handlers::DELETE;
|
|
}
|
|
|
|
public static function getModel()
|
|
{
|
|
return static::$resource::getModel();
|
|
}
|
|
|
|
/**
|
|
* Delete Store
|
|
*
|
|
* @return JsonResponse
|
|
*/
|
|
public function handler(Request $request)
|
|
{
|
|
$id = $request->route('id');
|
|
|
|
$model = static::getModel()::where('id', $id)->where('user_id', auth()->id())->first();
|
|
|
|
if (! $model) {
|
|
return static::sendNotFoundResponse();
|
|
}
|
|
|
|
$model->delete();
|
|
|
|
return response()->json([], 204);
|
|
}
|
|
}
|