2
2
3
3
namespace App \Http \Controllers \Backend \Service ;
4
4
5
+ use App \DTOs \CustomService \CustomServiceDto ;
5
6
use App \Enums \PageName ;
6
- use Illuminate \Http \Request ;
7
- use App \Models \CustomService ;
8
7
use App \Http \Controllers \Controller ;
9
- use App \DTOs \CustomService \CustomServiceDto ;
10
- use App \Interfaces \Services \BaseServiceInterface ;
11
- use App \Services \CustomService \CustomServiceService ;
12
8
use App \Http \Requests \CustomService \CustomServiceRequest ;
9
+ use App \Models \CustomService ;
10
+ use App \Services \CustomService \CustomServiceService ;
13
11
14
12
class CustomServiceController extends Controller
15
13
{
@@ -43,8 +41,8 @@ public function store(CustomServiceRequest $request)
43
41
$ service ->saveImage ($ request ->file ('image ' ));
44
42
return redirect (route ('custom-service.index ' ), 201 )->with ([
45
43
'alert-type ' => 'success ' ,
46
- 'message ' => 'Custom Service Created! '
47
- ]);
44
+ 'message ' => 'Custom Service Created! ' ,
45
+ ]);
48
46
}
49
47
50
48
/**
@@ -60,8 +58,8 @@ public function show(string $id)
60
58
*/
61
59
public function edit (CustomService $ customService )
62
60
{
63
- $ service = $ customService ;
64
- $ pageNames = ['homepage ' , 'account ' ];
61
+ $ service = $ customService ;
62
+ $ pageNames = [ 'homepage ' , 'account ' ];
65
63
return view ('backend.service.custom.edit ' , compact ('service ' , 'pageNames ' ));
66
64
}
67
65
@@ -77,20 +75,22 @@ public function update(CustomServiceRequest $request, CustomService $customServi
77
75
$ service = $ this ->service ->update (CustomServiceDto::transformRequest ($ request ), $ customService );
78
76
return redirect (route ('custom-service.index ' ))->with ([
79
77
'alert-type ' => 'success ' ,
80
- 'message ' => 'Custom Service Updated '
81
- ]);
78
+ 'message ' => 'Custom Service Updated ' ,
79
+ ]);
82
80
}
83
81
84
82
/**
85
83
* Remove the specified resource from storage.
86
84
*/
87
85
public function destroy (CustomService $ customService )
88
86
{
89
- $ customService ->deleteImage ($ customService ->image ->path );
87
+ if ($ customService ->image ) {
88
+ $ customService ->deleteImage ($ customService ->image ->path );
89
+ }
90
90
$ this ->service ->delete ($ customService );
91
91
return redirect (route ('custom-service.index ' ))->with ([
92
92
'alert-type ' => 'success ' ,
93
- 'message ' => 'Custom Service Deleted! '
94
- ]);
93
+ 'message ' => 'Custom Service Deleted! ' ,
94
+ ]);
95
95
}
96
96
}
0 commit comments