Bläddra i källkod

refactor and prevent auto creation of company for Socialite User

3.x
wallo 2 år sedan
förälder
incheckning
2d8346f605

+ 2
- 0
.gitignore Visa fil

@@ -17,3 +17,5 @@ yarn-error.log
17 17
 /.fleet
18 18
 /.idea
19 19
 /.vscode
20
+/public/css/
21
+/public/js/

+ 1
- 1
app/Actions/FilamentCompanies/CreateUserFromProvider.php Visa fil

@@ -46,7 +46,7 @@ class CreateUserFromProvider implements CreatesUserFromProvider
46 46
                     $this->createsConnectedAccounts->create($user, $provider, $providerUser)
47 47
                 );
48 48
 
49
-                $this->createCompany($user);
49
+                // $this->createCompany($user); // Commented out to prevent creating a company for a Socialite user
50 50
             });
51 51
         });
52 52
     }

+ 27
- 0
app/Events/CompanyGenerated.php Visa fil

@@ -0,0 +1,27 @@
1
+<?php
2
+
3
+namespace App\Events;
4
+
5
+use App\Models\Company;
6
+use App\Models\User;
7
+use Illuminate\Foundation\Events\Dispatchable;
8
+use Illuminate\Queue\SerializesModels;
9
+
10
+class CompanyGenerated
11
+{
12
+    use Dispatchable, SerializesModels;
13
+
14
+    public User $user;
15
+    public Company $company;
16
+    public string $country;
17
+
18
+    /**
19
+     * Create a new event instance.
20
+     */
21
+    public function __construct(User $user, Company $company, string $country)
22
+    {
23
+        $this->user = $user;
24
+        $this->company = $company;
25
+        $this->country = $country;
26
+    }
27
+}

+ 3
- 0
app/Filament/Company/Pages/CreateCompany.php Visa fil

@@ -3,6 +3,7 @@
3 3
 namespace App\Filament\Company\Pages;
4 4
 
5 5
 use App\Enums\EntityType;
6
+use App\Events\CompanyGenerated;
6 7
 use App\Models\Setting\CompanyProfile;
7 8
 use Filament\Forms\Components\Select;
8 9
 use Filament\Forms\Components\TextInput;
@@ -70,6 +71,8 @@ class CreateCompany extends FilamentCreateCompany
70 71
 
71 72
         $name = $data['name'];
72 73
 
74
+        CompanyGenerated::dispatch($user, $company, $data['profile']['country']);
75
+
73 76
         $this->companyCreated($name);
74 77
 
75 78
         return $company;

+ 6
- 5
app/Listeners/CreateCompanyDefaults.php Visa fil

@@ -2,9 +2,8 @@
2 2
 
3 3
 namespace App\Listeners;
4 4
 
5
-use App\Models\Company;
5
+use App\Events\CompanyGenerated;
6 6
 use App\Services\CompanyDefaultService;
7
-use Wallo\FilamentCompanies\Events\CompanyCreated;
8 7
 
9 8
 class CreateCompanyDefaults
10 9
 {
@@ -19,14 +18,16 @@ class CreateCompanyDefaults
19 18
     /**
20 19
      * Handle the event.
21 20
      */
22
-    public function handle(CompanyCreated $event): void
21
+    public function handle(CompanyGenerated $event): void
23 22
     {
24
-        /** @var Company $company */
25 23
         $company = $event->company;
24
+        $country = $event->country;
25
+
26
+        $currencyCode = $country ? country($country)->getCurrency()['iso_4217_code'] : 'USD';
26 27
 
27 28
         $user = $company->owner;
28 29
 
29 30
         $companyDefaultService = new CompanyDefaultService();
30
-        $companyDefaultService->createCompanyDefaults($company, $user);
31
+        $companyDefaultService->createCompanyDefaults($company, $user, $currencyCode);
31 32
     }
32 33
 }

+ 2
- 2
app/Providers/EventServiceProvider.php Visa fil

@@ -4,6 +4,7 @@ namespace App\Providers;
4 4
 
5 5
 use App\Events\CompanyDefaultEvent;
6 6
 use App\Events\CompanyDefaultUpdated;
7
+use App\Events\CompanyGenerated;
7 8
 use App\Listeners\ConfigureCompanyDefault;
8 9
 use App\Listeners\CreateCompanyDefaults;
9 10
 use App\Listeners\SyncAssociatedModels;
@@ -12,7 +13,6 @@ use Filament\Events\TenantSet;
12 13
 use Illuminate\Auth\Events\Registered;
13 14
 use Illuminate\Auth\Listeners\SendEmailVerificationNotification;
14 15
 use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
15
-use Wallo\FilamentCompanies\Events\CompanyCreated;
16 16
 
17 17
 class EventServiceProvider extends ServiceProvider
18 18
 {
@@ -34,7 +34,7 @@ class EventServiceProvider extends ServiceProvider
34 34
         TenantSet::class => [
35 35
             ConfigureCompanyDefault::class,
36 36
         ],
37
-        CompanyCreated::class => [
37
+        CompanyGenerated::class => [
38 38
             CreateCompanyDefaults::class,
39 39
         ],
40 40
     ];

+ 6
- 7
app/Services/CompanyDefaultService.php Visa fil

@@ -12,16 +12,15 @@ use App\Models\Setting\Discount;
12 12
 use App\Models\Setting\DocumentDefault;
13 13
 use App\Models\Setting\Tax;
14 14
 use App\Models\User;
15
-use Illuminate\Support\Facades\Auth;
16 15
 use Illuminate\Support\Facades\DB;
17 16
 
18 17
 class CompanyDefaultService
19 18
 {
20
-    public function createCompanyDefaults(Company $company, User $user): void
19
+    public function createCompanyDefaults(Company $company, User $user, string $currencyCode): void
21 20
     {
22
-        DB::transaction(function () use ($company, $user) {
21
+        DB::transaction(function () use ($company, $user, $currencyCode) {
23 22
             $categories = $this->createCategories($company, $user);
24
-            $currency = $this->createCurrency($company, $user);
23
+            $currency = $this->createCurrency($company, $user, $currencyCode);
25 24
             $salesTax = $this->createSalesTax($company, $user);
26 25
             $purchaseTax = $this->createPurchaseTax($company, $user);
27 26
             $salesDiscount = $this->createSalesDiscount($company, $user);
@@ -42,7 +41,7 @@ class CompanyDefaultService
42 41
                 'updated_by' => $user->id,
43 42
             ];
44 43
 
45
-            CompanyDefault::updateOrInsert(['company_id' => $company->id], $companyDefaults);
44
+            CompanyDefault::firstOrCreate(['company_id' => $company->id], $companyDefaults);
46 45
         }, 5);
47 46
     }
48 47
 
@@ -93,9 +92,9 @@ class CompanyDefaultService
93 92
         ];
94 93
     }
95 94
 
96
-    private function createCurrency(Company $company, User $user)
95
+    private function createCurrency(Company $company, User $user, string $currencyCode)
97 96
     {
98
-        return Currency::factory()->create([
97
+        return Currency::factory()->forCurrency($currencyCode)->create([
99 98
             'company_id' => $company->id,
100 99
             'created_by' => $user->id,
101 100
             'updated_by' => $user->id,

+ 2
- 2
app/Traits/SyncsWithCompanyDefaults.php Visa fil

@@ -8,11 +8,11 @@ trait SyncsWithCompanyDefaults
8 8
 {
9 9
     public static function bootSyncsWithCompanyDefaults(): void
10 10
     {
11
-        static::creating(static function ($model) {
11
+        static::created(static function ($model) {
12 12
             event(new CompanyDefaultEvent($model));
13 13
         });
14 14
 
15
-        static::updating(static function ($model) {
15
+        static::updated(static function ($model) {
16 16
             event(new CompanyDefaultEvent($model));
17 17
         });
18 18
     }

+ 58
- 54
composer.lock Visa fil

@@ -1234,16 +1234,16 @@
1234 1234
         },
1235 1235
         {
1236 1236
             "name": "filament/actions",
1237
-            "version": "v3.0.52",
1237
+            "version": "v3.0.53",
1238 1238
             "source": {
1239 1239
                 "type": "git",
1240 1240
                 "url": "https://github.com/filamentphp/actions.git",
1241
-                "reference": "1d8b7e393f9a783d674768e3b9f54e76a357b2e6"
1241
+                "reference": "ab3512faf3a0e35e3b863b78ac4c67eede8f654f"
1242 1242
             },
1243 1243
             "dist": {
1244 1244
                 "type": "zip",
1245
-                "url": "https://api.github.com/repos/filamentphp/actions/zipball/1d8b7e393f9a783d674768e3b9f54e76a357b2e6",
1246
-                "reference": "1d8b7e393f9a783d674768e3b9f54e76a357b2e6",
1245
+                "url": "https://api.github.com/repos/filamentphp/actions/zipball/ab3512faf3a0e35e3b863b78ac4c67eede8f654f",
1246
+                "reference": "ab3512faf3a0e35e3b863b78ac4c67eede8f654f",
1247 1247
                 "shasum": ""
1248 1248
             },
1249 1249
             "require": {
@@ -1280,20 +1280,20 @@
1280 1280
                 "issues": "https://github.com/filamentphp/filament/issues",
1281 1281
                 "source": "https://github.com/filamentphp/filament"
1282 1282
             },
1283
-            "time": "2023-09-11T12:30:47+00:00"
1283
+            "time": "2023-09-18T10:30:31+00:00"
1284 1284
         },
1285 1285
         {
1286 1286
             "name": "filament/filament",
1287
-            "version": "v3.0.52",
1287
+            "version": "v3.0.53",
1288 1288
             "source": {
1289 1289
                 "type": "git",
1290 1290
                 "url": "https://github.com/filamentphp/panels.git",
1291
-                "reference": "6a9e8b82ab7e5e639621f53c8982d2bef1322566"
1291
+                "reference": "0fba2ff378d28984e9d0107600a8dff5e2425d8b"
1292 1292
             },
1293 1293
             "dist": {
1294 1294
                 "type": "zip",
1295
-                "url": "https://api.github.com/repos/filamentphp/panels/zipball/6a9e8b82ab7e5e639621f53c8982d2bef1322566",
1296
-                "reference": "6a9e8b82ab7e5e639621f53c8982d2bef1322566",
1295
+                "url": "https://api.github.com/repos/filamentphp/panels/zipball/0fba2ff378d28984e9d0107600a8dff5e2425d8b",
1296
+                "reference": "0fba2ff378d28984e9d0107600a8dff5e2425d8b",
1297 1297
                 "shasum": ""
1298 1298
             },
1299 1299
             "require": {
@@ -1345,20 +1345,20 @@
1345 1345
                 "issues": "https://github.com/filamentphp/filament/issues",
1346 1346
                 "source": "https://github.com/filamentphp/filament"
1347 1347
             },
1348
-            "time": "2023-09-16T10:25:57+00:00"
1348
+            "time": "2023-09-18T10:30:37+00:00"
1349 1349
         },
1350 1350
         {
1351 1351
             "name": "filament/forms",
1352
-            "version": "v3.0.52",
1352
+            "version": "v3.0.53",
1353 1353
             "source": {
1354 1354
                 "type": "git",
1355 1355
                 "url": "https://github.com/filamentphp/forms.git",
1356
-                "reference": "b99b4dfd957df9cebafaee6d95f1de5132221353"
1356
+                "reference": "9b7dc160634649c411fdbeeee4058bd524b30088"
1357 1357
             },
1358 1358
             "dist": {
1359 1359
                 "type": "zip",
1360
-                "url": "https://api.github.com/repos/filamentphp/forms/zipball/b99b4dfd957df9cebafaee6d95f1de5132221353",
1361
-                "reference": "b99b4dfd957df9cebafaee6d95f1de5132221353",
1360
+                "url": "https://api.github.com/repos/filamentphp/forms/zipball/9b7dc160634649c411fdbeeee4058bd524b30088",
1361
+                "reference": "9b7dc160634649c411fdbeeee4058bd524b30088",
1362 1362
                 "shasum": ""
1363 1363
             },
1364 1364
             "require": {
@@ -1401,20 +1401,20 @@
1401 1401
                 "issues": "https://github.com/filamentphp/filament/issues",
1402 1402
                 "source": "https://github.com/filamentphp/filament"
1403 1403
             },
1404
-            "time": "2023-09-16T10:25:51+00:00"
1404
+            "time": "2023-09-18T10:30:39+00:00"
1405 1405
         },
1406 1406
         {
1407 1407
             "name": "filament/infolists",
1408
-            "version": "v3.0.52",
1408
+            "version": "v3.0.53",
1409 1409
             "source": {
1410 1410
                 "type": "git",
1411 1411
                 "url": "https://github.com/filamentphp/infolists.git",
1412
-                "reference": "db3f36f1fa243213996262f1afdce76aba497f7b"
1412
+                "reference": "148b6f2bc0c27c224dc0fd811882dd080eb50a6e"
1413 1413
             },
1414 1414
             "dist": {
1415 1415
                 "type": "zip",
1416
-                "url": "https://api.github.com/repos/filamentphp/infolists/zipball/db3f36f1fa243213996262f1afdce76aba497f7b",
1417
-                "reference": "db3f36f1fa243213996262f1afdce76aba497f7b",
1416
+                "url": "https://api.github.com/repos/filamentphp/infolists/zipball/148b6f2bc0c27c224dc0fd811882dd080eb50a6e",
1417
+                "reference": "148b6f2bc0c27c224dc0fd811882dd080eb50a6e",
1418 1418
                 "shasum": ""
1419 1419
             },
1420 1420
             "require": {
@@ -1452,20 +1452,20 @@
1452 1452
                 "issues": "https://github.com/filamentphp/filament/issues",
1453 1453
                 "source": "https://github.com/filamentphp/filament"
1454 1454
             },
1455
-            "time": "2023-09-11T12:30:48+00:00"
1455
+            "time": "2023-09-18T10:30:36+00:00"
1456 1456
         },
1457 1457
         {
1458 1458
             "name": "filament/notifications",
1459
-            "version": "v3.0.52",
1459
+            "version": "v3.0.53",
1460 1460
             "source": {
1461 1461
                 "type": "git",
1462 1462
                 "url": "https://github.com/filamentphp/notifications.git",
1463
-                "reference": "b675b8310bb4984334bc5b01b3b770a6b0d56a83"
1463
+                "reference": "288355f86d973a69bd483836b9a38d000b8b2ad2"
1464 1464
             },
1465 1465
             "dist": {
1466 1466
                 "type": "zip",
1467
-                "url": "https://api.github.com/repos/filamentphp/notifications/zipball/b675b8310bb4984334bc5b01b3b770a6b0d56a83",
1468
-                "reference": "b675b8310bb4984334bc5b01b3b770a6b0d56a83",
1467
+                "url": "https://api.github.com/repos/filamentphp/notifications/zipball/288355f86d973a69bd483836b9a38d000b8b2ad2",
1468
+                "reference": "288355f86d973a69bd483836b9a38d000b8b2ad2",
1469 1469
                 "shasum": ""
1470 1470
             },
1471 1471
             "require": {
@@ -1504,11 +1504,11 @@
1504 1504
                 "issues": "https://github.com/filamentphp/filament/issues",
1505 1505
                 "source": "https://github.com/filamentphp/filament"
1506 1506
             },
1507
-            "time": "2023-09-06T14:23:07+00:00"
1507
+            "time": "2023-09-18T10:30:34+00:00"
1508 1508
         },
1509 1509
         {
1510 1510
             "name": "filament/spatie-laravel-tags-plugin",
1511
-            "version": "v3.0.52",
1511
+            "version": "v3.0.53",
1512 1512
             "source": {
1513 1513
                 "type": "git",
1514 1514
                 "url": "https://github.com/filamentphp/spatie-laravel-tags-plugin.git",
@@ -1545,16 +1545,16 @@
1545 1545
         },
1546 1546
         {
1547 1547
             "name": "filament/support",
1548
-            "version": "v3.0.52",
1548
+            "version": "v3.0.53",
1549 1549
             "source": {
1550 1550
                 "type": "git",
1551 1551
                 "url": "https://github.com/filamentphp/support.git",
1552
-                "reference": "183354b6fe1af1bbda335818c2e412fb7c1869e9"
1552
+                "reference": "9f6fa9a2c03f45eccbca83a083535fb628f73b97"
1553 1553
             },
1554 1554
             "dist": {
1555 1555
                 "type": "zip",
1556
-                "url": "https://api.github.com/repos/filamentphp/support/zipball/183354b6fe1af1bbda335818c2e412fb7c1869e9",
1557
-                "reference": "183354b6fe1af1bbda335818c2e412fb7c1869e9",
1556
+                "url": "https://api.github.com/repos/filamentphp/support/zipball/9f6fa9a2c03f45eccbca83a083535fb628f73b97",
1557
+                "reference": "9f6fa9a2c03f45eccbca83a083535fb628f73b97",
1558 1558
                 "shasum": ""
1559 1559
             },
1560 1560
             "require": {
@@ -1598,20 +1598,20 @@
1598 1598
                 "issues": "https://github.com/filamentphp/filament/issues",
1599 1599
                 "source": "https://github.com/filamentphp/filament"
1600 1600
             },
1601
-            "time": "2023-09-16T10:26:04+00:00"
1601
+            "time": "2023-09-18T10:30:36+00:00"
1602 1602
         },
1603 1603
         {
1604 1604
             "name": "filament/tables",
1605
-            "version": "v3.0.52",
1605
+            "version": "v3.0.53",
1606 1606
             "source": {
1607 1607
                 "type": "git",
1608 1608
                 "url": "https://github.com/filamentphp/tables.git",
1609
-                "reference": "0cd15c2591f42d6528e65e99cf16f34c134904ad"
1609
+                "reference": "bf7110bceca30534038fe7e5344c236860636e27"
1610 1610
             },
1611 1611
             "dist": {
1612 1612
                 "type": "zip",
1613
-                "url": "https://api.github.com/repos/filamentphp/tables/zipball/0cd15c2591f42d6528e65e99cf16f34c134904ad",
1614
-                "reference": "0cd15c2591f42d6528e65e99cf16f34c134904ad",
1613
+                "url": "https://api.github.com/repos/filamentphp/tables/zipball/bf7110bceca30534038fe7e5344c236860636e27",
1614
+                "reference": "bf7110bceca30534038fe7e5344c236860636e27",
1615 1615
                 "shasum": ""
1616 1616
             },
1617 1617
             "require": {
@@ -1651,20 +1651,20 @@
1651 1651
                 "issues": "https://github.com/filamentphp/filament/issues",
1652 1652
                 "source": "https://github.com/filamentphp/filament"
1653 1653
             },
1654
-            "time": "2023-09-16T10:26:09+00:00"
1654
+            "time": "2023-09-18T10:30:31+00:00"
1655 1655
         },
1656 1656
         {
1657 1657
             "name": "filament/widgets",
1658
-            "version": "v3.0.52",
1658
+            "version": "v3.0.53",
1659 1659
             "source": {
1660 1660
                 "type": "git",
1661 1661
                 "url": "https://github.com/filamentphp/widgets.git",
1662
-                "reference": "11f37f08912f277e1bfc5b19e5b21d74b4f9b4e0"
1662
+                "reference": "bbe1952f1b04e673ae86a6cac758979e5e3ed18c"
1663 1663
             },
1664 1664
             "dist": {
1665 1665
                 "type": "zip",
1666
-                "url": "https://api.github.com/repos/filamentphp/widgets/zipball/11f37f08912f277e1bfc5b19e5b21d74b4f9b4e0",
1667
-                "reference": "11f37f08912f277e1bfc5b19e5b21d74b4f9b4e0",
1666
+                "url": "https://api.github.com/repos/filamentphp/widgets/zipball/bbe1952f1b04e673ae86a6cac758979e5e3ed18c",
1667
+                "reference": "bbe1952f1b04e673ae86a6cac758979e5e3ed18c",
1668 1668
                 "shasum": ""
1669 1669
             },
1670 1670
             "require": {
@@ -1695,7 +1695,7 @@
1695 1695
                 "issues": "https://github.com/filamentphp/filament/issues",
1696 1696
                 "source": "https://github.com/filamentphp/filament"
1697 1697
             },
1698
-            "time": "2023-09-10T23:30:09+00:00"
1698
+            "time": "2023-09-18T10:30:45+00:00"
1699 1699
         },
1700 1700
         {
1701 1701
             "name": "fruitcake/php-cors",
@@ -4750,16 +4750,16 @@
4750 4750
         },
4751 4751
         {
4752 4752
             "name": "psy/psysh",
4753
-            "version": "v0.11.20",
4753
+            "version": "v0.11.21",
4754 4754
             "source": {
4755 4755
                 "type": "git",
4756 4756
                 "url": "https://github.com/bobthecow/psysh.git",
4757
-                "reference": "0fa27040553d1d280a67a4393194df5228afea5b"
4757
+                "reference": "bcb22101107f3bf770523b65630c9d547f60c540"
4758 4758
             },
4759 4759
             "dist": {
4760 4760
                 "type": "zip",
4761
-                "url": "https://api.github.com/repos/bobthecow/psysh/zipball/0fa27040553d1d280a67a4393194df5228afea5b",
4762
-                "reference": "0fa27040553d1d280a67a4393194df5228afea5b",
4761
+                "url": "https://api.github.com/repos/bobthecow/psysh/zipball/bcb22101107f3bf770523b65630c9d547f60c540",
4762
+                "reference": "bcb22101107f3bf770523b65630c9d547f60c540",
4763 4763
                 "shasum": ""
4764 4764
             },
4765 4765
             "require": {
@@ -4789,6 +4789,10 @@
4789 4789
             "extra": {
4790 4790
                 "branch-alias": {
4791 4791
                     "dev-main": "0.11.x-dev"
4792
+                },
4793
+                "bamarni-bin": {
4794
+                    "bin-links": false,
4795
+                    "forward-command": false
4792 4796
                 }
4793 4797
             },
4794 4798
             "autoload": {
@@ -4820,9 +4824,9 @@
4820 4824
             ],
4821 4825
             "support": {
4822 4826
                 "issues": "https://github.com/bobthecow/psysh/issues",
4823
-                "source": "https://github.com/bobthecow/psysh/tree/v0.11.20"
4827
+                "source": "https://github.com/bobthecow/psysh/tree/v0.11.21"
4824 4828
             },
4825
-            "time": "2023-07-31T14:32:22+00:00"
4829
+            "time": "2023-09-17T21:15:54+00:00"
4826 4830
         },
4827 4831
         {
4828 4832
             "name": "ralouphie/getallheaders",
@@ -9738,16 +9742,16 @@
9738 9742
         },
9739 9743
         {
9740 9744
             "name": "sebastian/exporter",
9741
-            "version": "5.0.1",
9745
+            "version": "5.1.0",
9742 9746
             "source": {
9743 9747
                 "type": "git",
9744 9748
                 "url": "https://github.com/sebastianbergmann/exporter.git",
9745
-                "reference": "32ff03d078fed1279c4ec9a407d08c5e9febb480"
9749
+                "reference": "c3fa8483f9539b190f7cd4bfc4a07631dd1df344"
9746 9750
             },
9747 9751
             "dist": {
9748 9752
                 "type": "zip",
9749
-                "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/32ff03d078fed1279c4ec9a407d08c5e9febb480",
9750
-                "reference": "32ff03d078fed1279c4ec9a407d08c5e9febb480",
9753
+                "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/c3fa8483f9539b190f7cd4bfc4a07631dd1df344",
9754
+                "reference": "c3fa8483f9539b190f7cd4bfc4a07631dd1df344",
9751 9755
                 "shasum": ""
9752 9756
             },
9753 9757
             "require": {
@@ -9804,7 +9808,7 @@
9804 9808
             "support": {
9805 9809
                 "issues": "https://github.com/sebastianbergmann/exporter/issues",
9806 9810
                 "security": "https://github.com/sebastianbergmann/exporter/security/policy",
9807
-                "source": "https://github.com/sebastianbergmann/exporter/tree/5.0.1"
9811
+                "source": "https://github.com/sebastianbergmann/exporter/tree/5.1.0"
9808 9812
             },
9809 9813
             "funding": [
9810 9814
                 {
@@ -9812,7 +9816,7 @@
9812 9816
                     "type": "github"
9813 9817
                 }
9814 9818
             ],
9815
-            "time": "2023-09-08T04:46:58+00:00"
9819
+            "time": "2023-09-18T07:15:37+00:00"
9816 9820
         },
9817 9821
         {
9818 9822
             "name": "sebastian/global-state",
@@ -10657,5 +10661,5 @@
10657 10661
         "php": "^8.2"
10658 10662
     },
10659 10663
     "platform-dev": [],
10660
-    "plugin-api-version": "2.6.0"
10664
+    "plugin-api-version": "2.3.0"
10661 10665
 }

+ 1
- 1
config/services.php Visa fil

@@ -34,7 +34,7 @@ return [
34 34
     'github' => [
35 35
         'client_id' => env('GITHUB_CLIENT_ID'),
36 36
         'client_secret' => env('GITHUB_CLIENT_SECRET'),
37
-        'redirect' => 'http://erpsaas2.test/company/oauth/github/callback',
37
+        'redirect' => 'http://erpsaas.test/company/oauth/github/callback',
38 38
     ],
39 39
 
40 40
 ];

+ 3
- 0
database/factories/Setting/CompanyProfileFactory.php Visa fil

@@ -3,6 +3,7 @@
3 3
 namespace Database\Factories\Setting;
4 4
 
5 5
 use App\Enums\EntityType;
6
+use App\Events\CompanyGenerated;
6 7
 use App\Models\Setting\CompanyProfile;
7 8
 use Illuminate\Database\Eloquent\Factories\Factory;
8 9
 
@@ -42,6 +43,8 @@ class CompanyProfileFactory extends Factory
42 43
             $companyProfile->timezone = $this->faker->randomElement(CompanyProfile::getTimezoneOptions($companyProfile->country));
43 44
             $companyProfile->state = $this->faker->randomElement(CompanyProfile::getStateOptions($companyProfile->country));
44 45
             $companyProfile->save();
46
+
47
+            event(new CompanyGenerated($companyProfile->company->owner, $companyProfile->company, $companyProfile->country));
45 48
         });
46 49
     }
47 50
 }

+ 20
- 0
database/factories/Setting/CurrencyFactory.php Visa fil

@@ -36,4 +36,24 @@ class CurrencyFactory extends Factory
36 36
             'enabled' => true,
37 37
         ];
38 38
     }
39
+
40
+    /**
41
+     * Define a state for a specific currency.
42
+     */
43
+    public function forCurrency(string $code): Factory
44
+    {
45
+        $currency = currency($code);
46
+
47
+        return $this->state([
48
+            'name' => $currency->getName(),
49
+            'code' => $currency->getCurrency(),
50
+            'rate' => $currency->getRate(),
51
+            'precision' => $currency->getPrecision(),
52
+            'symbol' => $currency->getSymbol(),
53
+            'symbol_first' => $currency->isSymbolFirst(),
54
+            'decimal_mark' => $currency->getDecimalMark(),
55
+            'thousands_separator' => $currency->getThousandsSeparator(),
56
+            'enabled' => true,
57
+        ]);
58
+    }
39 59
 }

Laddar…
Avbryt
Spara