Blame view

database/seeds/Categories.php 1.72 KB
b7c7a5f6   Alexey Boroda   first commit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
  <?php
  
  namespace Database\Seeds;
  
  use App\Models\Model;
  use App\Models\Setting\Category;
  use Illuminate\Database\Seeder;
  
  class Categories extends Seeder
  {
      /**
       * Run the database seeds.
       *
       * @return void
       */
      public function run()
      {
          Model::unguard();
  
          $this->create();
  
          Model::reguard();
      }
  
      private function create()
      {
          $company_id = $this->command->argument('company');
  
          $rows = [
              [
                  'company_id' => $company_id,
                  'name' => trans_choice('general.transfers', 1),
                  'type' => 'other',
                  'color' => '#605ca8',
                  'enabled' => '1'
              ],
              [
                  'company_id' => $company_id,
                  'name' => trans('demo.categories_deposit'),
                  'type' => 'income',
                  'color' => '#f39c12',
                  'enabled' => '1'
              ],
              [
                  'company_id' => $company_id,
                  'name' => trans('demo.categories_sales'),
                  'type' => 'income',
                  'color' => '#6da252',
                  'enabled' => '1'
              ],
              [
                  'company_id' => $company_id,
                  'name' => trans_choice('general.others', 1),
                  'type' => 'expense',
                  'color' => '#d2d6de',
                  'enabled' => '1'
              ],
              [
                  'company_id' => $company_id,
                  'name' => trans('general.general'),
                  'type' => 'item',
                  'color' => '#00c0ef',
                  'enabled' => '1'
              ],
          ];
  
          foreach ($rows as $row) {
              Category::create($row);
          }
      }
  }