feat: add Policies as optional command
Closed this issue · 0 comments
caiodomingues commented
It would be of great value to add a flag to generate the Policy of the model, we can manage permissions in a simplistic way using resource validations. We wouldn't need to really create the Policy file, since the one provided by Laravel CLI when passing the --model=Dummy
flag is enough.
Meanwhile, we could change the Controller constructor function to inject the resource authorization:
use App\Models\Dummy;
class DummyController extends Controller {
public function __construct() {
// ...
$this->authorizeResource(Dummy::class);
}
The validation option can also be automatically added to the constructor if the flag is used.