service-image-add

aplus#22
Mahesh Sharma 2 years ago
parent 2b0b516388
commit 05a0def7f3
  1. 25
      app/Http/Controllers/Admin/ServiceController.php
  2. 26
      app/Http/Controllers/Admin/VisaServiceController.php
  3. 32
      database/migrations/2022_12_14_063910_add_image_to_services_table.php
  4. 32
      database/migrations/2022_12_14_071737_add_image_to_visa_services_table.php
  5. BIN
      public/images/service/2022/12/14/6fedfb5fcdf3c919034871154e65fb13.jpeg
  6. BIN
      public/images/service/2022/12/14/f32db952dcf6def35e25c26a3eea2967.jpeg
  7. 8
      resources/views/admin/service/create.blade.php
  8. 14
      resources/views/admin/service/edit.blade.php
  9. 6
      resources/views/admin/visa_service/create.blade.php
  10. 14
      resources/views/admin/visa_service/edit.blade.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!');

@ -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!');

@ -0,0 +1,32 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('services', function (Blueprint $table) {
$table->string('image');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('services', function (Blueprint $table) {
//
});
}
};

@ -0,0 +1,32 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('visa_services', function (Blueprint $table) {
//
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('visa_services', function (Blueprint $table) {
//
});
}
};

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

@ -105,7 +105,7 @@
<div class="col-md-4">
<div class="form-group">
<label for="seo_description">Meta Key Word</label>
<label for="seo_description">Meta KeyWord</label>
<textarea class="summernote_class" name="meta_keywords"></textarea>
</div>
</div>
@ -116,6 +116,12 @@
<input type="file" class="form-control" id="icon" name="icon" required>
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label for="image">Image <span style="color: red">*</span></label>
<input type="file" class="form-control" id="image" name="image" required>
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label>Status <span style="color: red">*</span> </label>

@ -78,6 +78,20 @@
@endif
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label for="image"> Image <span style="color: red">*</span></label>
<input type="file" class="form-control" id="image" name="image">
@if($service->image != null)
<span>
<a href="{{url($service->image)}}" target="_blank">
<img src="{{url($service->image)}}" alt="" style="width: 100px;">
</a>
</span>
@endif
</div>
</div>

@ -116,6 +116,12 @@
<input type="file" class="form-control" id="icon" name="icon" required>
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label for="image">Image <span style="color: red">*</span></label>
<input type="file" class="form-control" id="image" name="image" required>
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label>Status <span style="color: red">*</span> </label>

@ -79,6 +79,20 @@
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label for="image"> Image <span style="color: red">*</span></label>
<input type="file" class="form-control" id="image" name="image">
@if($service->image != null)
<span>
<a href="{{url($service->image)}}" target="_blank">
<img src="{{url($service->image)}}" alt="" style="width: 100px;">
</a>
</span>
@endif
</div>
</div>
<div class="col-md-4">

Loading…
Cancel
Save