annotate src/Generator/Model/stubs/model.stub @ 11:3426c7e91c24 main-dev

Modifying generaters and replacers
author luka
date Wed, 24 Apr 2024 19:53:42 -0400
parents b0b2e79ad8e6
children 827efbf4d73c
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
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents: 4
diff changeset
30
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents: 4
diff changeset
31 public static function boot() : void {
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents: 4
diff changeset
32 parent::boot();
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents: 4
diff changeset
33
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents: 4
diff changeset
34 self::creating(function ($item) {
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents: 4
diff changeset
35 $item->created_by = \Auth::user()->id;
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents: 4
diff changeset
36 $item->updated_by = \Auth::user()->id;
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
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents: 4
diff changeset
39 self::saving(function ($item) {
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 }
11
3426c7e91c24 Modifying generaters and replacers
luka
parents: 5
diff changeset
43
3426c7e91c24 Modifying generaters and replacers
luka
parents: 5
diff changeset
44
3426c7e91c24 Modifying generaters and replacers
luka
parents: 5
diff changeset
45 //relations
3426c7e91c24 Modifying generaters and replacers
luka
parents: 5
diff changeset
46
3426c7e91c24 Modifying generaters and replacers
luka
parents: 5
diff changeset
47 // BelongsTo
3426c7e91c24 Modifying generaters and replacers
luka
parents: 5
diff changeset
48
3426c7e91c24 Modifying generaters and replacers
luka
parents: 5
diff changeset
49 // HasMany
3426c7e91c24 Modifying generaters and replacers
luka
parents: 5
diff changeset
50
3426c7e91c24 Modifying generaters and replacers
luka
parents: 5
diff changeset
51
4
a20439b1c9d3 Added Model generator and other updates.
luka
parents:
diff changeset
52 }