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.');
|
||||
}
|
||||
}
|
||||
}
|
31
Modules/Gallery/composer.json
Normal file
31
Modules/Gallery/composer.json
Normal file
@@ -0,0 +1,31 @@
|
||||
{
|
||||
"name": "nwidart/gallery",
|
||||
"description": "",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Nicolas Widart",
|
||||
"email": "n.widart@gmail.com"
|
||||
}
|
||||
],
|
||||
"extra": {
|
||||
"laravel": {
|
||||
"providers": [],
|
||||
"aliases": {
|
||||
|
||||
}
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Modules\\Gallery\\": "",
|
||||
"Modules\\Gallery\\App\\": "app/",
|
||||
"Modules\\Gallery\\Database\\Factories\\": "database/factories/",
|
||||
"Modules\\Gallery\\Database\\Seeders\\": "database/seeders/"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"Modules\\Gallery\\Tests\\": "tests/"
|
||||
}
|
||||
}
|
||||
}
|
0
Modules/Gallery/config/.gitkeep
Normal file
0
Modules/Gallery/config/.gitkeep
Normal file
5
Modules/Gallery/config/config.php
Normal file
5
Modules/Gallery/config/config.php
Normal file
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'name' => 'Gallery',
|
||||
];
|
0
Modules/Gallery/database/factories/.gitkeep
Normal file
0
Modules/Gallery/database/factories/.gitkeep
Normal file
0
Modules/Gallery/database/migrations/.gitkeep
Normal file
0
Modules/Gallery/database/migrations/.gitkeep
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('galleries', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->uuid();
|
||||
$table->unsignedBigInteger('gallery_category_id');
|
||||
$table->text('detail')->nullable();
|
||||
$table->string('image')->nullable();
|
||||
$table->string('image_path')->nullable();
|
||||
$table->string('video_link')->nullable();
|
||||
$table->string('status')->default('active');
|
||||
$table->softDeletes();
|
||||
$table->timestamps();
|
||||
|
||||
// Define foreign key constraint
|
||||
$table->foreign('gallery_category_id')->references('id')->on('gallery_categories')->onDelete('cascade');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('galleries');
|
||||
}
|
||||
};
|
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('gallery_categories', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->uuid();
|
||||
$table->string('type')->nullable();
|
||||
$table->string('category')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('gallery_categories');
|
||||
}
|
||||
|
||||
};
|
0
Modules/Gallery/database/seeders/.gitkeep
Normal file
0
Modules/Gallery/database/seeders/.gitkeep
Normal file
78
Modules/Gallery/database/seeders/GalleryDatabaseSeeder.php
Normal file
78
Modules/Gallery/database/seeders/GalleryDatabaseSeeder.php
Normal file
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Gallery\database\seeders;
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Modules\Gallery\app\Models\Gallery;
|
||||
use Modules\Gallery\app\Models\GalleryCategory;
|
||||
|
||||
class GalleryDatabaseSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
//-- galleryCategories
|
||||
$galleryCategories = [
|
||||
'surgery',
|
||||
'sample collection',
|
||||
];
|
||||
|
||||
foreach ($galleryCategories as $category) {
|
||||
GalleryCategory::create([
|
||||
'uuid' => Str::uuid(),
|
||||
'category' => $category,
|
||||
'type' => 'image',
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//-- galleries
|
||||
$galleries = [
|
||||
['detail' => 'hair transplant 1', 'image' => 'g1.jpg'],
|
||||
['detail' => 'hair transplant 2', 'image' => 'g2.jpg'],
|
||||
['detail' => 'hair transplant 3', 'image' => 'g3.jpg'],
|
||||
['detail' => 'hair transplant 4', 'image' => 'g4.jpg'],
|
||||
['detail' => 'hair transplant 5', 'image' => 'g5.jpg'],
|
||||
];
|
||||
|
||||
foreach ($galleries as $gallery) {
|
||||
$galleryCategoriesIdInRandomOrder = GalleryCategory::all()->random()->id;
|
||||
$cmsGallery = Gallery::create([
|
||||
'uuid' => Str::uuid(),
|
||||
'gallery_category_id' => $galleryCategoriesIdInRandomOrder,
|
||||
'detail' => $gallery['detail'],
|
||||
]);
|
||||
|
||||
// Add image to the created banner
|
||||
$this->uploadImageForGallery($gallery['image'], $cmsGallery);
|
||||
}
|
||||
}
|
||||
|
||||
private function uploadImageForGallery(string $imageFileName, $cmsbanner)
|
||||
{
|
||||
$seederDirPath = 'galleries/';
|
||||
|
||||
// Generate a unique filename for the new image
|
||||
$newFileName = Str::uuid() . '.jpg';
|
||||
|
||||
// Storage path for the new image
|
||||
$storagePath = '/galleries/' . $newFileName;
|
||||
|
||||
// Check if the image exists in the seeder_disk
|
||||
if (Storage::disk('seeder_disk')->exists($seederDirPath . $imageFileName)) {
|
||||
// Copy the image from seeder to public
|
||||
$fileContents = Storage::disk('seeder_disk')->get($seederDirPath . $imageFileName);
|
||||
|
||||
Storage::disk('public_uploads')->put($storagePath, $fileContents);
|
||||
|
||||
$cmsbanner->image = $newFileName;
|
||||
$cmsbanner->image_path = $storagePath;
|
||||
$cmsbanner->save();
|
||||
}
|
||||
}
|
||||
}
|
0
Modules/Gallery/lang/.gitkeep
Normal file
0
Modules/Gallery/lang/.gitkeep
Normal file
11
Modules/Gallery/module.json
Normal file
11
Modules/Gallery/module.json
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"name": "Gallery",
|
||||
"alias": "gallery",
|
||||
"description": "",
|
||||
"keywords": [],
|
||||
"priority": 0,
|
||||
"providers": [
|
||||
"Modules\\Gallery\\app\\Providers\\GalleryServiceProvider"
|
||||
],
|
||||
"files": []
|
||||
}
|
15
Modules/Gallery/package.json
Normal file
15
Modules/Gallery/package.json
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"build": "vite build"
|
||||
},
|
||||
"devDependencies": {
|
||||
"axios": "^1.1.2",
|
||||
"laravel-vite-plugin": "^0.7.5",
|
||||
"sass": "^1.69.5",
|
||||
"postcss": "^8.3.7",
|
||||
"vite": "^4.0.0"
|
||||
}
|
||||
}
|
0
Modules/Gallery/resources/assets/.gitkeep
Normal file
0
Modules/Gallery/resources/assets/.gitkeep
Normal file
0
Modules/Gallery/resources/assets/js/app.js
Normal file
0
Modules/Gallery/resources/assets/js/app.js
Normal file
0
Modules/Gallery/resources/assets/sass/app.scss
Normal file
0
Modules/Gallery/resources/assets/sass/app.scss
Normal file
0
Modules/Gallery/resources/views/.gitkeep
Normal file
0
Modules/Gallery/resources/views/.gitkeep
Normal file
48
Modules/Gallery/resources/views/create.blade.php
Normal file
48
Modules/Gallery/resources/views/create.blade.php
Normal file
@@ -0,0 +1,48 @@
|
||||
@extends('admin::layouts.master')
|
||||
|
||||
@section('title')
|
||||
Create Gallery
|
||||
@endsection
|
||||
|
||||
@section('breadcrumb')
|
||||
@php
|
||||
$breadcrumbData = [
|
||||
[
|
||||
'title' => 'Gallery',
|
||||
'link' => 'null',
|
||||
],
|
||||
[
|
||||
'title' => 'Dashboard',
|
||||
'link' => route('dashboard'),
|
||||
],
|
||||
[
|
||||
'title' => 'Galleries',
|
||||
'link' => null,
|
||||
],
|
||||
[
|
||||
'title' => 'Add Gallery',
|
||||
'link' => null,
|
||||
],
|
||||
];
|
||||
@endphp
|
||||
@include('admin::layouts.partials.breadcrumb', $breadcrumbData)
|
||||
@endsection
|
||||
@section('content')
|
||||
|
||||
<div class="row">
|
||||
<div class="col-xxl">
|
||||
<div class="card mb-4">
|
||||
<div class="card-header d-flex align-items-center justify-content-between">
|
||||
<h5 class="mb-0">Add Gallery</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<form
|
||||
action="{{ route('cms.galleries.store')}}"
|
||||
method="POST" enctype="multipart/form-data">
|
||||
@csrf
|
||||
@include('gallery::partial.form')
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
50
Modules/Gallery/resources/views/edit.blade.php
Normal file
50
Modules/Gallery/resources/views/edit.blade.php
Normal file
@@ -0,0 +1,50 @@
|
||||
@extends('admin::layouts.master')
|
||||
|
||||
@section('title')
|
||||
Update Gallery
|
||||
@endsection
|
||||
|
||||
@section('breadcrumb')
|
||||
@php
|
||||
$breadcrumbData = [
|
||||
[
|
||||
'title' => 'Gallery',
|
||||
'link' => 'null',
|
||||
],
|
||||
[
|
||||
'title' => 'Dashboard',
|
||||
'link' => route('dashboard'),
|
||||
],
|
||||
[
|
||||
'title' => 'Galleries',
|
||||
'link' => null,
|
||||
],
|
||||
[
|
||||
'title' => 'Update Gallery',
|
||||
'link' => null,
|
||||
],
|
||||
];
|
||||
@endphp
|
||||
@include('admin::layouts.partials.breadcrumb', $breadcrumbData)
|
||||
@endsection
|
||||
@section('content')
|
||||
|
||||
<div class="row">
|
||||
<div class="col-xxl">
|
||||
<div class="card mb-4">
|
||||
<div class="card-header d-flex align-items-center justify-content-between">
|
||||
<h5 class="mb-0">Update Gallery</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<form action="{{ route('cms.galleries.update', ['uuid' => $gallery->uuid]) }}" method="POST"
|
||||
enctype="multipart/form-data">
|
||||
@csrf
|
||||
@method('PUT')
|
||||
|
||||
@include('gallery::partial.form')
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
138
Modules/Gallery/resources/views/index.blade.php
Normal file
138
Modules/Gallery/resources/views/index.blade.php
Normal file
@@ -0,0 +1,138 @@
|
||||
@extends('admin::layouts.master')
|
||||
|
||||
@section('title')
|
||||
Gallery
|
||||
@endsection
|
||||
|
||||
@section('breadcrumb')
|
||||
@php
|
||||
$breadcrumbData = [
|
||||
[
|
||||
'title' => 'Gallery',
|
||||
'link' => 'null',
|
||||
],
|
||||
[
|
||||
'title' => 'Dashboard',
|
||||
'link' => route('dashboard'),
|
||||
],
|
||||
[
|
||||
'title' => 'Galleries',
|
||||
'link' => null,
|
||||
],
|
||||
];
|
||||
@endphp
|
||||
@include('admin::layouts.partials.breadcrumb', $breadcrumbData)
|
||||
@endsection
|
||||
|
||||
@section('content')
|
||||
<!-- banners List Table -->
|
||||
<div class="card">
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<h4 class="card-header">List of Gallery</h4>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="flex-column flex-md-row">
|
||||
<div class="dt-action-buttons text-end pt-3 px-3">
|
||||
<div class="dt-buttons btn-group flex-wrap">
|
||||
<a href="{{ route('cms.galleries.create') }}"
|
||||
class="btn btn-secondary create-new btn-primary d-none d-sm-inline-block text-white">
|
||||
<i class="bx bx-plus me-sm-1"></i>
|
||||
Add New
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card-datatable table-responsive">
|
||||
<table class="datatables-users table border-top">
|
||||
<thead class="table-light">
|
||||
<tr>
|
||||
<th>S.N</th>
|
||||
<th>Detail With Image</th>
|
||||
<th>Group</th>
|
||||
<th>Type</th>
|
||||
<th>Created At</th>
|
||||
<th>Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody class="table-border-bottom-0">
|
||||
@if(count($galleries) > 0)
|
||||
@foreach ($galleries ?? [] as $gallery)
|
||||
<tr>
|
||||
<td>
|
||||
#{{ $loop->iteration }}
|
||||
</td>
|
||||
<td>
|
||||
<div class="d-flex align-items-center me-3">
|
||||
<img src="{{ asset($gallery->image_path ? 'storage/uploads/' . $gallery->image_path : 'backend/uploads/images/no-Image.jpg') }}"
|
||||
alt="Image" class="rounded me-3" height="40" width="60" style="object-fit: cover">
|
||||
<div class="card-title mb-0 px-3">
|
||||
<h6 class="mb-0">{{ $gallery->detail }}</h6>
|
||||
{{-- <small class="text-muted">{{ Str::limit($post->short_detail, 80) }}</small> --}}
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
|
||||
<td class="text-capitalize">
|
||||
{{ $gallery->galleryCategory?->category }}
|
||||
</td>
|
||||
<td>
|
||||
<span class="badge bg-primary text-white text-capitalize">{{ $gallery->galleryCategory?->type }}</span>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
{{ $gallery->created_at->toFormattedDateString() }}
|
||||
|
||||
</td>
|
||||
<td>
|
||||
<div class="dropdown">
|
||||
<button type="button" class="btn p-0 dropdown-toggle hide-arrow"
|
||||
data-bs-toggle="dropdown">
|
||||
<i class="bx bx-dots-vertical-rounded"></i>
|
||||
</button>
|
||||
<div class="dropdown-menu">
|
||||
<a class="dropdown-item"
|
||||
href="{{ route('cms.galleries.edit', ['uuid' => $gallery->uuid]) }}"><i
|
||||
class="bx bx-edit-alt me-1"></i>
|
||||
Edit</a>
|
||||
|
||||
<form method="POST"
|
||||
action="{{ route('cms.galleries.delete', ['uuid' => $gallery->uuid]) }}"
|
||||
id="deleteForm_{{ $gallery->uuid }}" class="dropdown-item">
|
||||
@csrf
|
||||
@method('DELETE')
|
||||
<button type="submit" class="border-0 bg-transparent deleteBtn"
|
||||
style="color:inherit"><i class="bx bx-trash me-1"></i> Delete</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
@else
|
||||
<tr>
|
||||
<td colspan="7">No record found.</td>
|
||||
</tr>
|
||||
@endif
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="px-3">
|
||||
{{ $galleries->links('admin::layouts.partials.pagination') }}
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
{{-- style --}}
|
||||
@push('required-styles')
|
||||
@include('admin::vendor.dataTables.style')
|
||||
@endpush
|
||||
|
||||
{{-- script --}}
|
||||
@push('required-scripts')
|
||||
@include('admin::vendor.dataTables.script')
|
||||
@endpush
|
29
Modules/Gallery/resources/views/layouts/master.blade.php
Normal file
29
Modules/Gallery/resources/views/layouts/master.blade.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<meta name="csrf-token" content="{{ csrf_token() }}">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
|
||||
<title>Gallery Module - {{ config('app.name', 'Laravel') }}</title>
|
||||
|
||||
<meta name="description" content="{{ $description ?? '' }}">
|
||||
<meta name="keywords" content="{{ $keywords ?? '' }}">
|
||||
<meta name="author" content="{{ $author ?? '' }}">
|
||||
|
||||
<!-- Fonts -->
|
||||
<link rel="preconnect" href="https://fonts.bunny.net">
|
||||
<link href="https://fonts.bunny.net/css?family=figtree:400,500,600&display=swap" rel="stylesheet" />
|
||||
|
||||
{{-- Vite CSS --}}
|
||||
{{-- {{ module_vite('build-gallery', 'resources/assets/sass/app.scss') }} --}}
|
||||
</head>
|
||||
|
||||
<body>
|
||||
@yield('content')
|
||||
|
||||
{{-- Vite JS --}}
|
||||
{{-- {{ module_vite('build-gallery', 'resources/assets/js/app.js') }} --}}
|
||||
</body>
|
226
Modules/Gallery/resources/views/partial/form.blade.php
Normal file
226
Modules/Gallery/resources/views/partial/form.blade.php
Normal file
@@ -0,0 +1,226 @@
|
||||
<div x-data="{ showVideo: '{{ isset($gallery) && $gallery->galleryCategory->type == 'video' ? true : false }}', categoryType: '{{ $gallery->galleryCategory->type ?? '' }}' }">
|
||||
<div class="row mb-4">
|
||||
<div class="card-body pt-0 p-2">
|
||||
<div class="type d-flex gap-4 mb-2 align-items-center mx-2">
|
||||
<!-- Image checkbox -->
|
||||
<div class="gallery-image">
|
||||
<input type="radio" id="imageRadio" name="type" value="image" x-on:click="showVideo = false"
|
||||
x-bind:disabled="categoryType === 'video'"
|
||||
{{ (isset($gallery) && $gallery->galleryCategory->type) !== 'video' ? 'x-bind:checked="!showVideo"' : '' }}>
|
||||
<label for="imageRadio">Image</label><br>
|
||||
</div>
|
||||
<!-- Video checkbox -->
|
||||
<div class="gallery-video">
|
||||
<input type="radio" id="gallery-video" name="type" value="video" placeholder=""
|
||||
x-on:click="showVideo = true" x-bind:disabled="categoryType === 'image'"
|
||||
{{ isset($gallery) && $gallery->galleryCategory->type == 'video' ? 'x-bind:checked="showVideo"' : '' }}>
|
||||
<label for="gallery-video">Video</label><br>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
{{-- Image --}}
|
||||
<template x-if="!showVideo || (categoryType === 'image' && !showVideo)">
|
||||
<div>
|
||||
<div id="image-content" class="d-flex align-items-start align-items-sm-center gap-4">
|
||||
<img src="{{ asset(!empty($gallery->image_path) ? 'storage/uploads/' . $gallery->image_path : 'backend/uploads/images/no-Image.jpg') }}"
|
||||
alt="banner-image input-file" class="d-block rounded show-image" height="100"
|
||||
width="100" />
|
||||
|
||||
<div class="button-wrapper">
|
||||
<label for="upload" class="btn btn-primary me-2 mb-4" tabindex="0">
|
||||
<span class="d-none d-sm-block">Upload</span>
|
||||
<i class="bx bx-upload d-block d-sm-none"></i>
|
||||
<input type="file" id="upload" class="input-file" name="image" hidden
|
||||
accept="image/png, image/jpeg" />
|
||||
</label>
|
||||
<button type="button" class="btn btn-label-secondary image-reset mb-4">
|
||||
<i class="bx bx-reset d-block d-sm-none"></i>
|
||||
<span class="d-none d-sm-block">Reset</span>
|
||||
</button>
|
||||
|
||||
<p class="mb-0">Allowed JPG, GIF or PNG. Max size of 3Mb</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="mb-3 col-md-6">
|
||||
<label class="form-label" for="basic-default-name">Photo /Video Short Information</label>
|
||||
<input type="text" class="form-control" name="detail"
|
||||
value="{{ old('detail', $gallery->detail ?? '') }}" placeholder="e.g. Himalayas, Nepal"
|
||||
required />
|
||||
@error('detail')
|
||||
<div class="text-danger">{{ $message }}</div>
|
||||
@enderror
|
||||
</div>
|
||||
|
||||
<div class="mb-3 col-md-6">
|
||||
<label class="form-label" for="basic-default-company">Status</label>
|
||||
<select class="select2 form-select" id="basic-default-company select2Basic"
|
||||
aria-label="Default select example" name="status" required>
|
||||
<option value="active"{{ ($gallery->status ?? '') == 'active' ? 'selected' : '' }}>
|
||||
Active</option>
|
||||
<option value="inactive"{{ ($gallery->status ?? '') == 'inactive' ? 'selected' : '' }}>
|
||||
Inactive
|
||||
</option>
|
||||
</select>
|
||||
@error('status')
|
||||
<div class="text-danger">{{ $message }}</div>
|
||||
@enderror
|
||||
</div>
|
||||
|
||||
<div class="mb-3 col-md-6">
|
||||
<label class="form-label" for="basic-default-name">Select Or Insert Category</label>
|
||||
<input type="text" list="categories" class="form-control"
|
||||
value="{{ old('category', isset($gallery) ? $gallery->galleryCategory->category : '') }}"
|
||||
name="category" id="basic-default-name" />
|
||||
@error('category')
|
||||
<div class="text-danger">{{ $message }}</div>
|
||||
@enderror
|
||||
|
||||
<template x-if="!showVideo || (categoryType === 'image' && !showVideo)">
|
||||
{{-- image --}}
|
||||
<datalist id="categories">
|
||||
@foreach ($galleryCategories ?? [] as $galleryCategory)
|
||||
@if ($galleryCategory->type == 'image')
|
||||
<option value="{{ $galleryCategory->category }}">
|
||||
{{ $galleryCategory->category }}
|
||||
</option>
|
||||
@endif
|
||||
@endforeach
|
||||
</datalist>
|
||||
</template>
|
||||
|
||||
{{-- video --}}
|
||||
{{-- <template x-if="showVideo">
|
||||
<div>
|
||||
<datalist id="categories">
|
||||
@foreach ($galleryCategories ?? [] as $galleryCategory)
|
||||
@if ($galleryCategory->type == 'video')
|
||||
<option value="{{ $galleryCategory->category }}">
|
||||
{{ $galleryCategory->category }}
|
||||
</option>
|
||||
@endif
|
||||
@endforeach
|
||||
</datalist>
|
||||
</div>
|
||||
</template> --}}
|
||||
</div>
|
||||
{{-- <div>
|
||||
<button type="submit" class="btn btn-primary">
|
||||
@if (empty($gallery))
|
||||
Save Gallery
|
||||
@else
|
||||
Update Gallery
|
||||
@endif
|
||||
</button>
|
||||
</div> --}}
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
{{-- Video --}}
|
||||
<template x-if="showVideo || (categoryType === 'video' && !showVideo)">
|
||||
<div>
|
||||
<label class="form-label" for="videoLink">Video link</label>
|
||||
<input type="text" class="form-control" id="videoLink" name="video_link"
|
||||
value="{{ old('video_link', isset($gallery) ? $gallery->video_link : '') }}"
|
||||
placeholder="Eg. https://www.youtube.com/watch?v=NbFJ8W8L-3s" />
|
||||
@error('video_link')
|
||||
<div class="text-danger">{{ $message }}</div>
|
||||
@enderror
|
||||
|
||||
<div class="row">
|
||||
<div class="mb-3 col-md-6">
|
||||
<label class="form-label" for="basic-default-name">Photo /Video Short Information</label>
|
||||
<input type="text" class="form-control" name="detail"
|
||||
value="{{ old('detail', $gallery->detail ?? '') }}" placeholder="e.g. Himalayas, Nepal"
|
||||
required />
|
||||
@error('detail')
|
||||
<div class="text-danger">{{ $message }}</div>
|
||||
@enderror
|
||||
</div>
|
||||
|
||||
<div class="mb-3 col-md-6">
|
||||
<label class="form-label" for="basic-default-company">Status</label>
|
||||
<select class="select2 form-select" id="basic-default-company select2Basic"
|
||||
aria-label="Default select example" name="status" required>
|
||||
<option value="active"{{ ($gallery->status ?? '') == 'active' ? 'selected' : '' }}>
|
||||
Active</option>
|
||||
<option
|
||||
value="inactive"{{ ($gallery->status ?? '') == 'inactive' ? 'selected' : '' }}>
|
||||
Inactive
|
||||
</option>
|
||||
</select>
|
||||
@error('status')
|
||||
<div class="text-danger">{{ $message }}</div>
|
||||
@enderror
|
||||
</div>
|
||||
|
||||
<div class="mb-3 col-md-6">
|
||||
<label class="form-label" for="basic-default-name">Select Or Insert Category</label>
|
||||
<input type="text" list="categories" class="form-control"
|
||||
value="{{ old('category', isset($gallery) ? $gallery->galleryCategory->category : '') }}"
|
||||
name="category" id="basic-default-name" />
|
||||
@error('category')
|
||||
<div class="text-danger">{{ $message }}</div>
|
||||
@enderror
|
||||
|
||||
{{-- image --}}
|
||||
{{-- <template x-if="!showVideo">
|
||||
<datalist id="categories">
|
||||
@foreach ($galleryCategories ?? [] as $galleryCategory)
|
||||
@if ($galleryCategory->type == 'image')
|
||||
<option value="{{ $galleryCategory->category }}">
|
||||
{{ $galleryCategory->category }}
|
||||
</option>
|
||||
@endif
|
||||
@endforeach
|
||||
</datalist>
|
||||
</template> --}}
|
||||
|
||||
|
||||
<template x-if="showVideo || (categoryType === 'video' && !showVideo)">
|
||||
<div>
|
||||
{{-- video --}}
|
||||
<datalist id="categories">
|
||||
@foreach ($galleryCategories ?? [] as $galleryCategory)
|
||||
@if ($galleryCategory->type == 'video')
|
||||
<option value="{{ $galleryCategory->category }}">
|
||||
{{ $galleryCategory->category }}
|
||||
</option>
|
||||
@endif
|
||||
@endforeach
|
||||
</datalist>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
{{-- <div>
|
||||
<button type="submit" class="btn btn-primary">
|
||||
@if (empty($gallery))
|
||||
Save Gallery
|
||||
@else
|
||||
Update Gallery
|
||||
@endif
|
||||
</button>
|
||||
</div> --}}
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<div>
|
||||
<button type="submit" class="btn btn-primary">
|
||||
{{ !isset($gallery->id) ? 'Save Gallery' : 'Update Gallery' }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<hr class="my-0" />
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
@push('required-styles')
|
||||
@include('admin::vendor.select2.style')
|
||||
@endpush
|
||||
|
||||
@push('required-scripts')
|
||||
@include('admin::vendor.select2.script')
|
||||
@endpush
|
0
Modules/Gallery/routes/.gitkeep
Normal file
0
Modules/Gallery/routes/.gitkeep
Normal file
19
Modules/Gallery/routes/api.php
Normal file
19
Modules/Gallery/routes/api.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| API Routes
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here is where you can register API routes for your application. These
|
||||
| routes are loaded by the RouteServiceProvider within a group which
|
||||
| is assigned the "api" middleware group. Enjoy building your API!
|
||||
|
|
||||
*/
|
||||
|
||||
Route::middleware(['auth:sanctum'])->prefix('v1')->name('api.')->group(function () {
|
||||
Route::get('gallery', fn (Request $request) => $request->user())->name('gallery');
|
||||
});
|
39
Modules/Gallery/routes/web.php
Normal file
39
Modules/Gallery/routes/web.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Modules\Gallery\app\Http\Controllers\GalleryController;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Web Routes
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here is where you can register web routes for your application. These
|
||||
| routes are loaded by the RouteServiceProvider within a group which
|
||||
| contains the "web" middleware group. Now create something great!
|
||||
|
|
||||
*/
|
||||
Route::group(
|
||||
[
|
||||
'prefix' => 'apanel',
|
||||
'middleware' => ['auth'],
|
||||
'as' => 'cms.',
|
||||
],
|
||||
function () {
|
||||
Route::group(
|
||||
[
|
||||
'prefix' => 'cms',
|
||||
'as' => 'galleries.',
|
||||
'controller' => 'GalleryController',
|
||||
],
|
||||
function () {
|
||||
Route::get('galleries', 'index')->name('index');
|
||||
Route::get('galleries/create', 'create')->name('create');
|
||||
Route::post('galleries/store', 'store')->name('store');
|
||||
Route::get('galleries/{uuid}/edit', 'edit')->name('edit');
|
||||
Route::put('galleries/{uuid}/update', 'update')->name('update');
|
||||
Route::delete('galleries/{uuid}/delete', 'destroy')->name('delete');
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
0
Modules/Gallery/tests/Feature/.gitkeep
Normal file
0
Modules/Gallery/tests/Feature/.gitkeep
Normal file
0
Modules/Gallery/tests/Unit/.gitkeep
Normal file
0
Modules/Gallery/tests/Unit/.gitkeep
Normal file
26
Modules/Gallery/vite.config.js
Normal file
26
Modules/Gallery/vite.config.js
Normal file
@@ -0,0 +1,26 @@
|
||||
import { defineConfig } from 'vite';
|
||||
import laravel from 'laravel-vite-plugin';
|
||||
|
||||
export default defineConfig({
|
||||
build: {
|
||||
outDir: '../../public/build-gallery',
|
||||
emptyOutDir: true,
|
||||
manifest: true,
|
||||
},
|
||||
plugins: [
|
||||
laravel({
|
||||
publicDirectory: '../../public',
|
||||
buildDirectory: 'build-gallery',
|
||||
input: [
|
||||
__dirname + '/resources/assets/sass/app.scss',
|
||||
__dirname + '/resources/assets/js/app.js'
|
||||
],
|
||||
refresh: true,
|
||||
}),
|
||||
],
|
||||
});
|
||||
|
||||
//export const paths = [
|
||||
// 'Modules/$STUDLY_NAME$/resources/assets/sass/app.scss',
|
||||
// 'Modules/$STUDLY_NAME$/resources/assets/js/app.js',
|
||||
//];
|
Reference in New Issue
Block a user