firstcommit
This commit is contained in:
0
Modules/Gallery/app/Http/Controllers/.gitkeep
Normal file
0
Modules/Gallery/app/Http/Controllers/.gitkeep
Normal file
141
Modules/Gallery/app/Http/Controllers/GalleryController.php
Normal file
141
Modules/Gallery/app/Http/Controllers/GalleryController.php
Normal file
@@ -0,0 +1,141 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Gallery\app\Http\Controllers;
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Modules\Gallery\app\Models\Gallery;
|
||||
use Modules\Gallery\app\Repositories\GalleryRepository;
|
||||
use Modules\Gallery\app\Services\FileManagementService;
|
||||
use Modules\Gallery\app\Http\Requests\CreateGalleryRequest;
|
||||
use Modules\Gallery\app\Models\GalleryCategory;
|
||||
|
||||
class GalleryController extends Controller
|
||||
{
|
||||
protected $galleryRepository;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->galleryRepository = new GalleryRepository;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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') : [];
|
||||
$galleries = $this->galleryRepository->allGalleries($perPage, $filter);
|
||||
|
||||
return view('gallery::index', compact('galleries'));
|
||||
}
|
||||
|
||||
//-- Find Gallery by uuid
|
||||
public function findGalleryByUuid($uuid)
|
||||
{
|
||||
return Gallery::where('uuid', $uuid)->first();
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
$galleryCategories = $this->galleryRepository->getGalleryCategories();
|
||||
return view('gallery::create', compact('galleryCategories'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
public function store(CreateGalleryRequest $request): RedirectResponse
|
||||
{
|
||||
try {
|
||||
$validated = $request->validated();
|
||||
|
||||
$this->galleryRepository->storeGallery($validated);
|
||||
toastr()->success('Gallery created successfully.');
|
||||
|
||||
return redirect()->route('cms.galleries.index');
|
||||
} catch (\Throwable $th) {
|
||||
DB::rollback();
|
||||
report($th);
|
||||
toastr()->error('Something went wrong.');
|
||||
return back();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the specified resource.
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
return view('gallery::show');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*/
|
||||
public function edit($uuid)
|
||||
{
|
||||
$data['galleryCategories'] = $this->galleryRepository->getGalleryCategories();
|
||||
$data['gallery'] = Gallery::with('galleryCategory')->where('uuid', $uuid)->first();
|
||||
|
||||
if (!$data['gallery']) {
|
||||
toastr()->error('Gallery not found.');
|
||||
return back();
|
||||
}
|
||||
return view('gallery::edit', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
public function update(CreateGalleryRequest $request, $uuid): RedirectResponse
|
||||
{
|
||||
$validated = $request->validated();
|
||||
try {
|
||||
$gallery = $this->galleryRepository->updateGallery($validated, $uuid);
|
||||
|
||||
if (!$gallery) {
|
||||
toastr()->error('Gallery not found !');
|
||||
return back();
|
||||
}
|
||||
|
||||
toastr()->success('Gallery updated successfully.');
|
||||
|
||||
return redirect()->route('cms.galleries.index');
|
||||
} catch (\Throwable $th) {
|
||||
report($th);
|
||||
toastr()->error('Something went wrong.');
|
||||
return back();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
public function destroy($uuid)
|
||||
{
|
||||
try {
|
||||
$gallery = $this->galleryRepository->deleteGallery($uuid);
|
||||
if (!$gallery) {
|
||||
toastr()->error('Image/Video not found.');
|
||||
return back();
|
||||
}
|
||||
|
||||
toastr()->success('Image/Video deleted successfully.');
|
||||
|
||||
return redirect()->route('cms.galleries.index');
|
||||
} catch (\Throwable $th) {
|
||||
report($th);
|
||||
toastr()->error('Something went wrong.');
|
||||
return back();
|
||||
}
|
||||
}
|
||||
}
|
0
Modules/Gallery/app/Http/Middleware/.gitkeep
Normal file
0
Modules/Gallery/app/Http/Middleware/.gitkeep
Normal file
0
Modules/Gallery/app/Http/Requests/.gitkeep
Normal file
0
Modules/Gallery/app/Http/Requests/.gitkeep
Normal file
52
Modules/Gallery/app/Http/Requests/CreateGalleryRequest.php
Normal file
52
Modules/Gallery/app/Http/Requests/CreateGalleryRequest.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Gallery\app\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class CreateGalleryRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'detail' => 'sometimes|nullable|string',
|
||||
'image' => 'sometimes|nullable|image|mimes:jpeg,png,jpg,gif',
|
||||
'image_path' => 'string|sometimes',
|
||||
'type' => 'string|sometimes',
|
||||
'category' => 'string|sometimes|nullable',
|
||||
'video_link' => 'string|sometimes|nullable',
|
||||
'status' => 'required',
|
||||
];
|
||||
}
|
||||
|
||||
public function messages()
|
||||
{
|
||||
return [
|
||||
'detail.string' => 'The detail field must be a string.',
|
||||
|
||||
'image.image' => 'The image must be an image file.',
|
||||
'image.mimes' => 'The image must be a file of type: jpeg, png, jpg, gif.',
|
||||
|
||||
'image_path.string' => 'The image path field must be a string.',
|
||||
|
||||
'type.string' => 'The type field must be a string.',
|
||||
|
||||
'category.string' => 'The category field must be a string.',
|
||||
|
||||
'video_link.string' => 'The video link field must be a string.',
|
||||
|
||||
'status.required' => 'The status field is required.',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
0
Modules/Gallery/app/Models/.gitkeep
Normal file
0
Modules/Gallery/app/Models/.gitkeep
Normal file
47
Modules/Gallery/app/Models/Gallery.php
Normal file
47
Modules/Gallery/app/Models/Gallery.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Gallery\app\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Modules\Gallery\Database\factories\GalleryFactory;
|
||||
|
||||
class Gallery extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*/
|
||||
protected $fillable = [
|
||||
'uuid',
|
||||
'gallery_category_id',
|
||||
'detail',
|
||||
'image',
|
||||
'image_path',
|
||||
'video_link',
|
||||
'status',
|
||||
];
|
||||
|
||||
protected static function newFactory(): GalleryFactory
|
||||
{
|
||||
//return GalleryFactory::new();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function getFullImageAttribute()
|
||||
{
|
||||
$result = null;
|
||||
if($this->image_path) {
|
||||
$result = asset('storage/uploads/' . $this->image_path);
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function galleryCategory()
|
||||
{
|
||||
return $this->belongsTo(GalleryCategory::class, 'gallery_category_id');
|
||||
}
|
||||
}
|
31
Modules/Gallery/app/Models/GalleryCategory.php
Normal file
31
Modules/Gallery/app/Models/GalleryCategory.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Gallery\app\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Modules\Gallery\Database\factories\GalleryCategoryFactory;
|
||||
|
||||
class GalleryCategory extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*/
|
||||
protected $fillable = [
|
||||
'uuid',
|
||||
'category',
|
||||
'type',
|
||||
];
|
||||
|
||||
protected static function newFactory(): GalleryCategoryFactory
|
||||
{
|
||||
//return GalleryCategoryFactory::new();
|
||||
}
|
||||
|
||||
public function gallery()
|
||||
{
|
||||
return $this->hasMany(Gallery::class, 'gallery_category_id');
|
||||
}
|
||||
}
|
0
Modules/Gallery/app/Providers/.gitkeep
Normal file
0
Modules/Gallery/app/Providers/.gitkeep
Normal file
114
Modules/Gallery/app/Providers/GalleryServiceProvider.php
Normal file
114
Modules/Gallery/app/Providers/GalleryServiceProvider.php
Normal file
@@ -0,0 +1,114 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Gallery\app\Providers;
|
||||
|
||||
use Illuminate\Support\Facades\Blade;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class GalleryServiceProvider extends ServiceProvider
|
||||
{
|
||||
protected string $moduleName = 'Gallery';
|
||||
|
||||
protected string $moduleNameLower = 'gallery';
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
}
|
59
Modules/Gallery/app/Providers/RouteServiceProvider.php
Normal file
59
Modules/Gallery/app/Providers/RouteServiceProvider.php
Normal file
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Gallery\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\Gallery\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('Gallery', '/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('Gallery', '/routes/api.php'));
|
||||
}
|
||||
}
|
152
Modules/Gallery/app/Repositories/GalleryRepository.php
Normal file
152
Modules/Gallery/app/Repositories/GalleryRepository.php
Normal file
@@ -0,0 +1,152 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Gallery\app\Repositories;
|
||||
|
||||
use Modules\Gallery\app\Models\Gallery;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Str;
|
||||
use Modules\Banner\app\Services\FileManagementService;
|
||||
use Modules\Gallery\app\Models\GalleryCategory;
|
||||
|
||||
class GalleryRepository
|
||||
{
|
||||
//-- Retrieve all Galleries
|
||||
public function allGalleries($perPage = null, $filter = [], $sort = ['by' => 'id', 'sort' => 'DESC'])
|
||||
{
|
||||
return Gallery::with('galleryCategory')->when(array_keys($filter, true), function ($query) use ($filter) {
|
||||
if (!empty($filter['detail'])) {
|
||||
$query->where('detail', 'like', '%' . $filter['detail'] . '%');
|
||||
}
|
||||
if (!empty($filter['type'])) {
|
||||
$query->where('type', 'like', '%' . $filter['type'] . '%');
|
||||
}
|
||||
})
|
||||
->orderBy($sort['by'], $sort['sort'])
|
||||
->paginate($perPage ?: env('PAGE_LIMIT', 999));
|
||||
}
|
||||
|
||||
public function getGalleryCategories()
|
||||
{
|
||||
return GalleryCategory::get();
|
||||
}
|
||||
|
||||
public function storeGallery(array $validated)
|
||||
{
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
// Create Gallery Category
|
||||
if (GalleryCategory::where('category', $validated['category'])->doesntExist()) {
|
||||
$galleryCategory = GalleryCategory::create([
|
||||
'uuid' => Str::uuid(),
|
||||
'category' => $validated['category'],
|
||||
'type' => $validated['type'],
|
||||
]);
|
||||
} else {
|
||||
$galleryCategory = GalleryCategory::where('category', $validated['category'])->first();
|
||||
}
|
||||
|
||||
// Create Gallery
|
||||
$gallery = $galleryCategory->gallery()->create([
|
||||
'uuid' => Str::uuid(),
|
||||
'detail' => $validated['detail'],
|
||||
'video_link' => isset($validated['video_link']) ? $validated['video_link'] : null,
|
||||
'status' => $validated['status'],
|
||||
]);
|
||||
|
||||
//-- store image
|
||||
if (isset($validated['image']) && $validated['image']->isValid()) {
|
||||
FileManagementService::storeFile(
|
||||
file: $validated['image'],
|
||||
uploadedFolderName: 'galleries',
|
||||
model: $gallery
|
||||
);
|
||||
}
|
||||
|
||||
DB::commit();
|
||||
|
||||
return $gallery;
|
||||
} catch (\Throwable $th) {
|
||||
DB::rollback();
|
||||
report($th);
|
||||
}
|
||||
}
|
||||
|
||||
public function findGalleryById($uuid)
|
||||
{
|
||||
return Gallery::where('uuid', $uuid)->first();
|
||||
}
|
||||
|
||||
|
||||
public function updateGallery($validated, $uuid)
|
||||
{
|
||||
try {
|
||||
$gallery = $this->findGalleryById($uuid);
|
||||
|
||||
if (!$gallery) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
if (GalleryCategory::where('category', $validated['category'])->doesntExist()) {
|
||||
$galleryCategory = GalleryCategory::create([
|
||||
'uuid' => Str::uuid(),
|
||||
'category' => $validated['category'],
|
||||
'type' => $validated['type'],
|
||||
]);
|
||||
} else {
|
||||
$galleryCategory = GalleryCategory::where('category', $validated['category'])->first();
|
||||
}
|
||||
//-- update gallery
|
||||
$gallery->detail = $validated['detail'];
|
||||
if ($gallery->video_link) {
|
||||
$gallery->video_link = $validated['video_link'];
|
||||
}
|
||||
$gallery->gallery_category_id = $galleryCategory->id;
|
||||
$gallery->status = $validated['status'];
|
||||
$gallery->save();
|
||||
|
||||
|
||||
//-- Update image
|
||||
if (isset($validated['image']) && $validated['image']->isValid()) {
|
||||
FileManagementService::uploadFile(
|
||||
file: $validated['image'],
|
||||
uploadedFolderName: 'galleries',
|
||||
filePath: $gallery->image_path,
|
||||
model: $gallery
|
||||
);
|
||||
}
|
||||
|
||||
return $gallery;
|
||||
} catch (\Throwable $th) {
|
||||
report($th);
|
||||
DB::transaction();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function deleteGallery($uuid)
|
||||
{
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$gallery = $this->findGalleryById($uuid);
|
||||
if (!$gallery) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Delete the image file associated with the banner
|
||||
if ($gallery->image_path !== null) {
|
||||
FileManagementService::deleteFile($gallery->image_path);
|
||||
}
|
||||
|
||||
$gallery->delete();
|
||||
DB::commit();
|
||||
|
||||
return true;
|
||||
} catch (\Throwable $th) {
|
||||
DB::rollback();
|
||||
report($th);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
66
Modules/Gallery/app/Services/FileManagementService.php
Normal file
66
Modules/Gallery/app/Services/FileManagementService.php
Normal file
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Gallery\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 redirect()->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