]> _ Git - extranet.git/commitdiff
wip #2413 @1
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 7 Dec 2018 16:42:01 +0000 (17:42 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 7 Dec 2018 16:42:01 +0000 (17:42 +0100)
15 files changed:
app/Http/Controllers/Admin/ProjectCrudController.php [new file with mode: 0644]
app/Http/Requests/ProjectRequest.php [new file with mode: 0644]
app/Models/BackpackUser.php
app/Models/Project.php [new file with mode: 0644]
app/User.php
composer.json
composer.lock
config/backpack/base.php
config/backpack/crud.php
database/migrations/2018_12_07_161238_create_projects_table.php [new file with mode: 0644]
database/migrations/2018_12_07_162652_add_attributes_to_projects_table.php [new file with mode: 0644]
database/migrations/2018_12_07_163246_create_tasks_table.php [new file with mode: 0644]
database/migrations/2018_12_07_163613_create_companies_table.php [new file with mode: 0644]
resources/views/vendor/backpack/base/inc/sidebar_content.blade.php
routes/backpack/custom.php

diff --git a/app/Http/Controllers/Admin/ProjectCrudController.php b/app/Http/Controllers/Admin/ProjectCrudController.php
new file mode 100644 (file)
index 0000000..f9a7e1b
--- /dev/null
@@ -0,0 +1,60 @@
+<?php
+
+namespace App\Http\Controllers\Admin;
+
+use Backpack\CRUD\app\Http\Controllers\CrudController;
+
+// VALIDATION: change the requests to match your own file names if you need form validation
+use App\Http\Requests\ProjectRequest as StoreRequest;
+use App\Http\Requests\ProjectRequest as UpdateRequest;
+
+/**
+ * Class ProjectCrudController
+ * @package App\Http\Controllers\Admin
+ * @property-read CrudPanel $crud
+ */
+class ProjectCrudController extends CrudController
+{
+    public function setup()
+    {
+        /*
+        |--------------------------------------------------------------------------
+        | CrudPanel Basic Information
+        |--------------------------------------------------------------------------
+        */
+        $this->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 (file)
index 0000000..94e0553
--- /dev/null
@@ -0,0 +1,56 @@
+<?php
+
+namespace App\Http\Requests;
+
+use App\Http\Requests\Request;
+use Illuminate\Foundation\Http\FormRequest;
+
+class ProjectRequest extends FormRequest
+{
+    /**
+     * Determine if the user is authorized to make this request.
+     *
+     * @return bool
+     */
+    public function authorize()
+    {
+        // only allow updates if the user is logged in
+        return backpack_auth()->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 [
+            //
+        ];
+    }
+}
index e27c6464bd3322c80d14bb199d8563371ea6124c..6aee419b7ce48e6f39f55ac8127c02bde67fa7f1 100644 (file)
@@ -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 (file)
index 0000000..5a3c629
--- /dev/null
@@ -0,0 +1,55 @@
+<?php
+
+namespace App\Models;
+
+use Illuminate\Database\Eloquent\Model;
+use Backpack\CRUD\CrudTrait;
+
+class Project extends Model
+{
+    use CrudTrait;
+
+    /*
+    |--------------------------------------------------------------------------
+    | GLOBAL VARIABLES
+    |--------------------------------------------------------------------------
+    */
+
+    protected $table = 'projects';
+    // protected $primaryKey = 'id';
+    // public $timestamps = false;
+    // protected $guarded = ['id'];
+    protected $fillable = ['name'];
+    // protected $hidden = [];
+    // protected $dates = [];
+
+    /*
+    |--------------------------------------------------------------------------
+    | FUNCTIONS
+    |--------------------------------------------------------------------------
+    */
+
+    /*
+    |--------------------------------------------------------------------------
+    | RELATIONS
+    |--------------------------------------------------------------------------
+    */
+
+    /*
+    |--------------------------------------------------------------------------
+    | SCOPES
+    |--------------------------------------------------------------------------
+    */
+
+    /*
+    |--------------------------------------------------------------------------
+    | ACCESORS
+    |--------------------------------------------------------------------------
+    */
+
+    /*
+    |--------------------------------------------------------------------------
+    | MUTATORS
+    |--------------------------------------------------------------------------
+    */
+}
index fbc0e589f25849c0def4076afdc3ee6ae9df0f01..f5cb45ebf758a2994660055e42d7c02b33e2846e 100644 (file)
@@ -2,6 +2,8 @@
 
 namespace App;
 
+use Backpack\CRUD\CrudTrait;
+use Spatie\Permission\Traits\HasRoles;
 use Illuminate\Notifications\Notifiable;
 use Illuminate\Contracts\Auth\MustVerifyEmail;
 use Illuminate\Foundation\Auth\User as Authenticatable;
@@ -9,6 +11,8 @@ use Illuminate\Foundation\Auth\User as Authenticatable;
 class User extends Authenticatable
 {
     use Notifiable;
+    use CrudTrait;
+    use HasRoles;
 
     /**
      * The attributes that are mass assignable.
@@ -16,7 +20,7 @@ class User extends Authenticatable
      * @var array
      */
     protected $fillable = [
-        'name', 'email', 'password',
+        'name', 'email', 'password'
     ];
 
     /**
index 95d568f0d813b9e5f0297b5e2536c0182b1ad7de..8725192d916f336b16d265e66d5d644228820775 100644 (file)
@@ -16,6 +16,7 @@
         "backpack/permissionmanager": "^3.12",
         "backpack/settings": "^2.1",
         "barryvdh/laravel-elfinder": "^0.4.1",
+        "doctrine/dbal": "^2.9",
         "fideloper/proxy": "^4.0",
         "laravel/framework": "5.7.*",
         "laravel/tinker": "^1.0"
index 712206517977304e2e47144f465aa34fe8de29f7..97a9c4818bbed7f9f4f3437e111a95cd619df6e8 100644 (file)
@@ -4,7 +4,7 @@
         "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
         "This file is @generated automatically"
     ],
-    "content-hash": "73b51212b873899b1e37a1be6c3ea7c5",
+    "content-hash": "04be8215e2d7d144f71d35d8f473a76f",
     "packages": [
         {
             "name": "almasaeed2010/adminlte",
index 0ece3eeddf6a0779fd7eb4057f5e21bbbd1399c8..bc6e437d16bf06ebc6f82884f58450d8141a42ff 100644 (file)
@@ -15,25 +15,25 @@ return [
     'project_name' => 'Backpack',
 
     // Menu logos
-    'logo_lg'   => '<b>Back</b>pack',
-    'logo_mini' => '<b>B</b>p',
+    'logo_lg' => '<b>Cubedesigners</b>',
+    'logo_mini' => '<b>C</b>D',
 
     // 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.
index dc47c25edd6c64be53835cc208f4e484fd0cd5cf..ccc4408f0c68dd1ebce3abbb6596bc7210ad9068 100644 (file)
@@ -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 (file)
index 0000000..0ed8cff
--- /dev/null
@@ -0,0 +1,31 @@
+<?php
+
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class CreateProjectsTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::create('projects', function (Blueprint $table) {
+            $table->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 (file)
index 0000000..31af456
--- /dev/null
@@ -0,0 +1,34 @@
+<?php
+
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class AddAttributesToProjectsTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::table('projects', function (Blueprint $table) {
+            $table->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 (file)
index 0000000..6763e5a
--- /dev/null
@@ -0,0 +1,36 @@
+<?php
+
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class CreateTasksTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::create('tasks', function (Blueprint $table) {
+            $table->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 (file)
index 0000000..606b202
--- /dev/null
@@ -0,0 +1,39 @@
+<?php
+
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class CreateCompaniesTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::create('companies', function (Blueprint $table) {
+            $table->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');
+    }
+}
index 5d7f2aa81a0d309a313166d9bc17db3c65ba4df4..a24348ef680029af5a4bbd9ca64c6b2ffafb8817 100644 (file)
@@ -1,3 +1,14 @@
 <!-- This file is used to store sidebar items, starting with Backpack\Base 0.9.0 -->
 <li><a href="{{ backpack_url('dashboard') }}"><i class="fa fa-dashboard"></i> <span>{{ trans('backpack::base.dashboard') }}</span></a></li>
-<li><a href="{{ backpack_url('elfinder') }}"><i class="fa fa-files-o"></i> <span>{{ trans('backpack::crud.file_manager') }}</span></a></li>
\ No newline at end of file
+<li><a href="{{ backpack_url('elfinder') }}"><i class="fa fa-files-o"></i> <span>{{ trans('backpack::crud.file_manager') }}</span></a></li>
+<!-- Users, Roles Permissions -->
+<li class="treeview">
+    <a href="#"><i class="fa fa-group"></i> <span>Users, Roles, Permissions</span> <i class="fa fa-angle-left pull-right"></i></a>
+    <ul class="treeview-menu">
+        <li><a href="{{ backpack_url('user') }}"><i class="fa fa-user"></i> <span>Users</span></a></li>
+        <li><a href="{{ backpack_url('role') }}"><i class="fa fa-group"></i> <span>Roles</span></a></li>
+        <li><a href="{{ backpack_url('permission') }}"><i class="fa fa-key"></i> <span>Permissions</span></a></li>
+    </ul>
+</li>
+
+<li><a href='{{ backpack_url('project') }}'><i class='fa fa-rocket'></i> <span>Projects</span></a></li>
\ No newline at end of file
index 85e8c9791f9fb9abdddc235199cc450e82837f2c..d59c1a8b9a030ab17f42525fb9a6669d4824cdaf 100644 (file)
@@ -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