]> _ Git - extranet.git/commitdiff
wip #3546 @0.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 3 Apr 2020 16:56:53 +0000 (18:56 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 3 Apr 2020 16:56:53 +0000 (18:56 +0200)
app/Models/Company.php
app/Models/User.php
composer.lock

index 653d0f4403aa756110ab151752a887556cca0f08..15a94b904182de5b6563c59cbe42c817f3060b47 100644 (file)
@@ -19,21 +19,25 @@ class Company extends CubistMagicAbstractModel
         $this->addField(['name' => 'name',
             'label' => 'Company name',
             'type' => 'Text',
-            'column' => true]);
+            'column' => true,
+            'tab' => 'Details']);
 
         $this->addField(['name' => 'address',
             'type' => 'BunchOfFields',
             'bunch' => Address::class,
-            'label' => 'Address']);
+            'label' => 'Address',
+            'tab' => 'Addresses']);
 
         $this->addField(['name' => 'billing_address',
             'type' => 'BunchOfFields',
             'bunch' => Address::class,
-            'label' => 'Address de facturation']);
+            'label' => 'Billing address',
+            'tab' => 'Addresses']);
 
         $this->addField(['name' => 'vat_number',
             'type' => 'VATNumber',
-            'label' => 'VAT number']);
+            'label' => 'VAT number',
+            'tab' => 'Details']);
 
         $this->addField(['name' => 'type',
                 'type' => 'SelectFromArray',
@@ -46,16 +50,21 @@ class Company extends CubistMagicAbstractModel
                     4 => 'Agency',
                     5 => 'Big company',
                     6 => 'Government / Public institution'
-                ]
+                ],
+                'tab' => 'Details'
             ]
         );
 
         $this->addField(['name' => 'admin',
-            'type' => 'Integer',
-            'label' => 'Administrator']);
+            'type' => 'SelectFromModel',
+            'optionsmodel' => User::class,
+            'attribute' => 'nameWithCompany',
+            'label' => 'Administrator',
+            'tab' => 'Details']);
 
         $this->addField(['name' => 'website',
             'type' => 'URL',
-            'label' => 'Website']);
+            'label' => 'Website',
+            'tab' => 'Details']);
     }
 }
index a77b969a613cbc5e84d7f43b92a06e805cd97915..396e3c3af412d958cc7c6c4d8a0eda542adef92c 100644 (file)
@@ -11,46 +11,75 @@ class User extends CubistMagicAuthenticatable
     protected $_options = ['name' => 'users',
         'singular' => 'user',
         'plural' => 'users'];
+    protected static $_companyNames = null;
 
     public function setFields()
     {
         parent::setFields();
 
-        $this->addField(['name' => 'enabled',
-            'label' => 'Enabled',
-            'type' => 'checkbox']);
-
         $this->addField(['name' => 'firstname',
             'label' => 'Firstname',
             'type' => 'Text',
-            'column' => true]);
+            'column' => true,
+            'tab' => 'Contact']);
 
         $this->addField(['name' => 'lastname',
             'label' => 'Lastname',
             'type' => 'Text',
-            'column' => true]);
+            'column' => true,
+            'tab' => 'Contact']);
 
         $this->addField(['name' => 'company',
             'label' => 'Company',
             'type' => 'SelectFromModel',
-            'optionsmodel' => Company::class
+            'optionsmodel' => Company::class,
+            'tab' => 'Contact'
         ]);
 
         $this->addField(['name' => 'address',
             'type' => 'BunchOfFields',
             'bunch' => Address::class,
-            'label' => 'Address']);
+            'label' => 'Address',
+            'tab' => 'Contact']);
 
         $this->addField(['name' => 'phone',
             'label' => 'Phone',
-            'type' => 'Phone']);
+            'type' => 'Phone',
+            'tab' => 'Contact']);
 
         $this->addField(['name' => 'mobile',
             'label' => 'Mobile',
-            'type' => 'Phone']);
+            'type' => 'Phone',
+            'tab' => 'Contact']);
 
         $this->addField(['name' => 'locale',
             'label' => 'Locale',
-            'type' => 'Locale']);
+            'type' => 'Locale',
+            'tab' => 'Settings']);
+    }
+
+    public function getNameWithCompanyAttribute()
+    {
+        $name = trim($this->firstname . ' ' . $this->lastname);
+        if ($name === '') {
+            return $this->companyName;
+        }
+        return $name . ' (' . $this->companyName . ')';
+    }
+
+    public function getCompanyNameAttribute()
+    {
+        return self::_getCompanyNames($this->company);
+    }
+
+    protected static function _getCompanyNames($id = null)
+    {
+        if (null === self::$_companyNames) {
+            self::$_companyNames = Company::all()->pluck('name', 'id')->toArray();
+        }
+        if (null === $id) {
+            return self::$_companyNames;
+        }
+        return self::$_companyNames[$id];
     }
 }
index 7351f841de215f115fbe04fc9ab776f42ce8ce6b..1631e80bcdf90838082e11604723e51c6b766bfa 100644 (file)
             "source": {
                 "type": "git",
                 "url": "git://git.cubedesigners.com/cubist_cms-back.git",
-                "reference": "e3313e370bc3e4ee36cc0c36cffda94efbdc93ca"
+                "reference": "43ed7ae72e3b0901b64417face1a66fd76690b09"
             },
             "dist": {
                 "type": "tar",
-                "url": "https://composer.cubedesigners.com/dist/cubist/cms-back/cubist-cms-back-dev-master-fa7dbb.tar",
-                "reference": "e3313e370bc3e4ee36cc0c36cffda94efbdc93ca",
-                "shasum": "bcc79dd5117133e1deae4cac2b5d5f6e00b30a0e"
+                "url": "https://composer.cubedesigners.com/dist/cubist/cms-back/cubist-cms-back-dev-master-712a09.tar",
+                "reference": "43ed7ae72e3b0901b64417face1a66fd76690b09",
+                "shasum": "d9aab76074e6b1fa3c2a60670edb6ef3843bd70e"
             },
             "require": {
                 "backpack/backupmanager": "^2.0",
                 "ext-json": "*",
                 "ext-libxml": "*",
                 "fideloper/proxy": "^4.2",
+                "genealabs/laravel-model-caching": "^0.8.0",
                 "graham-campbell/markdown": "^12.0",
                 "lavary/laravel-menu": "^1.7",
                 "league/commonmark-ext-autolink": "^1.0",
                 }
             ],
             "description": "Cubist Backpack extension",
-            "time": "2020-04-01T10:13:05+00:00"
+            "time": "2020-04-03T15:10:31+00:00"
         },
         {
             "name": "cubist/cms-front",
             "source": {
                 "type": "git",
                 "url": "git://git.cubedesigners.com/cubist_cms-front.git",
-                "reference": "71072a67c5eb03adb8d33d543597eba75bb895b5"
+                "reference": "74456a64d1aba9effdc8b123840bdff6635eb965"
             },
             "dist": {
                 "type": "tar",
-                "url": "https://composer.cubedesigners.com/dist/cubist/cms-front/cubist-cms-front-dev-master-ad1338.tar",
-                "reference": "71072a67c5eb03adb8d33d543597eba75bb895b5",
-                "shasum": "e3631bb65171b2fc242dfcd8c6bc3ce0a8b27cbe"
+                "url": "https://composer.cubedesigners.com/dist/cubist/cms-front/cubist-cms-front-dev-master-6064bf.tar",
+                "reference": "74456a64d1aba9effdc8b123840bdff6635eb965",
+                "shasum": "91e4890b33906f2693d25cd459f04b65ab6b4d98"
             },
             "require": {
                 "cubist/gtag": "dev-master",
                 }
             ],
             "description": "Cubist CMS Front",
-            "time": "2020-03-11T14:30:33+00:00"
+            "time": "2020-04-02T15:40:28+00:00"
         },
         {
             "name": "cubist/gtag",
             ],
             "time": "2019-12-12T13:22:17+00:00"
         },
+        {
+            "name": "genealabs/laravel-model-caching",
+            "version": "0.8.0",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/GeneaLabs/laravel-model-caching.git",
+                "reference": "5b0bf609f2a758c36d3be67ca4d3413ca9f0bd79"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/GeneaLabs/laravel-model-caching/zipball/5b0bf609f2a758c36d3be67ca4d3413ca9f0bd79",
+                "reference": "5b0bf609f2a758c36d3be67ca4d3413ca9f0bd79",
+                "shasum": ""
+            },
+            "require": {
+                "genealabs/laravel-pivot-events": "^0.3.0",
+                "illuminate/cache": "^7.0",
+                "illuminate/config": "^7.0",
+                "illuminate/console": "^7.0",
+                "illuminate/container": "^7.0",
+                "illuminate/database": "^7.0",
+                "illuminate/http": "^7.0",
+                "illuminate/support": "^7.0",
+                "php": ">=7.2.5",
+                "predis/predis": "^1.1"
+            },
+            "require-dev": {
+                "fzaninotto/faker": "^1.9.1",
+                "orchestra/testbench": "^5.0",
+                "orchestra/testbench-browser-kit": "^5.0",
+                "php-coveralls/php-coveralls": "^2.2",
+                "phpmd/phpmd": "^2.7",
+                "phpunit/phpunit": "^8.0",
+                "sebastian/phpcpd": "^5.0",
+                "squizlabs/php_codesniffer": "^3.4",
+                "symfony/thanks": "^1.2"
+            },
+            "type": "library",
+            "extra": {
+                "laravel": {
+                    "providers": [
+                        "GeneaLabs\\LaravelModelCaching\\Providers\\Service"
+                    ]
+                }
+            },
+            "autoload": {
+                "psr-4": {
+                    "GeneaLabs\\LaravelModelCaching\\": "src/"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "Mike Bronner",
+                    "email": "hello@genealabs.com"
+                }
+            ],
+            "description": "Automatic caching for Eloquent models.",
+            "time": "2020-02-29T19:22:25+00:00"
+        },
+        {
+            "name": "genealabs/laravel-pivot-events",
+            "version": "0.3.0",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/GeneaLabs/laravel-pivot-events.git",
+                "reference": "7f35d5af019558474c0afc437bfa49ee161b658b"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/GeneaLabs/laravel-pivot-events/zipball/7f35d5af019558474c0afc437bfa49ee161b658b",
+                "reference": "7f35d5af019558474c0afc437bfa49ee161b658b",
+                "shasum": ""
+            },
+            "require": {
+                "illuminate/database": "^7.0",
+                "illuminate/support": "^7.0"
+            },
+            "require-dev": {
+                "orchestra/testbench": "^5.0",
+                "symfony/thanks": "^1.0"
+            },
+            "type": "library",
+            "autoload": {
+                "psr-4": {
+                    "GeneaLabs\\LaravelPivotEvents\\": "src"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "Mike Bronner",
+                    "email": "hello@genealabs.com",
+                    "homepage": "https://genealabs.com",
+                    "role": "Developer"
+                }
+            ],
+            "description": "This package introduces new eloquent events for sync(), attach(), detach() or updateExistingPivot() methods on BelongsToMany relation.",
+            "homepage": "https://github.com/fico7489/laravel-pivot",
+            "keywords": [
+                "eloquent events",
+                "eloquent extra events",
+                "laravel BelongsToMany events",
+                "laravel pivot events",
+                "laravel sync events"
+            ],
+            "time": "2020-02-29T18:56:56+00:00"
+        },
         {
             "name": "graham-campbell/markdown",
             "version": "v12.0.0",
         },
         {
             "name": "maennchen/zipstream-php",
-            "version": "1.2.0",
+            "version": "2.0.0",
             "source": {
                 "type": "git",
                 "url": "https://github.com/maennchen/ZipStream-PHP.git",
-                "reference": "6373eefe0b3274d7b702d81f2c99aa977ff97dc2"
+                "reference": "9ceee828f9620b2e5c075e551ec7ed8a7035ac95"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/maennchen/ZipStream-PHP/zipball/6373eefe0b3274d7b702d81f2c99aa977ff97dc2",
-                "reference": "6373eefe0b3274d7b702d81f2c99aa977ff97dc2",
+                "url": "https://api.github.com/repos/maennchen/ZipStream-PHP/zipball/9ceee828f9620b2e5c075e551ec7ed8a7035ac95",
+                "reference": "9ceee828f9620b2e5c075e551ec7ed8a7035ac95",
                 "shasum": ""
             },
             "require": {
                     "name": "Paul Duncan",
                     "email": "pabs@pablotron.org"
                 },
-                {
-                    "name": "Jesse Donat",
-                    "email": "donatj@gmail.com"
-                },
                 {
                     "name": "Jonatan Männchen",
                     "email": "jonatan@maennchen.ch"
                 },
+                {
+                    "name": "Jesse Donat",
+                    "email": "donatj@gmail.com"
+                },
                 {
                     "name": "András Kolesár",
                     "email": "kolesar@kolesar.hu"
                 "stream",
                 "zip"
             ],
-            "time": "2019-07-17T11:01:58+00:00"
+            "time": "2020-02-23T01:48:39+00:00"
         },
         {
             "name": "maximebf/debugbar",
         },
         {
             "name": "phpunit/phpunit",
-            "version": "9.0.2",
+            "version": "9.1.1",
             "source": {
                 "type": "git",
                 "url": "https://github.com/sebastianbergmann/phpunit.git",
-                "reference": "c0ecbfb898ab8b24d8a59a23520f7b2a73e27b5b"
+                "reference": "848f6521c906500e66229668768576d35de0227e"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/c0ecbfb898ab8b24d8a59a23520f7b2a73e27b5b",
-                "reference": "c0ecbfb898ab8b24d8a59a23520f7b2a73e27b5b",
+                "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/848f6521c906500e66229668768576d35de0227e",
+                "reference": "848f6521c906500e66229668768576d35de0227e",
                 "shasum": ""
             },
             "require": {
                 "phpunit/php-invoker": "^3.0",
                 "phpunit/php-text-template": "^2.0",
                 "phpunit/php-timer": "^3.0",
+                "sebastian/code-unit": "^1.0",
                 "sebastian/comparator": "^4.0",
                 "sebastian/diff": "^4.0",
                 "sebastian/environment": "^5.0.1",
             "type": "library",
             "extra": {
                 "branch-alias": {
-                    "dev-master": "9.0-dev"
+                    "dev-master": "9.1-dev"
                 }
             },
             "autoload": {
                 "testing",
                 "xunit"
             ],
-            "time": "2020-03-31T08:57:51+00:00"
+            "time": "2020-04-03T14:40:04+00:00"
         },
         {
             "name": "predis/predis",
             ],
             "time": "2019-01-07T21:25:54+00:00"
         },
+        {
+            "name": "sebastian/code-unit",
+            "version": "1.0.0",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/sebastianbergmann/code-unit.git",
+                "reference": "8d8f09bd47c75159921e6e84fdef146343962866"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/sebastianbergmann/code-unit/zipball/8d8f09bd47c75159921e6e84fdef146343962866",
+                "reference": "8d8f09bd47c75159921e6e84fdef146343962866",
+                "shasum": ""
+            },
+            "require": {
+                "php": "^7.3"
+            },
+            "require-dev": {
+                "phpunit/phpunit": "^9.0"
+            },
+            "type": "library",
+            "extra": {
+                "branch-alias": {
+                    "dev-master": "1.0-dev"
+                }
+            },
+            "autoload": {
+                "classmap": [
+                    "src/"
+                ]
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "BSD-3-Clause"
+            ],
+            "authors": [
+                {
+                    "name": "Sebastian Bergmann",
+                    "email": "sebastian@phpunit.de",
+                    "role": "lead"
+                }
+            ],
+            "description": "Collection of value objects that represent the PHP code units",
+            "homepage": "https://github.com/sebastianbergmann/code-unit",
+            "time": "2020-03-30T11:59:20+00:00"
+        },
         {
             "name": "sebastian/code-unit-reverse-lookup",
             "version": "2.0.0",
         },
         {
             "name": "spatie/laravel-medialibrary",
-            "version": "8.0.7",
+            "version": "8.0.8",
             "source": {
                 "type": "git",
                 "url": "https://github.com/spatie/laravel-medialibrary.git",
-                "reference": "d14dce6b170ee8345b286665848c50c91d54be4d"
+                "reference": "c5adacdca1db44fff93f6699887191776546a9f6"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/spatie/laravel-medialibrary/zipball/d14dce6b170ee8345b286665848c50c91d54be4d",
-                "reference": "d14dce6b170ee8345b286665848c50c91d54be4d",
+                "url": "https://api.github.com/repos/spatie/laravel-medialibrary/zipball/c5adacdca1db44fff93f6699887191776546a9f6",
+                "reference": "c5adacdca1db44fff93f6699887191776546a9f6",
                 "shasum": ""
             },
             "require": {
                 "illuminate/pipeline": "^6.18|^7.0",
                 "illuminate/support": "^6.18|^7.0",
                 "league/flysystem": "^1.0.64",
-                "maennchen/zipstream-php": "^1.0",
+                "maennchen/zipstream-php": "^1.0|^2.0",
                 "php": "^7.4",
                 "spatie/image": "^1.4.0",
                 "spatie/temporary-directory": "^1.1",
                 "media",
                 "spatie"
             ],
-            "time": "2020-03-30T09:11:38+00:00"
+            "time": "2020-04-02T09:47:42+00:00"
         },
         {
             "name": "spatie/laravel-permission",