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.
53 lines
1.2 KiB
53 lines
1.2 KiB
<?php
|
|
|
|
namespace App\iLaravel;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Http\Resources\Successful;
|
|
use App\Models\ILaravel;
|
|
use App\Utilities\Polices\BasePolicy;
|
|
use Illuminate\Http\Request;
|
|
|
|
class ILaravelController extends Controller
|
|
{
|
|
|
|
// this method check AuthServiceProvider
|
|
public function me()
|
|
{
|
|
return auth()->user();
|
|
}
|
|
|
|
public function store(Request $request)
|
|
{
|
|
BasePolicy::allow(app('modelDocument')?->storePolicy);
|
|
|
|
return ILaravel::create($request->all());
|
|
}
|
|
|
|
public function show(ILaravel $ILaravel)
|
|
{
|
|
BasePolicy::allow(app('modelDocument')?->getPolicy, $ILaravel);
|
|
|
|
return $ILaravel;
|
|
}
|
|
|
|
public function update(ILaravel $ILaravel, Request $request)
|
|
{
|
|
BasePolicy::allow(app('modelDocument')?->updatePolicy, $ILaravel);
|
|
|
|
$ILaravel->update($request->all());
|
|
return $ILaravel;
|
|
}
|
|
|
|
public function destroy(ILaravel $ILaravel)
|
|
{
|
|
BasePolicy::allow(app('modelDocument')?->{$ILaravel->trashed() ? 'restorePolicy' : 'deletePolicy'}, $ILaravel);
|
|
|
|
if ($ILaravel->trashed()) {
|
|
return tap($ILaravel, fn() => $ILaravel->restore());
|
|
}
|
|
|
|
$ILaravel->delete();
|
|
return Successful::make();
|
|
}
|
|
}
|