firstcommit
This commit is contained in:
0
Modules/Service/app/Http/Controllers/.gitkeep
Normal file
0
Modules/Service/app/Http/Controllers/.gitkeep
Normal file
139
Modules/Service/app/Http/Controllers/ServiceController.php
Normal file
139
Modules/Service/app/Http/Controllers/ServiceController.php
Normal file
@@ -0,0 +1,139 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Service\app\Http\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Modules\Service\app\Http\Requests\CreateServiceRequest;
|
||||
use Modules\Service\app\Repositories\ServiceRepository;
|
||||
|
||||
class ServiceController extends Controller
|
||||
{
|
||||
protected $serviceRepository;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->serviceRepository = new ServiceRepository;
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index(Request $request)
|
||||
{
|
||||
$perPage = $request->has('per-page') ? $request->input('per-page') : null;
|
||||
$filter = $request->has('filter') ? $request->input('filter') : [];
|
||||
$services = $this->serviceRepository->allServices($perPage, $filter);
|
||||
|
||||
return view('service::index', compact('services'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
return view('service::create');
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
public function store(CreateServiceRequest $request): RedirectResponse
|
||||
{
|
||||
try {
|
||||
$validated = $request->validated();
|
||||
|
||||
$this->serviceRepository->storeService($validated);
|
||||
toastr()->success('Service created successfully.');
|
||||
|
||||
return redirect()->route('cms.services.index');
|
||||
} catch (\Throwable $th) {
|
||||
report($th);
|
||||
toastr()->error('Something went wrong.');
|
||||
|
||||
return back();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the specified resource.
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
return view('service::show');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*/
|
||||
public function edit($uuid)
|
||||
{
|
||||
$service = $this->serviceRepository->findServiceByUuid($uuid);
|
||||
if (!$service) {
|
||||
toastr()->error('Service not found.');
|
||||
|
||||
return back();
|
||||
}
|
||||
|
||||
return view('service::edit', compact('service'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
public function update(CreateServiceRequest $request, $uuid): RedirectResponse
|
||||
{
|
||||
try {
|
||||
$validated = $request->validated();
|
||||
|
||||
$service = $this->serviceRepository->updateService($validated, $uuid);
|
||||
|
||||
|
||||
if (!$service) {
|
||||
toastr()->error('Service not found !');
|
||||
|
||||
return null;
|
||||
}
|
||||
toastr()->success('Service updated successfully.');
|
||||
|
||||
return redirect()->route('cms.services.index');
|
||||
} catch (\Throwable $th) {
|
||||
DB::rollback();
|
||||
report($th);
|
||||
toastr()->error('Something went wrong.');
|
||||
|
||||
return back();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
public function destroy($uuid)
|
||||
{
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$service = $this->serviceRepository->deleteService($uuid);
|
||||
if (!$service) {
|
||||
toastr()->error('Service not found.');
|
||||
|
||||
return back();
|
||||
}
|
||||
|
||||
DB::commit();
|
||||
|
||||
toastr()->success('Service deleted successfully.');
|
||||
|
||||
return redirect()->route('cms.services.index');
|
||||
} catch (\Throwable $th) {
|
||||
DB::rollback();
|
||||
report($th);
|
||||
toastr()->error('Something went wrong.');
|
||||
|
||||
return back();
|
||||
}
|
||||
}
|
||||
}
|
0
Modules/Service/app/Http/Middleware/.gitkeep
Normal file
0
Modules/Service/app/Http/Middleware/.gitkeep
Normal file
0
Modules/Service/app/Http/Requests/.gitkeep
Normal file
0
Modules/Service/app/Http/Requests/.gitkeep
Normal file
66
Modules/Service/app/Http/Requests/CreateServiceRequest.php
Normal file
66
Modules/Service/app/Http/Requests/CreateServiceRequest.php
Normal file
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Service\app\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class CreateServiceRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'required|string|max:255',
|
||||
'summary' => 'sometimes|nullable|string',
|
||||
'detail' => 'sometimes|nullable|string',
|
||||
'status' => 'required|in:active,inactive',
|
||||
'meta_title' => 'sometimes|nullable|string|max:255',
|
||||
'meta_description' => 'sometimes|nullable|string',
|
||||
'meta_keywords' => 'sometimes|nullable|string|max:255',
|
||||
'slug' => 'required',
|
||||
// 'homepage_flag' => 'nullable|boolean',
|
||||
'image' => 'sometimes|nullable|image|mimes:jpeg,png,jpg,gif',
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
public function messages()
|
||||
{
|
||||
return [
|
||||
'title.required' => 'The title field is required.',
|
||||
'title.string' => 'The title field must be a string.',
|
||||
'title.max' => 'The title may not be greater than 255 characters.',
|
||||
|
||||
'summary.string' => 'The summary field must be a string.',
|
||||
|
||||
'detail.string' => 'The detail field must be a string.',
|
||||
|
||||
'status.required' => 'The status field is required.',
|
||||
'status.in' => 'The status field must be either "active" or "inactive".',
|
||||
|
||||
'meta_title.string' => 'The meta title field must be a string.',
|
||||
'meta_title.max' => 'The meta title may not be greater than 255 characters.',
|
||||
|
||||
'meta_description.string' => 'The meta description field must be a string.',
|
||||
|
||||
'meta_keywords.string' => 'The meta keywords field must be a string.',
|
||||
'meta_keywords.max' => 'The meta keywords may not be greater than 255 characters.',
|
||||
|
||||
'slug.required' => 'The slug field is required.',
|
||||
|
||||
'image.image' => 'The image must be an image file.',
|
||||
'image.mimes' => 'The image must be a file of type: jpeg, png, jpg, gif.',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
// return auth()->user()->can('users.create');
|
||||
}
|
||||
}
|
0
Modules/Service/app/Models/.gitkeep
Normal file
0
Modules/Service/app/Models/.gitkeep
Normal file
37
Modules/Service/app/Models/Service.php
Normal file
37
Modules/Service/app/Models/Service.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Service\app\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Service extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*/
|
||||
protected $fillable = [
|
||||
'uuid',
|
||||
'title',
|
||||
'summary',
|
||||
'detail',
|
||||
'image',
|
||||
'image_path',
|
||||
'status',
|
||||
'slug',
|
||||
// 'homepage_flag',
|
||||
];
|
||||
|
||||
public function serviceMeta()
|
||||
{
|
||||
return $this->hasOne(ServiceMeta::class, 'service_id');
|
||||
}
|
||||
|
||||
public function getFullImageAttribute()
|
||||
{
|
||||
return $this->image_path ? asset('storage/uploads/'.$this->image_path) : asset('source/images/default.jpg');
|
||||
}
|
||||
|
||||
}
|
32
Modules/Service/app/Models/ServiceMeta.php
Normal file
32
Modules/Service/app/Models/ServiceMeta.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Service\app\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Modules\Service\Database\factories\ServiceMetaFactory;
|
||||
|
||||
class ServiceMeta extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*/
|
||||
protected $fillable = [
|
||||
'service_id',
|
||||
'meta_title',
|
||||
'meta_description',
|
||||
'meta_keywords',
|
||||
];
|
||||
|
||||
public function service()
|
||||
{
|
||||
return $this->belongsTo(Service::class, 'service_id');
|
||||
}
|
||||
|
||||
// protected static function newFactory(): ServiceMetaFactory
|
||||
// {
|
||||
// //return ServiceMetaFactory::new();
|
||||
// }
|
||||
}
|
0
Modules/Service/app/Providers/.gitkeep
Normal file
0
Modules/Service/app/Providers/.gitkeep
Normal file
59
Modules/Service/app/Providers/RouteServiceProvider.php
Normal file
59
Modules/Service/app/Providers/RouteServiceProvider.php
Normal file
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Service\app\Providers;
|
||||
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
|
||||
|
||||
class RouteServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* The module namespace to assume when generating URLs to actions.
|
||||
*/
|
||||
protected string $moduleNamespace = 'Modules\Service\app\Http\Controllers';
|
||||
|
||||
/**
|
||||
* Called before routes are registered.
|
||||
*
|
||||
* Register any model bindings or pattern based filters.
|
||||
*/
|
||||
public function boot(): void
|
||||
{
|
||||
parent::boot();
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the routes for the application.
|
||||
*/
|
||||
public function map(): void
|
||||
{
|
||||
$this->mapApiRoutes();
|
||||
|
||||
$this->mapWebRoutes();
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the "web" routes for the application.
|
||||
*
|
||||
* These routes all receive session state, CSRF protection, etc.
|
||||
*/
|
||||
protected function mapWebRoutes(): void
|
||||
{
|
||||
Route::middleware('web')
|
||||
->namespace($this->moduleNamespace)
|
||||
->group(module_path('Service', '/routes/web.php'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the "api" routes for the application.
|
||||
*
|
||||
* These routes are typically stateless.
|
||||
*/
|
||||
protected function mapApiRoutes(): void
|
||||
{
|
||||
Route::prefix('api')
|
||||
->middleware('api')
|
||||
->namespace($this->moduleNamespace)
|
||||
->group(module_path('Service', '/routes/api.php'));
|
||||
}
|
||||
}
|
114
Modules/Service/app/Providers/ServiceServiceProvider.php
Normal file
114
Modules/Service/app/Providers/ServiceServiceProvider.php
Normal file
@@ -0,0 +1,114 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Service\app\Providers;
|
||||
|
||||
use Illuminate\Support\Facades\Blade;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class ServiceServiceProvider extends ServiceProvider
|
||||
{
|
||||
protected string $moduleName = 'Service';
|
||||
|
||||
protected string $moduleNameLower = 'service';
|
||||
|
||||
/**
|
||||
* Boot the application events.
|
||||
*/
|
||||
public function boot(): void
|
||||
{
|
||||
$this->registerCommands();
|
||||
$this->registerCommandSchedules();
|
||||
$this->registerTranslations();
|
||||
$this->registerConfig();
|
||||
$this->registerViews();
|
||||
$this->loadMigrationsFrom(module_path($this->moduleName, 'database/migrations'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the service provider.
|
||||
*/
|
||||
public function register(): void
|
||||
{
|
||||
$this->app->register(RouteServiceProvider::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register commands in the format of Command::class
|
||||
*/
|
||||
protected function registerCommands(): void
|
||||
{
|
||||
// $this->commands([]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register command Schedules.
|
||||
*/
|
||||
protected function registerCommandSchedules(): void
|
||||
{
|
||||
// $this->app->booted(function () {
|
||||
// $schedule = $this->app->make(Schedule::class);
|
||||
// $schedule->command('inspire')->hourly();
|
||||
// });
|
||||
}
|
||||
|
||||
/**
|
||||
* Register translations.
|
||||
*/
|
||||
public function registerTranslations(): void
|
||||
{
|
||||
$langPath = resource_path('lang/modules/'.$this->moduleNameLower);
|
||||
|
||||
if (is_dir($langPath)) {
|
||||
$this->loadTranslationsFrom($langPath, $this->moduleNameLower);
|
||||
$this->loadJsonTranslationsFrom($langPath);
|
||||
} else {
|
||||
$this->loadTranslationsFrom(module_path($this->moduleName, 'lang'), $this->moduleNameLower);
|
||||
$this->loadJsonTranslationsFrom(module_path($this->moduleName, 'lang'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Register config.
|
||||
*/
|
||||
protected function registerConfig(): void
|
||||
{
|
||||
$this->publishes([module_path($this->moduleName, 'config/config.php') => config_path($this->moduleNameLower.'.php')], 'config');
|
||||
$this->mergeConfigFrom(module_path($this->moduleName, 'config/config.php'), $this->moduleNameLower);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register views.
|
||||
*/
|
||||
public function registerViews(): void
|
||||
{
|
||||
$viewPath = resource_path('views/modules/'.$this->moduleNameLower);
|
||||
$sourcePath = module_path($this->moduleName, 'resources/views');
|
||||
|
||||
$this->publishes([$sourcePath => $viewPath], ['views', $this->moduleNameLower.'-module-views']);
|
||||
|
||||
$this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower);
|
||||
|
||||
$componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.config('modules.paths.generator.component-class.path'));
|
||||
Blade::componentNamespace($componentNamespace, $this->moduleNameLower);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the services provided by the provider.
|
||||
*/
|
||||
public function provides(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
private function getPublishableViewPaths(): array
|
||||
{
|
||||
$paths = [];
|
||||
foreach (config('view.paths') as $path) {
|
||||
if (is_dir($path.'/modules/'.$this->moduleNameLower)) {
|
||||
$paths[] = $path.'/modules/'.$this->moduleNameLower;
|
||||
}
|
||||
}
|
||||
|
||||
return $paths;
|
||||
}
|
||||
}
|
145
Modules/Service/app/Repositories/ServiceRepository.php
Normal file
145
Modules/Service/app/Repositories/ServiceRepository.php
Normal file
@@ -0,0 +1,145 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Service\app\Repositories;
|
||||
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Str;
|
||||
use Modules\Banner\app\Services\FileManagementService;
|
||||
use Modules\Service\app\Models\Service;
|
||||
use Modules\Service\app\Models\ServiceMeta;
|
||||
|
||||
class ServiceRepository
|
||||
{
|
||||
//-- Retrieve all Services
|
||||
public function allServices($perPage = null, $filter = [], $sort = ['by' => 'id', 'sort' => 'DESC'])
|
||||
{
|
||||
return Service::with('serviceMeta')->when(array_keys($filter, true), function ($query) use ($filter) {
|
||||
if (!empty($filter['title'])) {
|
||||
$query->where('title', $filter['title']);
|
||||
}
|
||||
if (!empty($filter['price'])) {
|
||||
$query->where('price', 'like', '%' . $filter['price'] . '%');
|
||||
}
|
||||
})
|
||||
->orderBy($sort['by'], $sort['sort'])
|
||||
->paginate($perPage ?: env('PAGE_LIMIT', 999));
|
||||
}
|
||||
|
||||
//-- Find Service by uuid
|
||||
public function findServiceByUuid($uuid)
|
||||
{
|
||||
return Service::where('uuid', $uuid)->first();
|
||||
}
|
||||
|
||||
public function storeService(array $validated)
|
||||
{
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$service = new Service();
|
||||
$service->uuid = Str::uuid();
|
||||
$service->title = $validated['title'];
|
||||
$service->summary = $validated['summary'];
|
||||
$service->detail = $validated['detail'];
|
||||
$service->status = $validated['status'];
|
||||
$service->slug = $validated['slug'];
|
||||
// $service->homepage_flag = isset($validated['homepage_flag']) && $validated['homepage_flag'] == 1;
|
||||
$service->save();
|
||||
|
||||
if (isset($validated['image']) && $validated['image']->isValid()) {
|
||||
FileManagementService::storeFile(
|
||||
file: $validated['image'],
|
||||
uploadedFolderName: 'services',
|
||||
model: $service
|
||||
);
|
||||
}
|
||||
$serviceMeta = new ServiceMeta();
|
||||
$serviceMeta->uuid = Str::uuid();
|
||||
$serviceMeta->meta_title = $validated['meta_title'];
|
||||
$serviceMeta->meta_description = $validated['meta_description'];
|
||||
$serviceMeta->meta_keywords = $validated['meta_keywords'];
|
||||
$service->serviceMeta()->save($serviceMeta);
|
||||
DB::commit();
|
||||
|
||||
return $service;
|
||||
} catch (\Throwable $th) {
|
||||
report($th);
|
||||
DB::rollback();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public function updateService($validated, $uuid)
|
||||
{
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$service = $this->findServiceByUuid($uuid);
|
||||
if (!$service) {
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
$service->title = $validated['title'];
|
||||
$service->summary = $validated['summary'];
|
||||
$service->detail = $validated['detail'];
|
||||
$service->status = $validated['status'];
|
||||
$service->slug = $validated['slug'];
|
||||
// $service->homepage_flag = isset($validated['homepage_flag']) && $validated['homepage_flag'] == 1;
|
||||
$service->save();
|
||||
|
||||
if (isset($validated['image']) && $validated['image']->isValid()) {
|
||||
FileManagementService::uploadFile(
|
||||
file: $validated['image'],
|
||||
uploadedFolderName: 'services',
|
||||
filePath: $service->image_path,
|
||||
model: $service
|
||||
);
|
||||
}
|
||||
|
||||
// Update or create service meta
|
||||
$serviceMeta = $service->serviceMeta()->firstOrNew([]);
|
||||
if (!$serviceMeta->exists) {
|
||||
$serviceMeta->uuid = Str::uuid();
|
||||
}
|
||||
$serviceMeta->meta_title = $validated['meta_title'];
|
||||
$serviceMeta->meta_description = $validated['meta_description'];
|
||||
$serviceMeta->meta_keywords = $validated['meta_keywords'];
|
||||
$serviceMeta->save();
|
||||
|
||||
DB::commit();
|
||||
|
||||
return $service;
|
||||
} catch (\Throwable $th) {
|
||||
report($th);
|
||||
DB::rollBack();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
//-- Delete Service
|
||||
public function deleteService(string $uuid)
|
||||
{
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$service = $this->findServiceByUuid($uuid);
|
||||
if (!$service) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Delete the image file associated with the activity
|
||||
if ($service->image_path !== null) {
|
||||
FileManagementService::deleteFile($service->image_path);
|
||||
}
|
||||
// Delete associated service meta and service itself
|
||||
$service->serviceMeta()->delete();
|
||||
$service->delete();
|
||||
|
||||
DB::commit();
|
||||
|
||||
return $service;
|
||||
} catch (\Throwable $th) {
|
||||
DB::rollBack();
|
||||
report($th);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
68
Modules/Service/app/Services/FileManagementService.php
Normal file
68
Modules/Service/app/Services/FileManagementService.php
Normal file
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Service\app\Services;
|
||||
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class FileManagementService
|
||||
{
|
||||
//-- store file
|
||||
public static function storeFile($file, $uploadedFolderName, $model)
|
||||
{
|
||||
try {
|
||||
$originalFileName = $file->getClientOriginalName();
|
||||
$modifiedFileName = date('YmdHis').'_'.uniqid().'.'.$originalFileName;
|
||||
|
||||
$file->storeAs($uploadedFolderName, $modifiedFileName, 'public_uploads'); // This line uses 'public_uploads' disk
|
||||
|
||||
$model->image = $modifiedFileName;
|
||||
$model->image_path = $uploadedFolderName.'/'.$modifiedFileName;
|
||||
$model->save();
|
||||
} catch (\Throwable $th) {
|
||||
report($th);
|
||||
toastr()->error('Something went wrong.');
|
||||
|
||||
return redirect()->back();
|
||||
}
|
||||
}
|
||||
|
||||
//-- update file
|
||||
public static function uploadFile($file, $uploadedFolderName, $filePath, $model)
|
||||
{
|
||||
try {
|
||||
if ($filePath && Storage::disk('public_uploads')->exists($filePath)) {
|
||||
Storage::disk('public_uploads')->delete($filePath);
|
||||
}
|
||||
|
||||
$originalFileName = $file->getClientOriginalName();
|
||||
$modifiedFileName = date('YmdHis').'_'.uniqid().'.'.$originalFileName;
|
||||
|
||||
$file->storeAs($uploadedFolderName, $modifiedFileName, 'public_uploads'); // This line uses 'public_uploads' disk
|
||||
|
||||
$model->image = $modifiedFileName;
|
||||
$model->image_path = $uploadedFolderName.'/'.$modifiedFileName;
|
||||
|
||||
$model->save();
|
||||
} catch (\Throwable $th) {
|
||||
report($th);
|
||||
toastr()->error('Something went wrong.');
|
||||
|
||||
return back();
|
||||
}
|
||||
}
|
||||
|
||||
//-- delete file
|
||||
public static function deleteFile($filePath)
|
||||
{
|
||||
try {
|
||||
if ($filePath && Storage::disk('public_uploads')->exists($filePath)) {
|
||||
Storage::disk('public_uploads')->delete($filePath);
|
||||
} else {
|
||||
toastr()->error('File Not wrong.');
|
||||
}
|
||||
} catch (\Throwable $th) {
|
||||
report($th);
|
||||
toastr()->error('Something went wrong while deleting the file.');
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user