Skip to content

Feature/gated fields

Craig Smith requested to merge feature/gated_fields into 3.x

Created by: phpsa

Updates to the release of the V3 Branch

[ ] php8 and up only [ ] ability to use protected $resourceModel = xxx::class instead of public function model() { return xxx::class } - will make static analysis better long term [ ] ability to use route model binding on the controller endpoints [ ] Filtering of fields via gates

Example implementations

//Controller
protected $resourceModel = MyClass::class;
protected $resourceSingle = MyClassResource::class;
...
// this used to require the ID and casts where INT based. (some keys may be string based)
// passing the route param is also better long term as is more laravelEsq
public function show(MyClass $record) {
    return $this->handleShowAction($record);
}

//MyClassResource

protected static array $fieldGates = [
    'gate_name' => [
        'field 1',
        'field 2',
     ],
     'gate_two' => [
       'field 3,
     ]
];

Merge request reports