1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace App; |
4
|
|
|
|
5
|
|
|
use Illuminate\Database\Eloquent; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* App\Make |
9
|
|
|
* |
10
|
|
|
* @property integer $id |
11
|
|
|
* @property string $name |
12
|
|
|
* @property \Carbon\Carbon $deleted_at |
13
|
|
|
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Model[] $models |
14
|
|
|
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Rack[] $racks |
15
|
|
|
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Purchase[] $purchases |
16
|
|
|
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Guitar[] $guitars |
17
|
|
|
* @method static \Illuminate\Database\Query\Builder|\App\Make whereId($value) |
18
|
|
|
* @method static \Illuminate\Database\Query\Builder|\App\Make whereName($value) |
19
|
|
|
* @method static \Illuminate\Database\Query\Builder|\App\Make whereDeletedAt($value) |
20
|
|
|
* @mixin \Eloquent |
21
|
|
|
*/ |
22
|
|
|
class Make extends Eloquent\Model |
23
|
|
|
{ |
24
|
|
|
use Eloquent\SoftDeletes; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* We do not want any timestamps. |
28
|
|
|
* |
29
|
|
|
* @var bool |
30
|
|
|
*/ |
31
|
|
|
public $timestamps = false; |
32
|
|
|
/** |
33
|
|
|
* @var array |
34
|
|
|
*/ |
35
|
|
|
protected $dates = ['deleted_at']; |
36
|
|
|
/** |
37
|
|
|
* The attributes that are not mass assignable. |
38
|
|
|
* |
39
|
|
|
* @var array |
40
|
|
|
*/ |
41
|
|
|
protected $guarded = []; |
42
|
|
|
|
43
|
23 |
|
public static function boot() |
44
|
|
|
{ |
45
|
23 |
|
parent::boot(); |
46
|
|
|
|
47
|
23 |
|
static::deleting(function (Make $make) { |
48
|
|
|
$make->models()->delete(); |
49
|
|
|
$make->racks()->delete(); |
50
|
|
|
$make->purchases()->delete(); |
51
|
|
|
$make->guitars()->delete(); |
52
|
23 |
|
}); |
53
|
23 |
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* Models of this make. |
57
|
|
|
* |
58
|
|
|
* @return Eloquent\Relations\HasMany |
59
|
|
|
*/ |
60
|
|
|
public function models() |
61
|
|
|
{ |
62
|
|
|
return $this->hasMany(Model::class); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* Rack this make is located in. |
67
|
|
|
* |
68
|
|
|
* @return Eloquent\Relations\HasMany |
69
|
|
|
*/ |
70
|
|
|
public function racks() |
71
|
|
|
{ |
72
|
|
|
return $this->hasMany(Rack::class); |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* Purchases of this make. |
77
|
|
|
* |
78
|
|
|
* @return Eloquent\Relations\HasMany |
79
|
|
|
*/ |
80
|
|
|
public function purchases() |
81
|
|
|
{ |
82
|
|
|
return $this->hasMany(Purchase::class); |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
/** |
86
|
|
|
* Guitars of this make. |
87
|
|
|
* |
88
|
|
|
* @return Eloquent\Relations\HasMany |
89
|
|
|
*/ |
90
|
|
|
public function guitars() |
91
|
|
|
{ |
92
|
|
|
return $this->hasMany(Guitar::class); |
93
|
|
|
} |
94
|
|
|
} |
95
|
|
|
|