comparison app/Models/Client.php @ 2:90296614b7e2 default tip

Adding in the base for the clients table
author luka
date Thu, 28 Aug 2025 20:55:40 -0400
parents
children
comparison
equal deleted inserted replaced
1:8971e685366b 2:90296614b7e2
1 <?php
2
3 namespace App\Models;
4
5 use Illuminate\Database\Eloquent\SoftDeletes;
6 use Wizard\Framework\Models\BaseModel;
7
8 class Client extends BaseModel
9 {
10 // use HasFactory;
11 use SoftDeletes;
12
13 /**
14 * The table associated with the model.
15 *
16 * @var string
17 */
18 protected $table = 'clients';
19
20 /**
21 * The model's default values for attributes.
22 *
23 * @var array
24 */
25 protected $attributes = [
26 // {{ atributeInsertPoint }}
27 ];
28
29 protected $casts = [
30
31 ];
32
33 protected $fillable = [
34 'name',
35 'email',
36 'phone_number',
37 'address',
38 'notes',
39
40 ];
41
42 protected $default_relations = [
43
44 ];
45
46 protected static $filters = [
47 'name' => [
48 'column_name' => 'name',
49 'table' => 'clients',
50 'display' => 'Name',
51 'type' => 'value',
52 ],
53 'email' => [
54 'column_name' => 'email',
55 'table' => 'clients',
56 'display' => 'Email',
57 'type' => 'value',
58 ],
59 'phone_number' => [
60 'column_name' => 'phone_number',
61 'table' => 'clients',
62 'display' => 'Phone Number',
63 'type' => 'value',
64 ],
65 'address' => [
66 'column_name' => 'address',
67 'table' => 'clients',
68 'display' => 'Address',
69 'type' => 'value',
70 ],
71 'notes' => [
72 'column_name' => 'notes',
73 'table' => 'clients',
74 'display' => 'Notes',
75 'type' => 'value',
76 ],
77
78 ];
79
80 public static function get_filters()
81 {
82 return static::filters;
83 }
84
85 // relations
86
87 // BelongsTo
88
89 // HasMany
90
91 // HasManyThrough
92
93 /**
94 * Load the default relations for the model.
95 *
96 * @return $this
97 */
98 public function load_relations()
99 {
100 foreach ($this->default_relations as $relation) {
101 $this->load($relation);
102 }
103
104 return $this;
105 }
106
107 /**
108 * Retrieve a query builder instance with default relations loaded.
109 *
110 * @return \Illuminate\Database\Eloquent\Builder
111 */
112 public static function data_query()
113 {
114 return parent::data_query();
115 }
116
117 /**
118 * Retrieve a query builder instance with default relations loaded.
119 *
120 * @return \Illuminate\Database\Eloquent\Builder
121 */
122 public static function get_data(array $validated = [])
123 {
124 return parent::get_data($validated);
125 }
126 }