Файловый менеджер - Редактировать - /home/c7lekhnath/silverray.com.au/Modules/Language/database/seeders/68334/CustomPage.tar
Назад
lang/.gitkeep 0000644 00000000000 15012233232 0007075 0 ustar 00 module.json 0000644 00000000352 15012233232 0006715 0 ustar 00 { "name": "CustomPage", "alias": "custompage", "description": "", "keywords": [], "priority": 0, "providers": [ "Modules\\CustomPage\\app\\Providers\\CustomPageServiceProvider" ], "files": [] } tests/Unit/.gitkeep 0000644 00000000000 15012233232 0010235 0 ustar 00 tests/Feature/.gitkeep 0000644 00000000000 15012233232 0010711 0 ustar 00 vite.config.js 0000644 00000001312 15012233232 0007303 0 ustar 00 import { defineConfig } from 'vite'; import laravel from 'laravel-vite-plugin'; export default defineConfig({ build: { outDir: '../../public/build-custompage', emptyOutDir: true, manifest: true, }, plugins: [ laravel({ publicDirectory: '../../public', buildDirectory: 'build-custompage', 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', //]; routes/.gitkeep 0000644 00000000000 15012233232 0007475 0 ustar 00 routes/error_log 0000644 00000000450 15012233232 0007772 0 ustar 00 [07-May-2025 04:15:34 UTC] PHP Fatal error: Uncaught Error: Class "Illuminate\Support\Facades\Route" not found in /home/lekhnath/silverray.com.au/Modules/CustomPage/routes/web.php:17 Stack trace: #0 {main} thrown in /home/lekhnath/silverray.com.au/Modules/CustomPage/routes/web.php on line 17 routes/web.php 0000644 00000001474 15012233232 0007352 0 ustar 00 <?php use Illuminate\Support\Facades\Route; use Modules\CustomPage\app\Http\Controllers\CustomPageController; /* |-------------------------------------------------------------------------- | 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::middleware(['auth:admin', 'translation']) ->name('admin.') ->prefix('admin') ->group( function () { Route::resources(['custom-page' => CustomPageController::class]); Route::put('/custom-page/status-update/{id}', [CustomPageController::class, 'statusUpdate'])->name('custompage.status-update'); }); routes/api.php 0000644 00000001241 15012233232 0007336 0 ustar 00 <?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('custompage', fn (Request $request) => $request->user())->name('custompage'); }); composer.json 0000644 00000001317 15012233232 0007261 0 ustar 00 { "name": "nwidart/custompage", "description": "", "authors": [ { "name": "Nicolas Widart", "email": "n.widart@gmail.com" } ], "extra": { "laravel": { "providers": [], "aliases": { } } }, "autoload": { "psr-4": { "Modules\\CustomPage\\": "", "Modules\\CustomPage\\App\\": "app/", "Modules\\CustomPage\\Database\\Factories\\": "database/factories/", "Modules\\CustomPage\\Database\\Seeders\\": "database/seeders/" } }, "autoload-dev": { "psr-4": { "Modules\\CustomPage\\Tests\\": "tests/" } } } config/config.php 0000644 00000000057 15012233232 0007762 0 ustar 00 <?php return [ 'name' => 'CustomPage', ]; config/.gitkeep 0000644 00000000000 15012233232 0007421 0 ustar 00 package.json 0000644 00000000410 15012233232 0007016 0 ustar 00 { "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" } } app/Http/Controllers/.gitkeep 0000644 00000000000 15012233232 0012161 0 ustar 00 app/Http/Controllers/CustomPageController.php 0000644 00000012107 15012233232 0015367 0 ustar 00 <?php namespace Modules\CustomPage\app\Http\Controllers; use App\Enums\RedirectType; use Illuminate\Http\Request; use Illuminate\Http\Response; use App\Traits\RedirectHelperTrait; use App\Http\Controllers\Controller; use Illuminate\Http\RedirectResponse; use Modules\Language\app\Models\Language; use Modules\CustomPage\app\Models\CustomPage; use Modules\Language\app\Enums\TranslationModels; use Modules\Language\app\Traits\GenerateTranslationTrait; use Modules\CustomPage\app\Http\Requests\CustomPageRequest; class CustomPageController extends Controller { use RedirectHelperTrait, GenerateTranslationTrait; /** * Display a listing of the resource. */ public function index(Request $request) { checkAdminHasPermissionAndThrowException('custom.page.view'); $query = CustomPage::query(); $query->when($request->filled('keyword'), function ($qa) use ($request) { $qa->whereHas('translations', function ($q) use ($request) { $q->where('page_name', 'like', '%'.$request->keyword.'%'); }); }); $query->when($request->filled('status'), function ($q) use ($request) { $q->where('status', $request->status); }); $orderBy = $request->filled( 'order_by' ) && $request->order_by == 1 ? 'asc' : 'desc'; if ($request->filled('par-page')) { $custom_pages = $request->get('par-page') == 'all' ? $query->orderBy( 'id', $orderBy )->get() : $query->orderBy( 'id', $orderBy )->paginate($request->get('par-page'))->withQueryString(); } else { $custom_pages = $query->orderBy( 'id', $orderBy )->paginate()->withQueryString(); } return view('custompage::index', compact('custom_pages')); } /** * Show the form for creating a new resource. */ public function create() { checkAdminHasPermissionAndThrowException('custom.page.create'); return view('custompage::create'); } /** * Store a newly created resource in storage. */ public function store(CustomPageRequest $request): RedirectResponse { checkAdminHasPermissionAndThrowException('custom.page.store'); $validated_date = $request->validated(); $custom_page = CustomPage::create($validated_date); $this->generateTranslations( TranslationModels::CustomPage, $custom_page, 'page_id', $request, ); return $this->redirectWithMessage( RedirectType::CREATE->value, 'admin.custom-page.edit', [ 'custom_page' => $custom_page->id, 'code' => allLanguages()->first()->code ] ); } /** * Show the specified resource. */ public function show($id) { return view('custompage::show'); } /** * Show the form for editing the specified resource. */ public function edit($id) { checkAdminHasPermissionAndThrowException('custom.page.edit'); $code = request('code') ?? getSessionLanguage(); if (!Language::where('code', $code)->exists()) { abort(404); } $custom_page = CustomPage::findOrFail($id); $languages = allLanguages(); return view('custompage::edit', compact('custom_page','languages','code')); } /** * Update the specified resource in storage. */ public function update(CustomPageRequest $request, $id): RedirectResponse { checkAdminHasPermissionAndThrowException('custom.page.update'); $languages = allLanguages(); $validated_date = $request->validated(); $custom_page = CustomPage::findOrFail($id); $custom_page->update($validated_date); $this->updateTranslations( $custom_page, $request, $validated_date, ); return $this->redirectWithMessage( RedirectType::UPDATE->value, 'admin.custom-page.edit', [ 'custom_page' => $custom_page->id, 'code' => $request->code, ] ); } public function statusUpdate($id) { checkAdminHasPermissionAndThrowException('custom.page.status'); $custom_page = CustomPage::find($id); $status = $custom_page->status == 'enable' ? 'disable' : 'enable'; $custom_page->status = $status; $custom_page->save(); $notification = trans('Updated Successfully'); return response()->json([ 'success' => true, 'message' => $notification, ]); } /** * Remove the specified resource from storage. */ public function destroy($id) { checkAdminHasPermissionAndThrowException('custom.page.delete'); $custom_page = CustomPage::findOrFail($id); $custom_page->translations()->each(function ($translation) { $translation->delete(); }); $custom_page->delete(); return $this->redirectWithMessage(RedirectType::DELETE->value, 'admin.custom-page.index'); } } app/Http/Requests/CustomPageRequest.php 0000644 00000002505 15012233232 0014202 0 ustar 00 <?php namespace Modules\CustomPage\app\Http\Requests; use Illuminate\Foundation\Http\FormRequest; class CustomPageRequest extends FormRequest { /** * Get the validation rules that apply to the request. */ public function rules(): array { $rules = [ 'page_name' => 'required|string|max:255', 'description' => 'required', ]; if ($this->isMethod('post')) { $rules['slug'] = 'sometimes|required|string|max:500|unique:custom_pages'; } if ($this->isMethod('put')) { $rules['slug'] = 'sometimes|required|string|max:500|unique:custom_pages,slug,'. $this->custom_page; } return $rules; } public function messages(): array { return [ 'page_name.required' => trans('The Name is required'), 'page_name.string' => trans('The name must be a valid text'), 'page_name.max' => trans('The name can only be up to 255 characters'), 'slug.required' => trans('Slug is required'), 'slug.string' => trans('Slug must be a valid text'), 'slug.max' => trans('Slug can only be up to 500 characters'), 'slug.unique' => trans('Slug already exist'), 'description.required' => trans('Description is required'), ]; } } app/Http/Requests/.gitkeep 0000644 00000000000 15012233232 0011466 0 ustar 00 app/Http/Requests/error_log 0000644 00000000536 15012233232 0011770 0 ustar 00 [13-May-2025 16:36:19 UTC] PHP Fatal error: Uncaught Error: Class "Illuminate\Foundation\Http\FormRequest" not found in /home/lekhnath/silverray.com.au/Modules/CustomPage/app/Http/Requests/CustomPageRequest.php:7 Stack trace: #0 {main} thrown in /home/lekhnath/silverray.com.au/Modules/CustomPage/app/Http/Requests/CustomPageRequest.php on line 7 app/Http/Middleware/.gitkeep 0000644 00000000000 15012233232 0011730 0 ustar 00 app/Models/.gitkeep 0000644 00000000000 15012233232 0010157 0 ustar 00 app/Models/CustomPageTranslation.php 0000644 00000001044 15012233232 0013536 0 ustar 00 <?php namespace Modules\CustomPage\app\Models; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Factories\HasFactory; use Modules\CustomPage\Database\factories\CustomPageTranslationFactory; class CustomPageTranslation extends Model { use HasFactory; /** * The attributes that are mass assignable. */ protected $fillable = ['page_name', 'description']; protected static function newFactory(): CustomPageTranslationFactory { //return CustomPageTranslationFactory::new(); } } app/Models/error_log 0000644 00000001224 15012233232 0010454 0 ustar 00 [12-May-2025 17:15:00 UTC] PHP Fatal error: Uncaught Error: Class "Illuminate\Database\Eloquent\Model" not found in /home/lekhnath/silverray.com.au/Modules/CustomPage/app/Models/CustomPage.php:10 Stack trace: #0 {main} thrown in /home/lekhnath/silverray.com.au/Modules/CustomPage/app/Models/CustomPage.php on line 10 [14-May-2025 04:55:26 UTC] PHP Fatal error: Uncaught Error: Class "Illuminate\Database\Eloquent\Model" not found in /home/lekhnath/silverray.com.au/Modules/CustomPage/app/Models/CustomPageTranslation.php:9 Stack trace: #0 {main} thrown in /home/lekhnath/silverray.com.au/Modules/CustomPage/app/Models/CustomPageTranslation.php on line 9 app/Models/CustomPage.php 0000644 00000002227 15012233232 0011323 0 ustar 00 <?php namespace Modules\CustomPage\app\Models; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\HasMany; use Illuminate\Database\Eloquent\Factories\HasFactory; use Modules\CustomPage\Database\factories\CustomPageFactory; class CustomPage extends Model { use HasFactory; /** * The attributes that are mass assignable. */ protected $fillable = ['slug', 'status']; protected static function newFactory(): CustomPageFactory { //return CustomPageFactory::new(); } protected $appends = ['page_name']; public function getTranslation($code): ?CustomPageTranslation { return $this->hasOne(CustomPageTranslation::class, 'page_id')->where('lang_code', $code)->first(); } public function translations(): ?HasMany { return $this->hasMany(CustomPageTranslation::class, 'page_id'); } public function translation() { return $this->hasOne(CustomPageTranslation::class, 'page_id')->where('lang_code', getSessionLanguage()); } public function getPageNameAttribute(): ?string { return $this->translation->page_name; } } app/Providers/RouteServiceProvider.php 0000644 00000002677 15012233232 0014151 0 ustar 00 <?php namespace Modules\CustomPage\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\CustomPage\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('CustomPage', '/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('CustomPage', '/routes/api.php')); } } app/Providers/.gitkeep 0000644 00000000000 15012233232 0010711 0 ustar 00 app/Providers/CustomPageServiceProvider.php 0000644 00000006456 15012233232 0015121 0 ustar 00 <?php namespace Modules\CustomPage\app\Providers; use Illuminate\Support\Facades\Blade; use Illuminate\Support\ServiceProvider; class CustomPageServiceProvider extends ServiceProvider { protected string $moduleName = 'CustomPage'; protected string $moduleNameLower = 'custompage'; /** * 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; } } database/factories/.gitkeep 0000644 00000000000 15012233232 0011677 0 ustar 00 database/migrations/2024_02_04_103615_create_custom_page_translations_table.php 0000644 00000001346 15012233232 0023065 0 ustar 00 <?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('custom_page_translations', function (Blueprint $table) { $table->id(); $table->integer('page_id'); $table->string('lang_code'); $table->text('page_name'); $table->longText('description')->nullable(); $table->timestamps(); }); } /** * Reverse the migrations. */ public function down(): void { Schema::dropIfExists('custom_page_translations'); } }; database/migrations/.gitkeep 0000644 00000000000 15012233232 0012074 0 ustar 00 database/migrations/error_log 0000644 00000001520 15012233232 0012370 0 ustar 00 [14-May-2025 12:42:14 UTC] PHP Fatal error: Uncaught Error: Class "Illuminate\Database\Migrations\Migration" not found in /home/c7lekhnath/silverray.com.au/Modules/CustomPage/database/migrations/2024_02_04_103615_create_custom_page_translations_table.php:7 Stack trace: #0 {main} thrown in /home/c7lekhnath/silverray.com.au/Modules/CustomPage/database/migrations/2024_02_04_103615_create_custom_page_translations_table.php on line 7 [14-May-2025 16:48:43 UTC] PHP Fatal error: Uncaught Error: Class "Illuminate\Database\Migrations\Migration" not found in /home/c7lekhnath/silverray.com.au/Modules/CustomPage/database/migrations/2024_02_04_103504_create_custom_pages_table.php:7 Stack trace: #0 {main} thrown in /home/c7lekhnath/silverray.com.au/Modules/CustomPage/database/migrations/2024_02_04_103504_create_custom_pages_table.php on line 7 database/migrations/2024_02_04_103504_create_custom_pages_table.php 0000644 00000001215 15012233232 0020437 0 ustar 00 <?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('custom_pages', function (Blueprint $table) { $table->id(); $table->text('slug'); $table->enum('status', ['enable', 'disable'])->default('enable'); $table->timestamps(); }); } /** * Reverse the migrations. */ public function down(): void { Schema::dropIfExists('custom_pages'); } }; database/seeders/CustomPageDatabaseSeeder.php 0000644 00000000401 15012233232 0015263 0 ustar 00 <?php namespace Modules\CustomPage\database\seeders; use Illuminate\Database\Seeder; class CustomPageDatabaseSeeder extends Seeder { /** * Run the database seeds. */ public function run(): void { // $this->call([]); } } database/seeders/.gitkeep 0000644 00000000000 15012233232 0011352 0 ustar 00 database/seeders/CustomPagePermissionSeeder.php 0000644 00000002574 15012233232 0015724 0 ustar 00 <?php namespace Modules\CustomPage\database\seeders; use Illuminate\Database\Seeder; use Spatie\Permission\Models\Role; use Spatie\Permission\Models\Permission; class CustomPagePermissionSeeder extends Seeder { /** * Run the database seeds. */ public function run(): void { $roleSuperAdmin = Role::where(['guard_name' => 'admin'])->first(); $permissions = [ [ 'group_name' => 'custom page', 'permissions' => [ 'custom.page.view', 'custom.page.create', 'custom.page.store', 'custom.page.edit', 'custom.page.update', 'custom.page.delete', 'custom.page.status', 'custom.page.translate', ] ] ]; for ($i = 0; $i < count($permissions); $i++) { $permissionGroup = $permissions[$i]['group_name']; for ($j = 0; $j < count($permissions[$i]['permissions']); $j++) { $permission = Permission::create([ 'name' => $permissions[$i]['permissions'][$j], 'group_name' => $permissionGroup, 'guard_name' => 'admin' ]); $roleSuperAdmin->givePermissionTo($permission); } } } } database/seeders/error_log 0000644 00000001300 15012233233 0011643 0 ustar 00 [14-May-2025 08:48:05 UTC] PHP Fatal error: Uncaught Error: Class "Illuminate\Database\Seeder" not found in /home/lekhnath/silverray.com.au/Modules/CustomPage/database/seeders/CustomPageDatabaseSeeder.php:7 Stack trace: #0 {main} thrown in /home/lekhnath/silverray.com.au/Modules/CustomPage/database/seeders/CustomPageDatabaseSeeder.php on line 7 [14-May-2025 09:28:08 UTC] PHP Fatal error: Uncaught Error: Class "Illuminate\Database\Seeder" not found in /home/lekhnath/silverray.com.au/Modules/CustomPage/database/seeders/CustomPagePermissionSeeder.php:9 Stack trace: #0 {main} thrown in /home/lekhnath/silverray.com.au/Modules/CustomPage/database/seeders/CustomPagePermissionSeeder.php on line 9 resources/assets/.gitkeep 0000644 00000000000 15012233233 0011471 0 ustar 00 resources/assets/js/app.js 0000644 00000000000 15012233233 0011572 0 ustar 00 resources/assets/sass/app.scss 0000644 00000000000 15012233233 0012466 0 ustar 00 resources/views/sidebar.blade.php 0000644 00000000351 15012233233 0013074 0 ustar 00 <li class="{{ Route::is('admin.custom-page.*') ? 'active' : '' }}"> <a class="nav-link" href="{{ route('admin.custom-page.index', ['code' => getSessionLanguage()]) }}"> <span>{{ __('Custom Pages') }}</span> </a> </li>