diff --git a/app/Http/Controllers/Admin/WebpageCrudController.php b/app/Http/Controllers/Admin/WebpageCrudController.php new file mode 100644 index 00000000..7f88fd1b --- /dev/null +++ b/app/Http/Controllers/Admin/WebpageCrudController.php @@ -0,0 +1,75 @@ +crud->setModel('App\Models\Webpage'); + $this->crud->setRoute(config('backpack.base.route_prefix') . '/webpage'); + $this->crud->setEntityNameStrings('webpage', 'webpages'); + + /* + |-------------------------------------------------------------------------- + | CrudPanel Configuration + |-------------------------------------------------------------------------- + */ + + $this->crud->addColumns([ + ['name' => 'title', 'type' => 'text', 'label' => 'Title'], + ]); + + // TODO: remove setFromDb() and manually define Fields and Columns + $this->crud->addFields([ + ['name' => 'image', 'type' => 'browse', 'label' => 'Image'], + ['name' => 'title', 'type' => 'text', 'label' => 'Title'], + ['name' => 'text', 'label' => 'Text', 'type' => 'summernote'], + ['name' => 'link','type' => 'text', 'lable' => 'Bottom link'], + ['name' => 'link_image','type' => 'browse', 'lable' => 'Bottom image'], + ['name' => 'upper_link','type' => 'text', 'lable' => 'Upper link'], + ['name' => 'upper_image','type' => 'browse', 'lable' => 'Upper image'], + ['name' => 'web_banner', 'type' => 'browse', 'label' => 'Web banner'], + ['name' => 'mob_banner', 'type' => 'browse', 'label' => 'Mobile banner'], + ]); + + // add asterisk for fields that are required in WebpageRequest + $this->crud->setRequiredFields(StoreRequest::class, 'create'); + $this->crud->setRequiredFields(UpdateRequest::class, 'edit'); + } + + public function store(StoreRequest $request) + { + // your additional operations before save here + $redirect_location = parent::storeCrud($request); + // your additional operations after save here + // use $this->data['entry'] or $this->crud->entry + return $redirect_location; + } + + public function update(UpdateRequest $request) + { + // your additional operations before save here + $redirect_location = parent::updateCrud($request); + // your additional operations after save here + // use $this->data['entry'] or $this->crud->entry + return $redirect_location; + } +} diff --git a/app/Http/Requests/WebpageRequest.php b/app/Http/Requests/WebpageRequest.php new file mode 100644 index 00000000..6cea7e2c --- /dev/null +++ b/app/Http/Requests/WebpageRequest.php @@ -0,0 +1,56 @@ +check(); + } + + /** + * Get the validation rules that apply to the request. + * + * @return array + */ + public function rules() + { + return [ + // 'name' => 'required|min:5|max:255' + ]; + } + + /** + * Get the validation attributes that apply to the request. + * + * @return array + */ + public function attributes() + { + return [ + // + ]; + } + + /** + * Get the validation messages that apply to the request. + * + * @return array + */ + public function messages() + { + return [ + // + ]; + } +} diff --git a/app/Models/Webpage.php b/app/Models/Webpage.php new file mode 100644 index 00000000..fc1f1c25 --- /dev/null +++ b/app/Models/Webpage.php @@ -0,0 +1,65 @@ +bigIncrements('id'); + $table->string('image')->nullable(); + $table->string('title')->nullable(); + $table->text('text')->nullable(); + $table->string('upper_link')->nullable(); + $table->string('upper_link_image')->nullable(); + $table->string('link')->nullable(); + $table->string('link_image')->nullable(); + $table->string('web_banner')->nullable(); + $table->string('mob_banner')->nullable(); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('webpages'); + } +} diff --git a/routes/backpack/custom.php b/routes/backpack/custom.php index 81051482..d86a44e0 100644 --- a/routes/backpack/custom.php +++ b/routes/backpack/custom.php @@ -37,4 +37,5 @@ Route::group([ CRUD::resource('gurnawlar', 'GurnawCrudController'); CRUD::resource('folders', 'FolderCrudController'); CRUD::resource('showbukjaorders', 'ShowBukjaOrdersCrudController'); + CRUD::resource('webpage', 'WebpageCrudController'); }); // this should be the absolute last line of this file