@@ -80,10 +80,10 @@ public function edit(PredefinedKit $kit)
8080 {
8181 $ this ->authorize ('update ' , PredefinedKit::class);
8282
83- return view ('kits/edit ' )
84- ->with ('item ' , $ kit )
85- ->with ('models ' , $ kit ->models )
86- ->with ('licenses ' , $ kit ->licenses );
83+ return view ('kits/edit ' )
84+ ->with ('item ' , $ kit )
85+ ->with ('models ' , $ kit ->models )
86+ ->with ('licenses ' , $ kit ->licenses );
8787 }
8888
8989 /**
@@ -119,8 +119,8 @@ public function update(ImageUploadRequest $request, PredefinedKit $kit)
119119 public function destroy ($ kit_id )
120120 {
121121 $ this ->authorize ('delete ' , PredefinedKit::class);
122- // Check if the kit exists
123- if (is_null ($ kit = PredefinedKit:: find ( $ kit_id ) )) {
122+ $ kit = PredefinedKit:: find ( $ kit_id );
123+ if (is_null ($ kit )) {
124124 return redirect ()->route ('kits.index ' )->with ('error ' , trans ('admin/kits/general.kit_not_found ' ));
125125 }
126126
@@ -159,15 +159,16 @@ public function show(PredefinedKit $kit)
159159 public function editModel ($ kit_id , $ model_id )
160160 {
161161 $ this ->authorize ('update ' , PredefinedKit::class);
162- if (
163- ($ kit = PredefinedKit::find ($ kit_id ))
164- && ($ model = $ kit ->models ()->find ($ model_id ))
165- ) {
166- return view ('kits/model-edit ' , [
167- 'kit ' => $ kit ,
168- 'model ' => $ model ,
169- 'item ' => $ model ->pivot ,
170- ]);
162+ $ kit = PredefinedKit::find ($ kit_id );
163+ if ($ kit ) {
164+ $ model = $ kit ->models ()->find ($ model_id );
165+ if ($ model ) {
166+ return view ('kits/model-edit ' , [
167+ 'kit ' => $ kit ,
168+ 'model ' => $ model ,
169+ 'item ' => $ model ->pivot ,
170+ ]);
171+ }
171172 }
172173
173174 return redirect ()->route ('kits.index ' )->with ('error ' , trans ('admin/kits/general.kit_none ' ));
@@ -213,7 +214,8 @@ public function updateModel(Request $request, $kit_id, $model_id)
213214 public function detachModel ($ kit_id , $ model_id )
214215 {
215216 $ this ->authorize ('update ' , PredefinedKit::class);
216- if (is_null ($ kit = PredefinedKit::find ($ kit_id ))) {
217+ $ kit = PredefinedKit::find ($ kit_id );
218+ if (is_null ($ kit )) {
217219 // Redirect to the kits management page
218220 return redirect ()->route ('kits.index ' )->with ('error ' , trans ('admin/kits/general.kit_none ' ));
219221 }
@@ -236,7 +238,8 @@ public function detachModel($kit_id, $model_id)
236238 public function editLicense ($ kit_id , $ license_id )
237239 {
238240 $ this ->authorize ('update ' , PredefinedKit::class);
239- if (! ($ kit = PredefinedKit::find ($ kit_id ))) {
241+ $ kit = PredefinedKit::find ($ kit_id );
242+ if (is_null ($ kit )) {
240243 return redirect ()->route ('kits.index ' )->with ('error ' , trans ('admin/kits/general.kit_none ' ));
241244 }
242245 if (! ($ license = $ kit ->licenses ()->find ($ license_id ))) {
@@ -261,7 +264,8 @@ public function editLicense($kit_id, $license_id)
261264 public function updateLicense (Request $ request , $ kit_id , $ license_id )
262265 {
263266 $ this ->authorize ('update ' , PredefinedKit::class);
264- if (is_null ($ kit = PredefinedKit::find ($ kit_id ))) {
267+ $ kit = PredefinedKit::find ($ kit_id );
268+ if (is_null ($ kit )) {
265269 // Redirect to the kits management page
266270 return redirect ()->route ('kits.index ' )->with ('error ' , trans ('admin/kits/general.kit_none ' ));
267271 }
@@ -292,7 +296,8 @@ public function updateLicense(Request $request, $kit_id, $license_id)
292296 public function detachLicense ($ kit_id , $ license_id )
293297 {
294298 $ this ->authorize ('update ' , PredefinedKit::class);
295- if (is_null ($ kit = PredefinedKit::find ($ kit_id ))) {
299+ $ kit = PredefinedKit::find ($ kit_id );
300+ if (is_null ($ kit )) {
296301 // Redirect to the kits management page
297302 return redirect ()->route ('kits.index ' )->with ('error ' , trans ('admin/kits/general.kit_none ' ));
298303 }
@@ -315,7 +320,8 @@ public function detachLicense($kit_id, $license_id)
315320 public function editAccessory ($ kit_id , $ accessory_id )
316321 {
317322 $ this ->authorize ('update ' , PredefinedKit::class);
318- if (! ($ kit = PredefinedKit::find ($ kit_id ))) {
323+ $ kit = PredefinedKit::find ($ kit_id );
324+ if (is_null ($ kit )) {
319325 return redirect ()->route ('kits.index ' )->with ('error ' , trans ('admin/kits/general.kit_none ' ));
320326 }
321327 if (! ($ accessory = $ kit ->accessories ()->find ($ accessory_id ))) {
@@ -340,7 +346,8 @@ public function editAccessory($kit_id, $accessory_id)
340346 public function updateAccessory (Request $ request , $ kit_id , $ accessory_id )
341347 {
342348 $ this ->authorize ('update ' , PredefinedKit::class);
343- if (is_null ($ kit = PredefinedKit::find ($ kit_id ))) {
349+ $ kit = PredefinedKit::find ($ kit_id );
350+ if (is_null ($ kit )) {
344351 // Redirect to the kits management page
345352 return redirect ()->route ('kits.index ' )->with ('error ' , trans ('admin/kits/general.kit_none ' ));
346353 }
@@ -370,7 +377,8 @@ public function updateAccessory(Request $request, $kit_id, $accessory_id)
370377 public function detachAccessory ($ kit_id , $ accessory_id )
371378 {
372379 $ this ->authorize ('update ' , PredefinedKit::class);
373- if (is_null ($ kit = PredefinedKit::find ($ kit_id ))) {
380+ $ kit = PredefinedKit::find ($ kit_id );
381+ if (is_null ($ kit )) {
374382 // Redirect to the kits management page
375383 return redirect ()->route ('kits.index ' )->with ('error ' , trans ('admin/kits/general.kit_none ' ));
376384 }
@@ -393,7 +401,8 @@ public function detachAccessory($kit_id, $accessory_id)
393401 public function editConsumable ($ kit_id , $ consumable_id )
394402 {
395403 $ this ->authorize ('update ' , PredefinedKit::class);
396- if (! ($ kit = PredefinedKit::find ($ kit_id ))) {
404+ $ kit = PredefinedKit::find ($ kit_id );
405+ if (is_null ($ kit )) {
397406 return redirect ()->route ('kits.index ' )->with ('error ' , trans ('admin/kits/general.kit_none ' ));
398407 }
399408 if (! ($ consumable = $ kit ->consumables ()->find ($ consumable_id ))) {
@@ -418,7 +427,8 @@ public function editConsumable($kit_id, $consumable_id)
418427 public function updateConsumable (Request $ request , $ kit_id , $ consumable_id )
419428 {
420429 $ this ->authorize ('update ' , PredefinedKit::class);
421- if (is_null ($ kit = PredefinedKit::find ($ kit_id ))) {
430+ $ kit = PredefinedKit::find ($ kit_id );
431+ if (is_null ($ kit )) {
422432 // Redirect to the kits management page
423433 return redirect ()->route ('kits.index ' )->with ('error ' , trans ('admin/kits/general.kit_none ' ));
424434 }
@@ -448,7 +458,8 @@ public function updateConsumable(Request $request, $kit_id, $consumable_id)
448458 public function detachConsumable ($ kit_id , $ consumable_id )
449459 {
450460 $ this ->authorize ('update ' , PredefinedKit::class);
451- if (is_null ($ kit = PredefinedKit::find ($ kit_id ))) {
461+ $ kit = PredefinedKit::find ($ kit_id );
462+ if (is_null ($ kit )) {
452463 // Redirect to the kits management page
453464 return redirect ()->route ('kits.index ' )->with ('error ' , trans ('admin/kits/general.kit_none ' ));
454465 }
0 commit comments