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
|
|
|
'location', |
14
|
|
|
'name', |
15
|
|
|
'email', |
16
|
|
|
'password', |
17
|
|
|
'upload_id', |
18
|
|
|
'related_id', |
19
|
|
|
]; |
20
|
|
|
|
21
|
|
|
public function hasOneFileUpload() |
22
|
|
|
{ |
23
|
|
|
return $this->hasOne(Upload::class); |
24
|
|
|
} |
25
|
|
|
|
26
|
|
|
public function belongsToFileUpload() |
27
|
|
|
{ |
28
|
|
|
return $this->belongsTo(Upload::class, 'upload_id'); |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
public function hasManyFileUploads() |
32
|
|
|
{ |
33
|
|
|
return $this->hasMany(Upload::class); |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
public function belongsToManyFileUploads() |
37
|
|
|
{ |
38
|
|
|
return $this->belongsToMany(Upload::class, 'upload_user', 'upload_id', 'user_id'); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
public function morphOneFileUpload() |
42
|
|
|
{ |
43
|
|
|
return $this->morphOne(Upload::class, 'uploadeable'); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
public function morphManyFileUploads() |
47
|
|
|
{ |
48
|
|
|
return $this->morphMany(Upload::class, 'uploadeable'); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
public function morphToManyFileUploads() |
52
|
|
|
{ |
53
|
|
|
return $this->morphToMany(Upload::class, 'uploadeable'); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
public function hasOneRelated() |
57
|
|
|
{ |
58
|
|
|
return $this->hasOne(Related::class); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
public function belongsToRelated() |
62
|
|
|
{ |
63
|
|
|
return $this->belongsTo(Related::class, 'related_id'); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
public function hasManyRelated() |
67
|
|
|
{ |
68
|
|
|
return $this->hasMany(Related::class); |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
public function belongsToManyRelated() |
72
|
|
|
{ |
73
|
|
|
return $this->belongsToMany(Related::class); |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
public function morphOneRelated() |
77
|
|
|
{ |
78
|
|
|
return $this->morphOne(Related::class, 'relatable'); |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
public function morphManyRelated() |
82
|
|
|
{ |
83
|
|
|
return $this->morphMany(Related::class, 'relatable'); |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
public function morphToManyRelated() |
87
|
|
|
{ |
88
|
|
|
return $this->morphToMany(Related::class, 'relatable'); |
89
|
|
|
} |
90
|
|
|
} |
91
|
|
|
|