Mercurial > packages > magicforger
annotate src/Generator/Model/stubs/model.stub @ 31:8dd668020310 codex
started converting too bootstrap, also better support for casts
| author | Luka Sitas <sitas.luka.97@gmail.com> |
|---|---|
| date | Tue, 19 Aug 2025 20:34:53 -0400 |
| parents | 010ace248d14 |
| children | 76584181267a |
| rev | line source |
|---|---|
| 4 | 1 <?php |
| 2 | |
| 3 namespace {{ namespace }}; | |
| 4 | |
| 5 | 5 use Illuminate\Database\Eloquent\SoftDeletes; |
|
31
8dd668020310
started converting too bootstrap, also better support for casts
Luka Sitas <sitas.luka.97@gmail.com>
parents:
29
diff
changeset
|
6 use Wizard\Framework\Models\BaseModel; |
| 4 | 7 |
|
29
010ace248d14
Added support for filters, not fully there with relations or anything like that but it's a start
Luka Sitas <sitas.luka.97@gmail.com>
parents:
28
diff
changeset
|
8 class {{ class }} extends BaseModel |
| 4 | 9 { |
| 5 | 10 //use HasFactory; |
| 11 use SoftDeletes; | |
| 12 | |
| 13 /** | |
| 14 * The table associated with the model. | |
| 15 * | |
| 16 * @var string | |
| 17 */ | |
| 18 protected $table = '{{ tableName }}'; | |
| 19 | |
| 20 /** | |
| 21 * The model's default values for attributes. | |
| 22 * | |
| 23 * @var array | |
| 24 */ | |
| 25 protected $attributes = [ | |
| 26 # {{ atributeInsertPoint }} | |
| 27 ]; | |
| 28 | |
|
31
8dd668020310
started converting too bootstrap, also better support for casts
Luka Sitas <sitas.luka.97@gmail.com>
parents:
29
diff
changeset
|
29 protected $casts = [ |
|
8dd668020310
started converting too bootstrap, also better support for casts
Luka Sitas <sitas.luka.97@gmail.com>
parents:
29
diff
changeset
|
30 # {{ castInsertPoint }} |
|
8dd668020310
started converting too bootstrap, also better support for casts
Luka Sitas <sitas.luka.97@gmail.com>
parents:
29
diff
changeset
|
31 ]; |
|
8dd668020310
started converting too bootstrap, also better support for casts
Luka Sitas <sitas.luka.97@gmail.com>
parents:
29
diff
changeset
|
32 |
|
26
555bfaa500ac
Big update for view creation based on the column type.
Luka Sitas <sitas.luka.97@gmail.com>
parents:
24
diff
changeset
|
33 protected $fillable = [ |
|
23
827efbf4d73c
Huge changes to the relationships for models and more complex
Luka Sitas <sitas.luka.97@gmail.com>
parents:
11
diff
changeset
|
34 # {{ fillableInsertPoint }} |
|
827efbf4d73c
Huge changes to the relationships for models and more complex
Luka Sitas <sitas.luka.97@gmail.com>
parents:
11
diff
changeset
|
35 ]; |
|
827efbf4d73c
Huge changes to the relationships for models and more complex
Luka Sitas <sitas.luka.97@gmail.com>
parents:
11
diff
changeset
|
36 |
|
26
555bfaa500ac
Big update for view creation based on the column type.
Luka Sitas <sitas.luka.97@gmail.com>
parents:
24
diff
changeset
|
37 protected $default_relations = [ |
|
555bfaa500ac
Big update for view creation based on the column type.
Luka Sitas <sitas.luka.97@gmail.com>
parents:
24
diff
changeset
|
38 # {{ defaultRelationsInsertPoint }} |
|
555bfaa500ac
Big update for view creation based on the column type.
Luka Sitas <sitas.luka.97@gmail.com>
parents:
24
diff
changeset
|
39 ]; |
| 5 | 40 |
|
29
010ace248d14
Added support for filters, not fully there with relations or anything like that but it's a start
Luka Sitas <sitas.luka.97@gmail.com>
parents:
28
diff
changeset
|
41 protected static $filters = [ |
|
28
f88d2d5dee30
Updated inputs and routes
Luka Sitas <sitas.luka.97@gmail.com>
parents:
26
diff
changeset
|
42 # {{ defaultFiltersInsertPoint }} |
|
f88d2d5dee30
Updated inputs and routes
Luka Sitas <sitas.luka.97@gmail.com>
parents:
26
diff
changeset
|
43 ]; |
| 5 | 44 |
|
28
f88d2d5dee30
Updated inputs and routes
Luka Sitas <sitas.luka.97@gmail.com>
parents:
26
diff
changeset
|
45 public static function get_filters() { |
|
f88d2d5dee30
Updated inputs and routes
Luka Sitas <sitas.luka.97@gmail.com>
parents:
26
diff
changeset
|
46 return static::filters; |
| 5 | 47 } |
| 11 | 48 |
| 49 //relations | |
| 50 | |
| 51 // BelongsTo | |
|
23
827efbf4d73c
Huge changes to the relationships for models and more complex
Luka Sitas <sitas.luka.97@gmail.com>
parents:
11
diff
changeset
|
52 # {{ belongs_to_relationships }} |
| 11 | 53 |
| 54 // HasMany | |
|
24
31109c61ce02
Refactor RelationshipNavigator formatting and implement belongsTo, hasMany, belongsToMany injection in ModelGenerator
Luka Sitas <sitas.luka.97@gmail.com>
parents:
23
diff
changeset
|
55 # {{ has_many_relationships }} |
| 11 | 56 |
|
23
827efbf4d73c
Huge changes to the relationships for models and more complex
Luka Sitas <sitas.luka.97@gmail.com>
parents:
11
diff
changeset
|
57 // HasManyThrough |
|
827efbf4d73c
Huge changes to the relationships for models and more complex
Luka Sitas <sitas.luka.97@gmail.com>
parents:
11
diff
changeset
|
58 # {{ has_many_through_relationships }} |
| 11 | 59 |
|
26
555bfaa500ac
Big update for view creation based on the column type.
Luka Sitas <sitas.luka.97@gmail.com>
parents:
24
diff
changeset
|
60 |
|
555bfaa500ac
Big update for view creation based on the column type.
Luka Sitas <sitas.luka.97@gmail.com>
parents:
24
diff
changeset
|
61 /** |
|
555bfaa500ac
Big update for view creation based on the column type.
Luka Sitas <sitas.luka.97@gmail.com>
parents:
24
diff
changeset
|
62 * Load the default relations for the model. |
|
555bfaa500ac
Big update for view creation based on the column type.
Luka Sitas <sitas.luka.97@gmail.com>
parents:
24
diff
changeset
|
63 * |
|
555bfaa500ac
Big update for view creation based on the column type.
Luka Sitas <sitas.luka.97@gmail.com>
parents:
24
diff
changeset
|
64 * @return $this |
|
555bfaa500ac
Big update for view creation based on the column type.
Luka Sitas <sitas.luka.97@gmail.com>
parents:
24
diff
changeset
|
65 */ |
|
555bfaa500ac
Big update for view creation based on the column type.
Luka Sitas <sitas.luka.97@gmail.com>
parents:
24
diff
changeset
|
66 public function load_relations() { |
|
555bfaa500ac
Big update for view creation based on the column type.
Luka Sitas <sitas.luka.97@gmail.com>
parents:
24
diff
changeset
|
67 foreach($this->default_relations as $relation) { |
|
555bfaa500ac
Big update for view creation based on the column type.
Luka Sitas <sitas.luka.97@gmail.com>
parents:
24
diff
changeset
|
68 $this->load($relation); |
|
555bfaa500ac
Big update for view creation based on the column type.
Luka Sitas <sitas.luka.97@gmail.com>
parents:
24
diff
changeset
|
69 } |
|
555bfaa500ac
Big update for view creation based on the column type.
Luka Sitas <sitas.luka.97@gmail.com>
parents:
24
diff
changeset
|
70 return $this; |
|
555bfaa500ac
Big update for view creation based on the column type.
Luka Sitas <sitas.luka.97@gmail.com>
parents:
24
diff
changeset
|
71 } |
|
555bfaa500ac
Big update for view creation based on the column type.
Luka Sitas <sitas.luka.97@gmail.com>
parents:
24
diff
changeset
|
72 |
|
555bfaa500ac
Big update for view creation based on the column type.
Luka Sitas <sitas.luka.97@gmail.com>
parents:
24
diff
changeset
|
73 /** |
|
555bfaa500ac
Big update for view creation based on the column type.
Luka Sitas <sitas.luka.97@gmail.com>
parents:
24
diff
changeset
|
74 * Retrieve a query builder instance with default relations loaded. |
|
555bfaa500ac
Big update for view creation based on the column type.
Luka Sitas <sitas.luka.97@gmail.com>
parents:
24
diff
changeset
|
75 * |
|
555bfaa500ac
Big update for view creation based on the column type.
Luka Sitas <sitas.luka.97@gmail.com>
parents:
24
diff
changeset
|
76 * @return \Illuminate\Database\Eloquent\Builder |
|
555bfaa500ac
Big update for view creation based on the column type.
Luka Sitas <sitas.luka.97@gmail.com>
parents:
24
diff
changeset
|
77 */ |
|
555bfaa500ac
Big update for view creation based on the column type.
Luka Sitas <sitas.luka.97@gmail.com>
parents:
24
diff
changeset
|
78 public static function data_query() { |
|
28
f88d2d5dee30
Updated inputs and routes
Luka Sitas <sitas.luka.97@gmail.com>
parents:
26
diff
changeset
|
79 return parent::data_query(); |
|
26
555bfaa500ac
Big update for view creation based on the column type.
Luka Sitas <sitas.luka.97@gmail.com>
parents:
24
diff
changeset
|
80 } |
|
555bfaa500ac
Big update for view creation based on the column type.
Luka Sitas <sitas.luka.97@gmail.com>
parents:
24
diff
changeset
|
81 |
|
555bfaa500ac
Big update for view creation based on the column type.
Luka Sitas <sitas.luka.97@gmail.com>
parents:
24
diff
changeset
|
82 /** |
|
555bfaa500ac
Big update for view creation based on the column type.
Luka Sitas <sitas.luka.97@gmail.com>
parents:
24
diff
changeset
|
83 * Retrieve a query builder instance with default relations loaded. |
|
555bfaa500ac
Big update for view creation based on the column type.
Luka Sitas <sitas.luka.97@gmail.com>
parents:
24
diff
changeset
|
84 * |
|
555bfaa500ac
Big update for view creation based on the column type.
Luka Sitas <sitas.luka.97@gmail.com>
parents:
24
diff
changeset
|
85 * @return \Illuminate\Database\Eloquent\Builder |
|
555bfaa500ac
Big update for view creation based on the column type.
Luka Sitas <sitas.luka.97@gmail.com>
parents:
24
diff
changeset
|
86 */ |
|
28
f88d2d5dee30
Updated inputs and routes
Luka Sitas <sitas.luka.97@gmail.com>
parents:
26
diff
changeset
|
87 public static function get_data(array $validated = []) |
|
26
555bfaa500ac
Big update for view creation based on the column type.
Luka Sitas <sitas.luka.97@gmail.com>
parents:
24
diff
changeset
|
88 { |
|
28
f88d2d5dee30
Updated inputs and routes
Luka Sitas <sitas.luka.97@gmail.com>
parents:
26
diff
changeset
|
89 return parent::get_data($validated); |
|
26
555bfaa500ac
Big update for view creation based on the column type.
Luka Sitas <sitas.luka.97@gmail.com>
parents:
24
diff
changeset
|
90 } |
|
555bfaa500ac
Big update for view creation based on the column type.
Luka Sitas <sitas.luka.97@gmail.com>
parents:
24
diff
changeset
|
91 |
| 4 | 92 } |
