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.');
|
||||
}
|
||||
}
|
||||
}
|
31
Modules/Service/composer.json
Normal file
31
Modules/Service/composer.json
Normal file
@@ -0,0 +1,31 @@
|
||||
{
|
||||
"name": "nwidart/service",
|
||||
"description": "",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Nicolas Widart",
|
||||
"email": "n.widart@gmail.com"
|
||||
}
|
||||
],
|
||||
"extra": {
|
||||
"laravel": {
|
||||
"providers": [],
|
||||
"aliases": {
|
||||
|
||||
}
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Modules\\Service\\": "",
|
||||
"Modules\\Service\\App\\": "app/",
|
||||
"Modules\\Service\\Database\\Factories\\": "database/factories/",
|
||||
"Modules\\Service\\Database\\Seeders\\": "database/seeders/"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"Modules\\Service\\Tests\\": "tests/"
|
||||
}
|
||||
}
|
||||
}
|
0
Modules/Service/config/.gitkeep
Normal file
0
Modules/Service/config/.gitkeep
Normal file
5
Modules/Service/config/config.php
Normal file
5
Modules/Service/config/config.php
Normal file
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'name' => 'Service',
|
||||
];
|
0
Modules/Service/database/factories/.gitkeep
Normal file
0
Modules/Service/database/factories/.gitkeep
Normal file
0
Modules/Service/database/migrations/.gitkeep
Normal file
0
Modules/Service/database/migrations/.gitkeep
Normal file
@@ -0,0 +1,35 @@
|
||||
<?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('services', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->uuid();
|
||||
$table->string('title');
|
||||
$table->text('summary')->nullable();
|
||||
$table->longText('detail')->nullable();;
|
||||
$table->string('image')->nullable();
|
||||
$table->string('image_path')->nullable();
|
||||
$table->string('status')->default('active');
|
||||
$table->softDeletes();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('services');
|
||||
}
|
||||
};
|
@@ -0,0 +1,34 @@
|
||||
<?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('service_metas', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->uuid();
|
||||
$table->unsignedBigInteger('service_id');
|
||||
$table->string('meta_title')->nullable();
|
||||
$table->longText('meta_description')->nullable();
|
||||
$table->longText('meta_keywords')->nullable();
|
||||
$table->softDeletes();
|
||||
$table->foreign('service_id')->references('id')->on('services');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('service_metas');
|
||||
}
|
||||
};
|
@@ -0,0 +1,28 @@
|
||||
<?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::table('services', function (Blueprint $table) {
|
||||
// $table->boolean('homepage_flag')->default(false)->after('image_path');
|
||||
// });
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
// Schema::table('services', function (Blueprint $table) {
|
||||
// $table->dropColumn('homepage_flag');
|
||||
// });
|
||||
}
|
||||
};
|
@@ -0,0 +1,28 @@
|
||||
<?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::table('services', function (Blueprint $table) {
|
||||
$table->string('slug', 300)->after('title');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('services', function (Blueprint $table) {
|
||||
$table->dropColumn('slug');
|
||||
});
|
||||
}
|
||||
};
|
0
Modules/Service/database/seeders/.gitkeep
Normal file
0
Modules/Service/database/seeders/.gitkeep
Normal file
83
Modules/Service/database/seeders/ServiceDatabaseSeeder.php
Normal file
83
Modules/Service/database/seeders/ServiceDatabaseSeeder.php
Normal file
@@ -0,0 +1,83 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Service\database\seeders;
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Modules\Service\app\Models\Service;
|
||||
|
||||
class ServiceDatabaseSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
|
||||
$services = [
|
||||
[
|
||||
'title' => 'PSYCHIATRY',
|
||||
'slug' => 'psychiatry',
|
||||
'summary' => null,
|
||||
'detail' => 'Psychiatry is one of the neglected fields in our country where even today we are fighting to establish psychiatric illnesses as medical disorders in true sense. A mental illness is not a character flaw. It is caused by genetic, biological, social and environmental factors. According to a report from the World Health Organization (WHO) one in four people around the world suffer from mental health problems at some point in their lives. With appropriate treatment and support, people with mental illness can have normal life and live successfully in their community. It is high time we took these illnesses seriously.',
|
||||
'image' => 's1.png'
|
||||
],
|
||||
[
|
||||
'title' => 'GERIATRIC MEDICINE',
|
||||
'slug' => 'generic-medicine',
|
||||
'summary' => null,
|
||||
'detail' => 'Demographic transition has become the norm of the current world. The booming geriatric population has posed serious challenges to the socio-economic aspects of every nation round the globe. How could Nepal be an exception to this global trend? Nepal is a country where very few people are aware about Geriatric medicine. In our context, even the established giants of general medicine are ignorant about the essence of this discipline.
|
||||
|
||||
Geriatrics or geriatric medicine is a specialty that focuses on health care of elderly people. It aims to promote health by preventing and treating diseases and disabilities in older adults Geriatric medicine is in its inception in our country and we have the responsibility to nurture its infancy.',
|
||||
'image' => 's2.png'
|
||||
],
|
||||
[
|
||||
'title' => 'PEDIATRICS',
|
||||
'slug' => 'pediatrics',
|
||||
'summary' => null,
|
||||
'detail' => '“The child who has health has hope and the one who has hope has everything. Let’s nourish hope from your home.”
|
||||
|
||||
Child care and adolescent health are beautiful sweet challenges for any families. Every child/adolescent has the right to health, to education, to protection and to tenderness to life. Nation builds on parents hand via vulnerable soft marks of their kids’ footsteps. The most overwhelming key to a child`s successful future is the full positive involvement of the parents in holistic way. Quality health care, optimum education provision and child friendly environment make it possible for welfare recipient kids to secure better future. Sadly, Children of developing countries are far deprived from quality health care and good guidance. Basic needs like growth, development, nutrition immunization and many more aspects are yet to be fulfilled. We have a vision where all children and adolescents are healthy and live in dignity with choices and opportunities. When it comes for a child health there is no ‘them’, it’s only ‘us’. We have a promise for promising child care and guidance. Let`s proceed ahead for your child`s best health. Let`s build profound hope on your kids roadmap.',
|
||||
'image' => 's3.png'
|
||||
]
|
||||
];
|
||||
|
||||
foreach ($services as $service) {
|
||||
$cmsService = Service::create([
|
||||
'uuid' => Str::uuid(),
|
||||
'title' => $service['title'],
|
||||
'summary' => $service['summary'],
|
||||
'detail' => $service['detail'],
|
||||
'slug' => $service['slug'],
|
||||
// 'homepage_flag' => $service['homepage_flag'],
|
||||
]);
|
||||
|
||||
// Add image to the created banner
|
||||
$this->uploadImageForService($service['image'], $cmsService);
|
||||
}
|
||||
}
|
||||
private function uploadImageForService(string $imageFileName, $cmsService)
|
||||
{
|
||||
$seederDirPath = 'services/';
|
||||
|
||||
// Generate a unique filename for the new image
|
||||
$newFileName = Str::uuid() . '.jpg';
|
||||
|
||||
// Storage path for the new image
|
||||
$storagePath = '/services/' . $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);
|
||||
|
||||
$cmsService->image = $newFileName;
|
||||
$cmsService->image_path = $storagePath;
|
||||
$cmsService->save();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
0
Modules/Service/lang/.gitkeep
Normal file
0
Modules/Service/lang/.gitkeep
Normal file
11
Modules/Service/module.json
Normal file
11
Modules/Service/module.json
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"name": "Service",
|
||||
"alias": "service",
|
||||
"description": "",
|
||||
"keywords": [],
|
||||
"priority": 0,
|
||||
"providers": [
|
||||
"Modules\\Service\\app\\Providers\\ServiceServiceProvider"
|
||||
],
|
||||
"files": []
|
||||
}
|
15
Modules/Service/package.json
Normal file
15
Modules/Service/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/Service/resources/assets/.gitkeep
Normal file
0
Modules/Service/resources/assets/.gitkeep
Normal file
0
Modules/Service/resources/assets/js/app.js
Normal file
0
Modules/Service/resources/assets/js/app.js
Normal file
0
Modules/Service/resources/assets/sass/app.scss
Normal file
0
Modules/Service/resources/assets/sass/app.scss
Normal file
0
Modules/Service/resources/views/.gitkeep
Normal file
0
Modules/Service/resources/views/.gitkeep
Normal file
46
Modules/Service/resources/views/create.blade.php
Normal file
46
Modules/Service/resources/views/create.blade.php
Normal file
@@ -0,0 +1,46 @@
|
||||
@extends('admin::layouts.master')
|
||||
|
||||
@section('title')
|
||||
Create Service
|
||||
@endsection
|
||||
|
||||
@section('breadcrumb')
|
||||
@php
|
||||
$breadcrumbData = [
|
||||
[
|
||||
'title' => 'Service',
|
||||
'link' => 'null',
|
||||
],
|
||||
[
|
||||
'title' => 'Dashboard',
|
||||
'link' => route('dashboard'),
|
||||
],
|
||||
[
|
||||
'title' => 'Services',
|
||||
'link' => null,
|
||||
],
|
||||
[
|
||||
'title' => 'Add Service',
|
||||
'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 Service</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<form
|
||||
action="{{ route('cms.services.store')}}"
|
||||
method="POST" enctype="multipart/form-data">
|
||||
@csrf
|
||||
@include('service::partial.form')
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>@endsection
|
48
Modules/Service/resources/views/edit.blade.php
Normal file
48
Modules/Service/resources/views/edit.blade.php
Normal file
@@ -0,0 +1,48 @@
|
||||
@extends('admin::layouts.master')
|
||||
|
||||
@section('title')
|
||||
Update Service
|
||||
@endsection
|
||||
|
||||
@section('breadcrumb')
|
||||
@php
|
||||
$breadcrumbData = [
|
||||
[
|
||||
'title' => 'Service',
|
||||
'link' => 'null',
|
||||
],
|
||||
[
|
||||
'title' => 'Dashboard',
|
||||
'link' => route('dashboard'),
|
||||
],
|
||||
[
|
||||
'title' => 'Services',
|
||||
'link' => null,
|
||||
],
|
||||
[
|
||||
'title' => 'Update Service',
|
||||
'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 Service</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<form action="{{ route('cms.services.update', ['uuid' => $service->uuid]) }}" method="POST"
|
||||
enctype="multipart/form-data">
|
||||
@csrf
|
||||
@method('PUT')
|
||||
|
||||
@include('service::partial.form')
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>@endsection
|
141
Modules/Service/resources/views/index.blade.php
Normal file
141
Modules/Service/resources/views/index.blade.php
Normal file
@@ -0,0 +1,141 @@
|
||||
@extends('admin::layouts.master')
|
||||
|
||||
@section('title')
|
||||
Service
|
||||
@endsection
|
||||
|
||||
@section('breadcrumb')
|
||||
@php
|
||||
$breadcrumbData = [
|
||||
[
|
||||
'title' => 'Service',
|
||||
'link' => 'null',
|
||||
],
|
||||
[
|
||||
'title' => 'Dashboard',
|
||||
'link' => route('dashboard'),
|
||||
],
|
||||
[
|
||||
'title' => 'Services',
|
||||
'link' => null,
|
||||
],
|
||||
];
|
||||
@endphp
|
||||
@include('admin::layouts.partials.breadcrumb', $breadcrumbData)
|
||||
@endsection
|
||||
|
||||
@section('content')
|
||||
<div class="card">
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<h4 class="card-header">List of Service</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.services.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>Title With Image</th>
|
||||
{{-- <th>Title</th> --}}
|
||||
{{-- <th>Homepage Flag</th> --}}
|
||||
<th>Created At</th>
|
||||
<th>Status</th>
|
||||
<th>Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody class="table-border-bottom-0">
|
||||
@if(count($services) > 0)
|
||||
@foreach ($services ?? [] as $service)
|
||||
<tr>
|
||||
<td>
|
||||
#{{ $loop->iteration }}
|
||||
</td>
|
||||
<td>
|
||||
<div class="d-flex align-items-center me-3">
|
||||
<img src="{{ asset($service->image_path ? $service->fullImage : '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">{{ $service->title }}</h6>
|
||||
<small class="text-muted">{{ Str::limit($service->summary, 80) }}</small>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
|
||||
{{-- <td>
|
||||
@if (isset($service->homepage_flag) && $service->homepage_flag == 1)
|
||||
<img src="{{ asset('backend/uploads/icons/tick.png') }}" alt="" srcset=""
|
||||
height="20px">
|
||||
@endif
|
||||
</td> --}}
|
||||
<td>
|
||||
{{ $service->created_at->toFormattedDateString() }}
|
||||
</td>
|
||||
<td>
|
||||
<span class="badge bg-label-{{ $service->status == 'active' ? 'success' : 'danger' }}">
|
||||
{{ $service->status }}</span>
|
||||
</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.services.edit', ['uuid' => $service->uuid]) }}"><i
|
||||
class="bx bx-edit-alt me-1"></i>
|
||||
Edit</a>
|
||||
|
||||
|
||||
<form method="POST"
|
||||
action="{{ route('cms.services.delete', ['uuid' => $service->uuid]) }}"
|
||||
id="deleteForm_{{ $service->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">
|
||||
{{ $services->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/Service/resources/views/layouts/master.blade.php
Normal file
29
Modules/Service/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>Service 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-service', 'resources/assets/sass/app.scss') }} --}}
|
||||
</head>
|
||||
|
||||
<body>
|
||||
@yield('content')
|
||||
|
||||
{{-- Vite JS --}}
|
||||
{{-- {{ module_vite('build-service', 'resources/assets/js/app.js') }} --}}
|
||||
</body>
|
146
Modules/Service/resources/views/partial/form.blade.php
Normal file
146
Modules/Service/resources/views/partial/form.blade.php
Normal file
@@ -0,0 +1,146 @@
|
||||
<div class="row">
|
||||
<div class="col-8">
|
||||
<div class="card mb-4">
|
||||
<h5 class="card-header">Service Details</h5>
|
||||
<hr class="my-0">
|
||||
<div class="card-body">
|
||||
<div class="row" x-data="generateSlug()" x-init="title = '{{ addslashes(old('title', $service->title ?? '')) }}';">
|
||||
<div class="mb-3 fv-plugins-icon-container">
|
||||
<label class="form-label" for="basic-default-name">Title</label>
|
||||
<input type="text" class="form-control" x-model="title" x-on:input="updateSlug()"
|
||||
name="title" {{-- value="" --}} value="{{ old('title', $service->title ?? '') }}"
|
||||
placeholder="e.g. Software Development" required />
|
||||
@error('title')
|
||||
<div class="text-danger">{{ $message }}</div>
|
||||
@enderror
|
||||
</div>
|
||||
|
||||
<div class="mb-3 col-md-6 fv-plugins-icon-container">
|
||||
<label for="slug" class="form-label">Slug</label>
|
||||
<input class="form-control" type="text" x-model="slug" name="slug" id=""
|
||||
value="{{ old('slug', $service->slug ?? '') }}" placeholder="e.g:service slug" required>
|
||||
@error('slug')
|
||||
<div class="text-danger">{{ $message }}</div>
|
||||
@enderror
|
||||
</div>
|
||||
|
||||
<div class="mb-3 col-md-6">
|
||||
<label for="language" class="form-label">Status</label>
|
||||
<div class="position-relative">
|
||||
<select id="select2Basic language" class="select2 form-select select2-hidden-accessible"
|
||||
data-select2-id="language" tabindex="-1" aria-hidden="true" name="status">
|
||||
<option value="active"
|
||||
{{ old('status', $service->status ?? '') == 'active' ? 'selected' : '' }}>
|
||||
Active</option>
|
||||
<option value="inactive"
|
||||
{{ old('status', $service->status ?? '') == 'inactive' ? 'selected' : '' }}>Inactive
|
||||
</option>
|
||||
</select>
|
||||
@error('status')
|
||||
<div class="text-danger">{{ $message }}</div>
|
||||
@enderror
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mb-3 col-md-12">
|
||||
<label for="exampleFormControlTextarea1" class="form-label">Summary</label>
|
||||
<textarea class="form-control" id="exampleFormControlTextarea1" rows="3" name="summary"
|
||||
placeholder="e.g:Write Summary here...">{{ old('summary', $service->summary ?? '') }}</textarea>
|
||||
@error('summary')
|
||||
<div class="text-danger">{{ $message }}</div>
|
||||
@enderror
|
||||
</div>
|
||||
|
||||
<div class="mb-3 col-md-12">
|
||||
<label class="form-label" for="basic-default-message">Detail</label>
|
||||
<textarea name="" id="mainTextarea" class="d-none">{{ !empty($service) ? $service->detail : '' }}</textarea>
|
||||
<textarea name="detail" class="form-contro full-editor form-control" id="editorTextarea" rows='5'
|
||||
placeholder="Creating custom software solutions or applications to meet specific business needs."></textarea>
|
||||
@error('detail')
|
||||
<div class="text-danger">{{ $message }}</div>
|
||||
@enderror
|
||||
</div>
|
||||
|
||||
{{-- If want to add function Add to Homepage for services --}}
|
||||
{{-- <div class="mb-3 col-md-6 fv-plugins-icon-container">
|
||||
<input type="checkbox" id="checkbox" name="homepage_flag" value="1" {{ old('homepage_flag', isset($service) && $service->homepage_flag == 1) ? 'checked' : '' }}>
|
||||
<label class="form-label" for="checkbox">Add To Homepage</label>
|
||||
</div> --}}
|
||||
|
||||
<div class="mt-2">
|
||||
<button type="submit" class="btn btn-primary me-2">
|
||||
{{ !isset($service) ? 'Save Changes' : 'Update Changes' }}</button>
|
||||
<button type="reset" class="btn btn-label-secondary">Reset</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- /Account -->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{-- Right sidebar --}}
|
||||
<div class="col-4">
|
||||
<div class="card mb-4">
|
||||
<h5 class="card-header">Images</h5>
|
||||
<div class="card-body">
|
||||
<div class="d-flex align-items-start align-items-sm-center gap-4">
|
||||
<img src="{{ asset(!empty($service->image_path) ? $service->fullImage : 'backend/uploads/images/no-Image.jpg') }}"
|
||||
alt="service-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>
|
||||
</div>
|
||||
|
||||
<div class="card mb-4">
|
||||
<h5 class="card-header">Service Meta Details</h5>
|
||||
<div class="card-body">
|
||||
<div class="mb-3 col-md-12">
|
||||
<label for="exampleFormControlTextarea1" class="form-label">Meta Title</label>
|
||||
<textarea class="form-control" id="exampleFormControlTextarea1" rows="3" name="meta_title">{{ old('meta_title', $service->serviceMeta->meta_title ?? '') }}</textarea>
|
||||
@error('meta_title')
|
||||
<div class="text-danger">{{ $message }}</div>
|
||||
@enderror
|
||||
</div>
|
||||
<div class="mb-3 col-md-12">
|
||||
<label for="exampleFormControlTextarea1" class="form-label">Meta Description</label>
|
||||
<textarea class="form-control" id="exampleFormControlTextarea1" rows="3" name="meta_description">{{ old('meta_description', $service->serviceMeta->meta_description ?? '') }}</textarea>
|
||||
@error('meta_description')
|
||||
<div class="text-danger">{{ $message }}</div>
|
||||
@enderror
|
||||
</div>
|
||||
<div class="mb-3 col-md-12">
|
||||
<label for="exampleFormControlTextarea1" class="form-label">Meta Keywords</label>
|
||||
<textarea class="form-control" id="exampleFormControlTextarea1" rows="3" name="meta_keywords">{{ old('meta_keywords', $service->serviceMeta->meta_keywords ?? '') }}</textarea>
|
||||
@error('meta_keywords')
|
||||
<div class="text-danger">{{ $message }}</div>
|
||||
@enderror
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@push('required-styles')
|
||||
@include('admin::vendor.full_editor.style')
|
||||
@include('admin::vendor.select2.style')
|
||||
@endpush
|
||||
|
||||
@push('required-scripts')
|
||||
@include('admin::vendor.textareaContentDisplay.script')
|
||||
@include('admin::vendor.full_editor.script')
|
||||
@include('admin::vendor.select2.script')
|
||||
@endpush
|
0
Modules/Service/routes/.gitkeep
Normal file
0
Modules/Service/routes/.gitkeep
Normal file
19
Modules/Service/routes/api.php
Normal file
19
Modules/Service/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('service', fn (Request $request) => $request->user())->name('service');
|
||||
});
|
39
Modules/Service/routes/web.php
Normal file
39
Modules/Service/routes/web.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Modules\Service\app\Http\Controllers\ServiceController;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| 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' => 'services.',
|
||||
'controller' => 'ServiceController',
|
||||
],
|
||||
function () {
|
||||
Route::get('services', 'index')->name('index');
|
||||
Route::get('services/create', 'create')->name('create');
|
||||
Route::post('services/store', 'store')->name('store');
|
||||
Route::get('services/{uuid}/edit', 'edit')->name('edit');
|
||||
Route::put('services/{uuid}/update', 'update')->name('update');
|
||||
Route::delete('services/{uuid}/delete', 'destroy')->name('delete');
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
0
Modules/Service/tests/Feature/.gitkeep
Normal file
0
Modules/Service/tests/Feature/.gitkeep
Normal file
0
Modules/Service/tests/Unit/.gitkeep
Normal file
0
Modules/Service/tests/Unit/.gitkeep
Normal file
26
Modules/Service/vite.config.js
Normal file
26
Modules/Service/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-service',
|
||||
emptyOutDir: true,
|
||||
manifest: true,
|
||||
},
|
||||
plugins: [
|
||||
laravel({
|
||||
publicDirectory: '../../public',
|
||||
buildDirectory: 'build-service',
|
||||
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