Mercurial > packages > magicforger
annotate src/Generator/Model/stubs/model.stub @ 24:31109c61ce02 codex
Refactor RelationshipNavigator formatting and implement belongsTo, hasMany, belongsToMany injection in ModelGenerator
| author | Luka Sitas <sitas.luka.97@gmail.com> |
|---|---|
| date | Tue, 22 Apr 2025 21:37:44 -0400 |
| parents | 827efbf4d73c |
| children | 555bfaa500ac |
| rev | line source |
|---|---|
| 4 | 1 <?php |
| 2 | |
| 3 namespace {{ namespace }}; | |
| 4 | |
| 5 use Illuminate\Database\Eloquent\Factories\HasFactory; | |
| 6 use Illuminate\Database\Eloquent\Model; | |
| 5 | 7 use Illuminate\Database\Eloquent\SoftDeletes; |
| 4 | 8 |
| 9 class {{ class }} extends Model | |
| 10 { | |
| 5 | 11 //use HasFactory; |
| 12 use SoftDeletes; | |
| 13 | |
| 14 /** | |
| 15 * The table associated with the model. | |
| 16 * | |
| 17 * @var string | |
| 18 */ | |
| 19 protected $table = '{{ tableName }}'; | |
| 20 | |
| 21 /** | |
| 22 * The model's default values for attributes. | |
| 23 * | |
| 24 * @var array | |
| 25 */ | |
| 26 protected $attributes = [ | |
| 27 # {{ atributeInsertPoint }} | |
| 28 ]; | |
| 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 | 34 |
| 35 public static function boot() : void { | |
| 36 parent::boot(); | |
| 37 | |
| 38 self::creating(function ($item) { | |
| 39 $item->created_by = \Auth::user()->id; | |
| 40 $item->updated_by = \Auth::user()->id; | |
| 41 }); | |
| 42 | |
| 43 self::saving(function ($item) { | |
| 44 $item->updated_by = \Auth::user()->id; | |
| 45 }); | |
| 46 } | |
| 11 | 47 |
| 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 |
| 4 | 60 } |
