Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 7 |
|
0.00% |
0 / 7 |
CRAP | |
0.00% |
0 / 1 |
| SharesShortcut | |
0.00% |
0 / 7 |
|
0.00% |
0 / 7 |
56 | |
0.00% |
0 / 1 |
| setSharedWithOthersAttribute | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getSharedWithOthersAttribute | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getAddedToFlycutsAttribute | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| flyshare | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| user | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| sharer | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| shortcutAdded | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace App\Http\Models; |
| 4 | |
| 5 | use App\Http\Models\Auth\User; |
| 6 | use App\Http\Scopes\UserScope; |
| 7 | |
| 8 | class SharesShortcut extends Moloquent |
| 9 | { |
| 10 | /** |
| 11 | * The attributes that are mass assignable. |
| 12 | * |
| 13 | * @var array |
| 14 | */ |
| 15 | protected $fillable = [ |
| 16 | 'user_id', 'shortcut', |
| 17 | ]; |
| 18 | |
| 19 | /** |
| 20 | * The table associated with the model. |
| 21 | * |
| 22 | * @var string |
| 23 | */ |
| 24 | protected $table = 'shares_shortcuts'; |
| 25 | |
| 26 | /** |
| 27 | * The accessors to append to the model's array form. |
| 28 | * |
| 29 | * @var array |
| 30 | */ |
| 31 | protected $appends = ['shared_with_others', 'added_to_flycuts']; |
| 32 | |
| 33 | /** |
| 34 | * Set the shared_with_others attribute. |
| 35 | */ |
| 36 | public function setSharedWithOthersAttribute(string $value): void |
| 37 | { |
| 38 | $this->attributes['shared_with_others'] = false; |
| 39 | } |
| 40 | |
| 41 | /** |
| 42 | * Get the shared_with_others atrribute for the shortcut. |
| 43 | */ |
| 44 | public function getSharedWithOthersAttribute(): bool |
| 45 | { |
| 46 | return false; |
| 47 | } |
| 48 | |
| 49 | /** |
| 50 | * Determine if the flyshare has a corresponding shortcut added as. |
| 51 | */ |
| 52 | public function getAddedToFlycutsAttribute(): bool |
| 53 | { |
| 54 | return filled($this->shortcutAdded); |
| 55 | } |
| 56 | |
| 57 | /** |
| 58 | * Get the flyshare that belongs to the shortcut shared with the user. |
| 59 | */ |
| 60 | public function flyshare() |
| 61 | { |
| 62 | return $this->belongsTo(FlyShare::class); |
| 63 | } |
| 64 | |
| 65 | /** |
| 66 | * Get the user that the shortcut was shared with |
| 67 | * |
| 68 | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
| 69 | */ |
| 70 | public function user() |
| 71 | { |
| 72 | return $this->belongsTo(User::class); |
| 73 | } |
| 74 | |
| 75 | /** |
| 76 | * Get the user that shared the shortcut |
| 77 | * |
| 78 | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
| 79 | */ |
| 80 | public function sharer() |
| 81 | { |
| 82 | return $this->belongsTo(User::class); |
| 83 | } |
| 84 | |
| 85 | /** |
| 86 | * Get the shortcut this flyshare was added as |
| 87 | * |
| 88 | * @return \Illuminate\Database\Eloquent\Relations\HasOne |
| 89 | */ |
| 90 | public function shortcutAdded() |
| 91 | { |
| 92 | return $this->hasOne(Shortcut::class, 'reference_shares_shortcut_id')->withoutGlobalScope(UserScope::class); |
| 93 | } |
| 94 | } |