Last change
on this file was d25ba66, checked in by Özkan İliyaz <iliyaz_96@…>, 4 years ago |
ADD post confirmation with multiple phases, notification after succesfully password creation
|
-
Property mode
set to
100644
|
File size:
1.0 KB
|
Line | |
---|
1 | <?php
|
---|
2 |
|
---|
3 | namespace App\Models;
|
---|
4 |
|
---|
5 | use Illuminate\Database\Eloquent\Model;
|
---|
6 |
|
---|
7 | class PostSecurity extends Model
|
---|
8 | {
|
---|
9 | protected $table = "post_securities";
|
---|
10 |
|
---|
11 | protected $fillable = [
|
---|
12 | "role_id", "phases_id"
|
---|
13 | ];
|
---|
14 |
|
---|
15 | public function role()
|
---|
16 | {
|
---|
17 | return $this->belongsTo(Role::class);
|
---|
18 | }
|
---|
19 |
|
---|
20 | public function phases($onlyNames = false)
|
---|
21 | {
|
---|
22 | $collection = collect();
|
---|
23 | $names = [];
|
---|
24 | $phase_ids = explode(",", $this->phase_ids);
|
---|
25 |
|
---|
26 | foreach ($phase_ids as $phase_id) {
|
---|
27 | $phase = Phase::findOrFail($phase_id);
|
---|
28 | array_push($names, $phase->name);
|
---|
29 | $collection->push($phase);
|
---|
30 | }
|
---|
31 |
|
---|
32 | if ($onlyNames) return implode(", ", $names);
|
---|
33 |
|
---|
34 | return $collection;
|
---|
35 | }
|
---|
36 |
|
---|
37 | public function getPhasesAttribute()
|
---|
38 | {
|
---|
39 | return $this->phases();
|
---|
40 | }
|
---|
41 |
|
---|
42 | public function getPhaseNamesAttribute()
|
---|
43 | {
|
---|
44 | return $this->phases(true);
|
---|
45 | }
|
---|
46 |
|
---|
47 | public function hasNextPhase($id)
|
---|
48 | {
|
---|
49 | return in_array($id + 1, explode(",", $this->phases_id));
|
---|
50 | }
|
---|
51 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.