1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace RafflesArgentina\ResourceController\Models; |
4
|
|
|
|
5
|
|
|
use Illuminate\Database\Eloquent\Model; |
6
|
|
|
use Illuminate\Database\Eloquent\SoftDeletes; |
7
|
|
|
|
8
|
|
|
class User extends Model |
9
|
|
|
{ |
10
|
|
|
use SoftDeletes; |
11
|
|
|
|
12
|
|
|
protected $fillable = [ |
13
|
|
|
'name', |
14
|
|
|
'email', |
15
|
|
|
'password', |
16
|
|
|
'upload_id', |
17
|
|
|
'related_id', |
18
|
|
|
]; |
19
|
|
|
|
20
|
|
|
public function hasOneFileUpload() |
21
|
|
|
{ |
22
|
|
|
return $this->hasOne(Upload::class); |
23
|
|
|
} |
24
|
|
|
|
25
|
|
|
public function belongsToFileUpload() |
26
|
|
|
{ |
27
|
|
|
return $this->belongsTo(Upload::class, 'upload_id'); |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
public function hasManyFileUploads() |
31
|
|
|
{ |
32
|
|
|
return $this->hasMany(Upload::class); |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
public function belongsToManyFileUploads() |
36
|
|
|
{ |
37
|
|
|
return $this->belongsToMany(Upload::class, 'upload_user', 'upload_id', 'user_id'); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
public function morphOneFileUpload() |
41
|
|
|
{ |
42
|
|
|
return $this->morphOne(Upload::class, 'uploadeable'); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
public function morphManyFileUploads() |
46
|
|
|
{ |
47
|
|
|
return $this->morphMany(Upload::class, 'uploadeable'); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
public function morphToManyFileUploads() |
51
|
|
|
{ |
52
|
|
|
return $this->morphToMany(Upload::class, 'uploadeable'); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
public function hasOneRelated() |
56
|
|
|
{ |
57
|
|
|
return $this->hasOne(Related::class); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
public function belongsToRelated() |
61
|
|
|
{ |
62
|
|
|
return $this->belongsTo(Related::class, 'related_id'); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
public function hasManyRelated() |
66
|
|
|
{ |
67
|
|
|
return $this->hasMany(Related::class); |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
public function belongsToManyRelated() |
71
|
|
|
{ |
72
|
|
|
return $this->belongsToMany(Related::class); |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
public function morphOneRelated() |
76
|
|
|
{ |
77
|
|
|
return $this->morphOne(Related::class, 'relatable'); |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
public function morphManyRelated() |
81
|
|
|
{ |
82
|
|
|
return $this->morphMany(Related::class, 'relatable'); |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
public function morphToManyRelated() |
86
|
|
|
{ |
87
|
|
|
return $this->morphToMany(Related::class, 'relatable'); |
88
|
|
|
} |
89
|
|
|
} |
90
|
|
|
|