10
10
use Illuminate \Routing \Controller as BaseController ;
11
11
use Illuminate \Foundation \Validation \ValidatesRequests ;
12
12
use Illuminate \Foundation \Auth \Access \AuthorizesRequests ;
13
+ use Illuminate \Support \Facades \Gate ;
13
14
14
15
15
16
class ReactUpdateController extends BaseController
@@ -33,7 +34,12 @@ class ReactUpdateController extends BaseController
33
34
*/
34
35
public function __construct (ReactRequest $ request ){
35
36
// TODO set up middleware that adapts to non-admin updates
36
- $ this ->middleware ('can:admin-site ' );
37
+ $ gate_handle = config ('react_sync.gate_handle ' );
38
+ if (!Gate::has ($ gate_handle )){
39
+ throw new \Exception ("You must define a authorization rule named ' $ gate_handle' to protect access to the ReactUpdateController methods. " );
40
+ exit ();
41
+ }
42
+ $ this ->middleware ("can: $ gate_handle " );
37
43
38
44
}
39
45
@@ -155,21 +161,19 @@ private function resolveBelongsTo($prop, $value){
155
161
156
162
157
163
private function resolveHasMany ($ prop , $ value ){
158
- die ('sdfsdfsdfsdf ' );
164
+ throw new \Exception ("Relationship 'resolveHasMany' is not yet enabled " );
165
+ die ('Relationship not yet enabled ' );
159
166
// Since this is a hasMany relationship, use the ...
160
167
//
161
168
// See documentation for mass assignment!! This has to be enabled on the model to which you are saving data.
162
169
if (is_array ($ value )){ // always gonna be an array isn't it :(
163
170
// Save all new relations
164
- dd ($ value );
165
171
$ this ->model ->{$ prop }()->createMany ($ value );
166
172
}
167
173
else {
168
174
$ this ->model ->{$ prop }()->create ($ value );
169
175
}
170
- dd ($ this ->model ->{$ prop });
171
176
$ this ->model ->{$ prop }()->sync ($ value );
172
- dd ($ this ->model );
173
177
return $ this ->model ;
174
178
}
175
179
0 commit comments