diff --git a/app/Http/Controllers/Admin/ServiceController.php b/app/Http/Controllers/Admin/ServiceController.php index 11fb17c..413ab00 100644 --- a/app/Http/Controllers/Admin/ServiceController.php +++ b/app/Http/Controllers/Admin/ServiceController.php @@ -94,6 +94,15 @@ class ServiceController extends Controller $out_put_path = User::save_image(\request('icon'),$extension,$count,$image_folder_type); is_array($out_put_path) ? $service->icon = $out_put_path[0] : $service->icon = $out_put_path; } + if($request->hasFile('image')){ + $extension = \request()->file('image')->getClientOriginalExtension(); + $image_folder_type = array_search('service',config('custom.image_folders')); //for image saved in folder + + $count = rand(100,999); + + $out_put_path = User::save_image(\request('image'),$extension,$count,$image_folder_type); + is_array($out_put_path) ? $service->image = $out_put_path[0] : $service->image = $out_put_path; + } if($service->save()){ @@ -190,6 +199,22 @@ class ServiceController extends Controller is_array($out_put_path) ? $service->icon = $out_put_path[0] : $service->icon = $out_put_path; + } + if($request->hasFile('image')){ + + $extension = \request()->file('image')->getClientOriginalExtension(); + + $image_folder_type = array_search('service',config('custom.image_folders')); //for image saved in folder + $count = rand(100,999); + $out_put_path = User::save_image(\request('image'),$extension,$count,$image_folder_type); + + + if (is_file(public_path().'/'.$service->image) && file_exists(public_path().'/'.$service->image)){ + unlink(public_path().'/'.$service->image); + } + is_array($out_put_path) ? $service->image = $out_put_path[0] : $service->image = $out_put_path; + + } if($service->update()){ Session::flash('success','Service has been successfully updated!'); diff --git a/app/Http/Controllers/Admin/VisaServiceController.php b/app/Http/Controllers/Admin/VisaServiceController.php index 557ad36..5955184 100644 --- a/app/Http/Controllers/Admin/VisaServiceController.php +++ b/app/Http/Controllers/Admin/VisaServiceController.php @@ -94,7 +94,15 @@ class VisaServiceController extends Controller $out_put_path = User::save_image(\request('icon'),$extension,$count,$image_folder_type); is_array($out_put_path) ? $service->icon = $out_put_path[0] : $service->icon = $out_put_path; } - + if($request->hasFile('image')){ + $extension = \request()->file('image')->getClientOriginalExtension(); + $image_folder_type = array_search('visa_service',config('custom.image_folders')); //for image saved in folder + + $count = rand(100,999); + + $out_put_path = User::save_image(\request('image'),$extension,$count,$image_folder_type); + is_array($out_put_path) ? $service->image = $out_put_path[0] : $service->image = $out_put_path; + } if($service->save()){ // $points = $request->points; @@ -104,7 +112,7 @@ class VisaServiceController extends Controller // $service_point->point = $point; // $service_point->save(); // } - Session::flash('success','Service has been created!'); + Session::flash('success','Visa Service has been created!'); return redirect($this->redirect); } @@ -190,6 +198,22 @@ class VisaServiceController extends Controller is_array($out_put_path) ? $service->icon = $out_put_path[0] : $service->icon = $out_put_path; + } + if($request->hasFile('image')){ + + $extension = \request()->file('image')->getClientOriginalExtension(); + + $image_folder_type = array_search('vis_service',config('custom.image_folders')); //for image saved in folder + $count = rand(100,999); + $out_put_path = User::save_image(\request('image'),$extension,$count,$image_folder_type); + + + if (is_file(public_path().'/'.$service->image) && file_exists(public_path().'/'.$service->image)){ + unlink(public_path().'/'.$service->image); + } + is_array($out_put_path) ? $service->image = $out_put_path[0] : $service->image = $out_put_path; + + } if($service->update()){ Session::flash('success','Visa Service has been successfully updated!'); diff --git a/database/migrations/2022_12_14_063910_add_image_to_services_table.php b/database/migrations/2022_12_14_063910_add_image_to_services_table.php new file mode 100644 index 0000000..aaedb16 --- /dev/null +++ b/database/migrations/2022_12_14_063910_add_image_to_services_table.php @@ -0,0 +1,32 @@ +string('image'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('services', function (Blueprint $table) { + // + }); + } +}; diff --git a/database/migrations/2022_12_14_071737_add_image_to_visa_services_table.php b/database/migrations/2022_12_14_071737_add_image_to_visa_services_table.php new file mode 100644 index 0000000..a05a7f6 --- /dev/null +++ b/database/migrations/2022_12_14_071737_add_image_to_visa_services_table.php @@ -0,0 +1,32 @@ +
- +
@@ -116,6 +116,12 @@ +
+
+ + +
+
diff --git a/resources/views/admin/service/edit.blade.php b/resources/views/admin/service/edit.blade.php index 0261357..b10521d 100644 --- a/resources/views/admin/service/edit.blade.php +++ b/resources/views/admin/service/edit.blade.php @@ -78,6 +78,20 @@ @endif
+
+
+ + + @if($service->image != null) + + + + + + @endif +
+
+ diff --git a/resources/views/admin/visa_service/create.blade.php b/resources/views/admin/visa_service/create.blade.php index 069c897..648065a 100644 --- a/resources/views/admin/visa_service/create.blade.php +++ b/resources/views/admin/visa_service/create.blade.php @@ -116,6 +116,12 @@ +
+
+ + +
+
diff --git a/resources/views/admin/visa_service/edit.blade.php b/resources/views/admin/visa_service/edit.blade.php index 0261357..35f1a2c 100644 --- a/resources/views/admin/visa_service/edit.blade.php +++ b/resources/views/admin/visa_service/edit.blade.php @@ -78,6 +78,20 @@ @endif
+ +
+
+ + + @if($service->image != null) + + + + + + @endif +
+