@@ -33,11 +33,11 @@ public function resource(Resource $resource)
3333 protected function buildGatesForModel (Model $ model , Resource $ resource , array $ gates )
3434 {
3535 return array_merge (
36- in_array ('view ' , $ gates ) ? [config ('rest.automatic_gates .names.authorized_to_view ' ) => $ resource ->authorizedTo ('view ' , $ model )] : [],
37- in_array ('update ' , $ gates ) ? [config ('rest.automatic_gates .names.authorized_to_update ' ) => $ resource ->authorizedTo ('update ' , $ model )] : [],
38- in_array ('delete ' , $ gates ) ? [config ('rest.automatic_gates .names.authorized_to_delete ' ) => $ resource ->authorizedTo ('delete ' , $ model )] : [],
39- in_array ('restore ' , $ gates ) ? [config ('rest.automatic_gates .names.authorized_to_restore ' ) => $ resource ->authorizedTo ('restore ' , $ model )] : [],
40- in_array ('forceDelete ' , $ gates ) ? [config ('rest.automatic_gates .names.authorized_to_force_delete ' ) => $ resource ->authorizedTo ('forceDelete ' , $ model )] : [],
36+ in_array ('view ' , $ gates ) ? [config ('rest.gates .names.authorized_to_view ' ) => $ resource ->authorizedTo ('view ' , $ model )] : [],
37+ in_array ('update ' , $ gates ) ? [config ('rest.gates .names.authorized_to_update ' ) => $ resource ->authorizedTo ('update ' , $ model )] : [],
38+ in_array ('delete ' , $ gates ) ? [config ('rest.gates .names.authorized_to_delete ' ) => $ resource ->authorizedTo ('delete ' , $ model )] : [],
39+ in_array ('restore ' , $ gates ) ? [config ('rest.gates .names.authorized_to_restore ' ) => $ resource ->authorizedTo ('restore ' , $ model )] : [],
40+ in_array ('forceDelete ' , $ gates ) ? [config ('rest.gates .names.authorized_to_force_delete ' ) => $ resource ->authorizedTo ('forceDelete ' , $ model )] : [],
4141 );
4242 }
4343
@@ -64,9 +64,9 @@ public function modelToResponse(Model $model, Resource $resource, array $request
6464 ->toArray ()
6565 )
6666 )
67- ->when ($ resource ->isAutomaticGatingEnabled () && isset ($ currentRequestArray ['gates ' ]), function ($ attributes ) use ($ currentRequestArray , $ resource , $ model ) {
67+ ->when ($ resource ->isGatingEnabled () && isset ($ currentRequestArray ['gates ' ]), function ($ attributes ) use ($ currentRequestArray , $ resource , $ model ) {
6868 return $ attributes ->put (
69- config ('rest.automatic_gates .key ' ),
69+ config ('rest.gates .key ' ),
7070 $ this ->buildGatesForModel ($ model , $ resource , $ currentRequestArray ['gates ' ])
7171 );
7272 })
@@ -127,9 +127,9 @@ public function toResponse($request)
127127 $ this ->responsable ->perPage (),
128128 $ this ->responsable ->currentPage (),
129129 $ this ->responsable ->getOptions (),
130- $ this ->resource ->isAutomaticGatingEnabled () && in_array ('create ' , $ request ->input ('search.gates ' , [])) ? [
131- config ('rest.automatic_gates .key ' ) => [
132- config ('rest.automatic_gates .names.authorized_to_create ' ) => $ this ->resource ->authorizedTo ('create ' , $ this ->resource ::newModel ()::class),
130+ $ this ->resource ->isGatingEnabled () && in_array ('create ' , $ request ->input ('search.gates ' , [])) ? [
131+ config ('rest.gates .key ' ) => [
132+ config ('rest.gates .names.authorized_to_create ' ) => $ this ->resource ->authorizedTo ('create ' , $ this ->resource ::newModel ()::class),
133133 ],
134134 ] : []
135135 );
@@ -148,9 +148,9 @@ public function toResponse($request)
148148 return [
149149 'data ' => $ data ?? $ this ->map ($ this ->responsable , $ this ->modelToResponse ($ this ->responsable , $ this ->resource , $ request ->input ('search ' , []))),
150150 'meta ' => array_merge (
151- $ this ->resource ->isAutomaticGatingEnabled () && in_array ('create ' , $ request ->input ('search.gates ' , [])) ? [
152- config ('rest.automatic_gates .key ' ) => [
153- config ('rest.automatic_gates .names.authorized_to_create ' ) => $ this ->resource ->authorizedTo ('create ' , $ this ->resource ::newModel ()::class),
151+ $ this ->resource ->isGatingEnabled () && in_array ('create ' , $ request ->input ('search.gates ' , [])) ? [
152+ config ('rest.gates .key ' ) => [
153+ config ('rest.gates .names.authorized_to_create ' ) => $ this ->resource ->authorizedTo ('create ' , $ this ->resource ::newModel ()::class),
154154 ],
155155 ] : []
156156 ),
0 commit comments