annotate src/Generator/Model/stubs/model.stub @ 23:827efbf4d73c main-dev

Huge changes to the relationships for models and more complex
author Luka Sitas <sitas.luka.97@gmail.com>
date Fri, 11 Apr 2025 20:50:20 -0400
parents 3426c7e91c24
children 31109c61ce02
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4
a20439b1c9d3 Added Model generator and other updates.
luka
parents:
diff changeset
1 <?php
a20439b1c9d3 Added Model generator and other updates.
luka
parents:
diff changeset
2
a20439b1c9d3 Added Model generator and other updates.
luka
parents:
diff changeset
3 namespace {{ namespace }};
a20439b1c9d3 Added Model generator and other updates.
luka
parents:
diff changeset
4
a20439b1c9d3 Added Model generator and other updates.
luka
parents:
diff changeset
5 use Illuminate\Database\Eloquent\Factories\HasFactory;
a20439b1c9d3 Added Model generator and other updates.
luka
parents:
diff changeset
6 use Illuminate\Database\Eloquent\Model;
5
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents: 4
diff changeset
7 use Illuminate\Database\Eloquent\SoftDeletes;
4
a20439b1c9d3 Added Model generator and other updates.
luka
parents:
diff changeset
8
a20439b1c9d3 Added Model generator and other updates.
luka
parents:
diff changeset
9 class {{ class }} extends Model
a20439b1c9d3 Added Model generator and other updates.
luka
parents:
diff changeset
10 {
5
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents: 4
diff changeset
11 //use HasFactory;
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents: 4
diff changeset
12 use SoftDeletes;
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents: 4
diff changeset
13
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents: 4
diff changeset
14 /**
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents: 4
diff changeset
15 * The table associated with the model.
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents: 4
diff changeset
16 *
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents: 4
diff changeset
17 * @var string
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents: 4
diff changeset
18 */
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents: 4
diff changeset
19 protected $table = '{{ tableName }}';
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents: 4
diff changeset
20
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents: 4
diff changeset
21 /**
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents: 4
diff changeset
22 * The model's default values for attributes.
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents: 4
diff changeset
23 *
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents: 4
diff changeset
24 * @var array
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents: 4
diff changeset
25 */
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents: 4
diff changeset
26 protected $attributes = [
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents: 4
diff changeset
27 # {{ atributeInsertPoint }}
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents: 4
diff changeset
28 ];
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents: 4
diff changeset
29
23
827efbf4d73c Huge changes to the relationships for models and more complex
Luka Sitas <sitas.luka.97@gmail.com>
parents: 11
diff changeset
30 protected $fillable =[
827efbf4d73c Huge changes to the relationships for models and more complex
Luka Sitas <sitas.luka.97@gmail.com>
parents: 11
diff changeset
31 # {{ fillableInsertPoint }}
827efbf4d73c Huge changes to the relationships for models and more complex
Luka Sitas <sitas.luka.97@gmail.com>
parents: 11
diff changeset
32 ];
827efbf4d73c Huge changes to the relationships for models and more complex
Luka Sitas <sitas.luka.97@gmail.com>
parents: 11
diff changeset
33
5
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents: 4
diff changeset
34
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents: 4
diff changeset
35 public static function boot() : void {
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents: 4
diff changeset
36 parent::boot();
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents: 4
diff changeset
37
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents: 4
diff changeset
38 self::creating(function ($item) {
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents: 4
diff changeset
39 $item->created_by = \Auth::user()->id;
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents: 4
diff changeset
40 $item->updated_by = \Auth::user()->id;
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents: 4
diff changeset
41 });
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents: 4
diff changeset
42
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents: 4
diff changeset
43 self::saving(function ($item) {
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents: 4
diff changeset
44 $item->updated_by = \Auth::user()->id;
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents: 4
diff changeset
45 });
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents: 4
diff changeset
46 }
11
3426c7e91c24 Modifying generaters and replacers
luka
parents: 5
diff changeset
47
3426c7e91c24 Modifying generaters and replacers
luka
parents: 5
diff changeset
48
3426c7e91c24 Modifying generaters and replacers
luka
parents: 5
diff changeset
49 //relations
3426c7e91c24 Modifying generaters and replacers
luka
parents: 5
diff changeset
50
3426c7e91c24 Modifying generaters and replacers
luka
parents: 5
diff changeset
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
3426c7e91c24 Modifying generaters and replacers
luka
parents: 5
diff changeset
53
3426c7e91c24 Modifying generaters and replacers
luka
parents: 5
diff changeset
54 // HasMany
23
827efbf4d73c Huge changes to the relationships for models and more complex
Luka Sitas <sitas.luka.97@gmail.com>
parents: 11
diff changeset
55 # {{ has_may_relationships }}
11
3426c7e91c24 Modifying generaters and replacers
luka
parents: 5
diff changeset
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
3426c7e91c24 Modifying generaters and replacers
luka
parents: 5
diff changeset
59
4
a20439b1c9d3 Added Model generator and other updates.
luka
parents:
diff changeset
60 }