From d60131e3ad66c306bd97c04480e0a82317da6eb8 Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Fri, 7 Dec 2018 17:42:01 +0100 Subject: [PATCH] wip #2413 @1 --- .../Admin/ProjectCrudController.php | 60 +++++++++++++++++++ app/Http/Requests/ProjectRequest.php | 56 +++++++++++++++++ app/Models/BackpackUser.php | 2 + app/Models/Project.php | 55 +++++++++++++++++ app/User.php | 6 +- composer.json | 1 + composer.lock | 2 +- config/backpack/base.php | 16 ++--- config/backpack/crud.php | 4 +- ...018_12_07_161238_create_projects_table.php | 31 ++++++++++ ...62652_add_attributes_to_projects_table.php | 34 +++++++++++ .../2018_12_07_163246_create_tasks_table.php | 36 +++++++++++ ...18_12_07_163613_create_companies_table.php | 39 ++++++++++++ .../base/inc/sidebar_content.blade.php | 13 +++- routes/backpack/custom.php | 3 +- 15 files changed, 344 insertions(+), 14 deletions(-) create mode 100644 app/Http/Controllers/Admin/ProjectCrudController.php create mode 100644 app/Http/Requests/ProjectRequest.php create mode 100644 app/Models/Project.php create mode 100644 database/migrations/2018_12_07_161238_create_projects_table.php create mode 100644 database/migrations/2018_12_07_162652_add_attributes_to_projects_table.php create mode 100644 database/migrations/2018_12_07_163246_create_tasks_table.php create mode 100644 database/migrations/2018_12_07_163613_create_companies_table.php diff --git a/app/Http/Controllers/Admin/ProjectCrudController.php b/app/Http/Controllers/Admin/ProjectCrudController.php new file mode 100644 index 0000000..f9a7e1b --- /dev/null +++ b/app/Http/Controllers/Admin/ProjectCrudController.php @@ -0,0 +1,60 @@ +crud->setModel('App\Models\Project'); + $this->crud->setRoute(config('backpack.base.route_prefix') . '/project'); + $this->crud->setEntityNameStrings('project', 'projects'); + + /* + |-------------------------------------------------------------------------- + | CrudPanel Configuration + |-------------------------------------------------------------------------- + */ + + // TODO: remove setFromDb() and manually define Fields and Columns + $this->crud->setFromDb(); + + // add asterisk for fields that are required in ProjectRequest + $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/ProjectRequest.php b/app/Http/Requests/ProjectRequest.php new file mode 100644 index 0000000..94e0553 --- /dev/null +++ b/app/Http/Requests/ProjectRequest.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/BackpackUser.php b/app/Models/BackpackUser.php index e27c646..6aee419 100644 --- a/app/Models/BackpackUser.php +++ b/app/Models/BackpackUser.php @@ -12,6 +12,8 @@ class BackpackUser extends User protected $table = 'users'; + protected $attributes = ['company' => '']; + /** * Send the password reset notification. * diff --git a/app/Models/Project.php b/app/Models/Project.php new file mode 100644 index 0000000..5a3c629 --- /dev/null +++ b/app/Models/Project.php @@ -0,0 +1,55 @@ + 'Backpack', // Menu logos - 'logo_lg' => 'Backpack', - 'logo_mini' => 'Bp', + 'logo_lg' => 'Cubedesigners', + 'logo_mini' => 'CD', // Developer or company name. Shown in footer. - 'developer_name' => 'Cristian Tabacitu', + 'developer_name' => '', // Developer website. Link in footer. 'developer_link' => 'http://tabacitu.ro', // Show powered by Laravel Backpack in the footer? - 'show_powered_by' => true, + 'show_powered_by' => false, // The AdminLTE skin. Affects menu color and primary/secondary colors used throughout the application. - 'skin' => 'skin-purple', + 'skin' => 'skin-blue', // Options: skin-black, skin-blue, skin-purple, skin-red, skin-yellow, skin-green, skin-blue-light, skin-black-light, skin-purple-light, skin-green-light, skin-red-light, skin-yellow-light // Date & Datetime Format Syntax: https://github.com/jenssegers/date#usage // (same as Carbon) - 'default_date_format' => 'j F Y', + 'default_date_format' => 'j F Y', 'default_datetime_format' => 'j F Y H:i', // Content of the HTML meta robots tag to prevent indexing and link following @@ -42,7 +42,7 @@ return [ // Overlays - CSS files that change the look and feel of the admin panel 'overlays' => [ 'vendor/backpack/base/backpack.bold.css', - // 'vendor/backpack/base/backpack.content.is.king.css', + 'vendor/backpack/base/backpack.content.is.king.css', ], /* @@ -105,7 +105,7 @@ return [ // Username column for authentication // The Backpack default is the same as the Laravel default (email) // If you need to switch to username, you also need to create that column in your db - 'authentication_column' => 'email', + 'authentication_column' => 'email', 'authentication_column_name' => 'Email', // The guard that protects the Backpack admin panel. diff --git a/config/backpack/crud.php b/config/backpack/crud.php index dc47c25..ccc4408 100644 --- a/config/backpack/crud.php +++ b/config/backpack/crud.php @@ -313,7 +313,7 @@ return [ // "ga" => "Irish", // "it_IT" => "Italian (Italy)", // "it_CH" => "Italian (Switzerland)", - 'it' => 'Italian', + // 'it' => 'Italian', // "ja_JP" => "Japanese (Japan)", // "ja" => "Japanese", // "kea_CV" => "Kabuverdianu (Cape Verde)", @@ -418,7 +418,7 @@ return [ // "pa" => "Punjabi", // "ro_MD" => "Romanian (Moldova)", // "ro_RO" => "Romanian (Romania)", - 'ro' => 'Romanian', + // 'ro' => 'Romanian', // "rm_CH" => "Romansh (Switzerland)", // "rm" => "Romansh", // "rof_TZ" => "Rombo (Tanzania)", diff --git a/database/migrations/2018_12_07_161238_create_projects_table.php b/database/migrations/2018_12_07_161238_create_projects_table.php new file mode 100644 index 0000000..0ed8cff --- /dev/null +++ b/database/migrations/2018_12_07_161238_create_projects_table.php @@ -0,0 +1,31 @@ +increments('id'); + $table->string('name'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('projects'); + } +} diff --git a/database/migrations/2018_12_07_162652_add_attributes_to_projects_table.php b/database/migrations/2018_12_07_162652_add_attributes_to_projects_table.php new file mode 100644 index 0000000..31af456 --- /dev/null +++ b/database/migrations/2018_12_07_162652_add_attributes_to_projects_table.php @@ -0,0 +1,34 @@ +unsignedInteger('client'); + $table->unsignedInteger('manager'); + $table->unsignedSmallInteger('status'); + $table->boolean('old')->default(false); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('projects', function (Blueprint $table) { + $table->dropColumn(['client', 'manager', 'old', 'status']); + }); + } +} diff --git a/database/migrations/2018_12_07_163246_create_tasks_table.php b/database/migrations/2018_12_07_163246_create_tasks_table.php new file mode 100644 index 0000000..6763e5a --- /dev/null +++ b/database/migrations/2018_12_07_163246_create_tasks_table.php @@ -0,0 +1,36 @@ +increments('id'); + $table->string('name'); + $table->unsignedSmallInteger('category'); + $table->unsignedSmallInteger('type'); + $table->float('price'); + $table->float('price_per_day'); + $table->unsignedInteger('project'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('tasks'); + } +} diff --git a/database/migrations/2018_12_07_163613_create_companies_table.php b/database/migrations/2018_12_07_163613_create_companies_table.php new file mode 100644 index 0000000..606b202 --- /dev/null +++ b/database/migrations/2018_12_07_163613_create_companies_table.php @@ -0,0 +1,39 @@ +increments('id'); + $table->string('name'); + $table->multiLineString('address'); + $table->string('zipcode', 16); + $table->string('city'); + $table->string('country', 2); + $table->string('vat_number', 64); + $table->unsignedSmallInteger('type'); + $table->longText('notes'); + + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('companies'); + } +} diff --git a/resources/views/vendor/backpack/base/inc/sidebar_content.blade.php b/resources/views/vendor/backpack/base/inc/sidebar_content.blade.php index 5d7f2aa..a24348e 100644 --- a/resources/views/vendor/backpack/base/inc/sidebar_content.blade.php +++ b/resources/views/vendor/backpack/base/inc/sidebar_content.blade.php @@ -1,3 +1,14 @@
  • {{ trans('backpack::base.dashboard') }}
  • -
  • {{ trans('backpack::crud.file_manager') }}
  • \ No newline at end of file +
  • {{ trans('backpack::crud.file_manager') }}
  • + +
  • + Users, Roles, Permissions + +
  • + +
  • Projects
  • \ No newline at end of file diff --git a/routes/backpack/custom.php b/routes/backpack/custom.php index 85e8c97..d59c1a8 100644 --- a/routes/backpack/custom.php +++ b/routes/backpack/custom.php @@ -11,4 +11,5 @@ Route::group([ 'middleware' => ['web', config('backpack.base.middleware_key', 'admin')], 'namespace' => 'App\Http\Controllers\Admin', ], function () { // custom admin routes -}); // this should be the absolute last line of this file + CRUD::resource('project', 'ProjectCrudController'); +}); // this should be the absolute last line of this file \ No newline at end of file -- 2.39.5