1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Reedware\LaravelBlueprints\Concerns; |
4
|
|
|
|
5
|
|
|
trait SoftDeletesBy |
6
|
|
|
{ |
7
|
|
|
/** |
8
|
|
|
* Alias of {@see $this->deletedBy()}. |
9
|
|
|
* |
10
|
|
|
* @param string $table |
11
|
|
|
* @param string|null $local |
12
|
|
|
* @param string|null $name |
13
|
|
|
* @param string|null $onUpdate |
14
|
|
|
* @param string|null $onDelete |
15
|
|
|
* |
16
|
|
|
* @return \Illuminate\Support\Fluent |
17
|
|
|
*/ |
18
|
|
|
public function softDeletesBy($table = null, $local = null, $name = null, $onUpdate = null, $onDelete = null) |
19
|
|
|
{ |
20
|
|
|
return $this->deletedBy($table, $local, $name, $onUpdate, $onDelete); |
21
|
|
|
} |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* Alias of {@see $this->deletedByMorph()}. |
25
|
|
|
* |
26
|
|
|
* @param string|null $indexName |
27
|
|
|
* |
28
|
|
|
* @return \Illuminate\Support\Fluent |
29
|
|
|
*/ |
30
|
|
|
public function softDeletesByMorph($indexName = null) |
31
|
|
|
{ |
32
|
|
|
return $this->deletedByMorph($indexName); |
|
|
|
|
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* Alias of {@see $this->bigDeletedBy()}. |
37
|
|
|
* |
38
|
|
|
* @param string $table |
39
|
|
|
* @param string|null $local |
40
|
|
|
* @param string|null $name |
41
|
|
|
* @param string|null $onUpdate |
42
|
|
|
* @param string|null $onDelete |
43
|
|
|
* |
44
|
|
|
* @return \Illuminate\Support\Fluent |
45
|
|
|
*/ |
46
|
|
|
public function bigSoftDeletesBy($table = null, $local = null, $name = null, $onUpdate = null, $onDelete = null) |
47
|
|
|
{ |
48
|
|
|
return $this->bigDeletedBy($table, $local, $name, $onUpdate, $onDelete); |
|
|
|
|
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* Alias of {@see $this->bigDeletedByMorph()}. |
53
|
|
|
* |
54
|
|
|
* @param string|null $indexName |
55
|
|
|
* |
56
|
|
|
* @return \Illuminate\Support\Fluent |
57
|
|
|
*/ |
58
|
|
|
public function bigSoftDeletesByMorph($indexName = null) |
59
|
|
|
{ |
60
|
|
|
return $this->bigDeletedByMorph($indexName); |
|
|
|
|
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* Adds the 'deleted_by_id' Reference. |
65
|
|
|
* |
66
|
|
|
* @param string $table |
67
|
|
|
* @param string|null $local |
68
|
|
|
* @param string|null $name |
69
|
|
|
* @param string|null $onUpdate |
70
|
|
|
* @param string|null $onDelete |
71
|
|
|
* |
72
|
|
|
* @return \Illuminate\Support\Fluent |
73
|
|
|
*/ |
74
|
|
|
public function deletedBy($table = null, $local = null, $name = null, $onUpdate = null, $onDelete = null) |
75
|
|
|
{ |
76
|
|
|
// Determine the Table |
77
|
|
|
if(is_null($table)) { |
78
|
|
|
$table = $this->getTimestampsByTable(); |
|
|
|
|
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
// Create the Belongs to Relation |
82
|
|
|
return $this->belongsTo($table, 'deleted_by_id', $local, $name, $onUpdate, $onDelete)->nullable(); |
|
|
|
|
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
/** |
86
|
|
|
* Adds the 'deleted_by_id' Morph Reference. |
87
|
|
|
* |
88
|
|
|
* @param string|null $indexName |
89
|
|
|
* |
90
|
|
|
* @return void |
91
|
|
|
*/ |
92
|
|
|
public function deletedByMorph($indexName = null) |
93
|
|
|
{ |
94
|
|
|
// Create the 'deleted_by_id' Morph Column |
95
|
|
|
$this->belongsToColumn('deleted_by_id')->nullable(); |
|
|
|
|
96
|
|
|
|
97
|
|
|
// Create the 'deleted_by_type' Morph Column |
98
|
|
|
$this->string('deleted_by_type', 255)->nullable(); |
|
|
|
|
99
|
|
|
|
100
|
|
|
// Index the two Columns |
101
|
|
|
$this->index(['deleted_by_id', 'deleted_by_type'], $indexName); |
|
|
|
|
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
/** |
105
|
|
|
* Adds the 'deleted_by_id' Reference. |
106
|
|
|
* |
107
|
|
|
* @param string $table |
108
|
|
|
* @param string|null $local |
109
|
|
|
* @param string|null $name |
110
|
|
|
* @param string|null $onUpdate |
111
|
|
|
* @param string|null $onDelete |
112
|
|
|
* |
113
|
|
|
* @return void |
114
|
|
|
*/ |
115
|
|
|
public function bigDeletedBy($table = null, $local = null, $name = null, $onUpdate = null, $onDelete = null) |
116
|
|
|
{ |
117
|
|
|
// Determine the Table |
118
|
|
|
if(is_null($table)) { |
119
|
|
|
$table = $this->getTimestampsByTable(); |
120
|
|
|
} |
121
|
|
|
|
122
|
|
|
// Create the Belongs to Relation |
123
|
|
|
return $this->bigBelongsTo($table, 'deleted_by_id', $local, $name, $onUpdate, $onDelete)->nullable(); |
|
|
|
|
124
|
|
|
} |
125
|
|
|
|
126
|
|
|
/** |
127
|
|
|
* Adds the 'deleted_by_id' Morph Reference. |
128
|
|
|
* |
129
|
|
|
* @param string|null $indexName |
130
|
|
|
* |
131
|
|
|
* @return void |
132
|
|
|
*/ |
133
|
|
|
public function bigDeletedByMorph($indexName = null) |
134
|
|
|
{ |
135
|
|
|
// Create the 'deleted_by_id' Morph Column |
136
|
|
|
$this->bigBelongsToColumn('deleted_by_id')->nullable(); |
|
|
|
|
137
|
|
|
|
138
|
|
|
// Create the 'deleted_by_type' Morph Column |
139
|
|
|
$this->string('deleted_by_type', 255)->nullable(); |
140
|
|
|
|
141
|
|
|
// Index the two Columns |
142
|
|
|
$this->index(['deleted_by_id', 'deleted_by_type'], $indexName); |
143
|
|
|
} |
144
|
|
|
} |
This check looks for function or method calls that always return null and whose return value is used.
The method
getObject()
can return nothing but null, so it makes no sense to use the return value.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.