PHP code example of cerebralfart / laravel-crud-controller
1. Go to this page and download the library: Download cerebralfart/laravel-crud-controller library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
cerebralfart / laravel-crud-controller example snippets
class Controller extends CRUDController {
protected bool $authDisabled = true;
// OR
protected array $authDisabled = ['list', 'show'];
}
class Controller extends CRUDController {
protected array $authErrors = [
'viewAny' => 'Listing all entities is not allowed.',
];
}
class ObjPolicy implements Policy{
public function viewAny(?User $user){
if ($user === null) return Response::deny("Not logged in");
if ($user->isBanned()) return Response::deny("User is banned");
if ($user->balance < 0) return Response::deny("No balance left");
return Response::allow();
}
}
use \Illuminate\Database\Eloquent\Builder;
class Controller extends CRUDController {
public function filterDraft(Builder $builder): void {
$builder->where('draft', true);
}
public function filterHot(Page $page): void {
return $page->comments()->count() > 10;
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.