1 | <?php |
||
2 | |||
3 | namespace Pratiksh\Adminetic\Traits; |
||
4 | |||
5 | use Illuminate\Support\Facades\Cache; |
||
6 | use Pratiksh\Adminetic\Models\Admin\Profile; |
||
7 | use Spatie\Activitylog\LogOptions; |
||
8 | use Spatie\Activitylog\Traits\LogsActivity; |
||
9 | |||
10 | /** |
||
11 | * Adminetic User. |
||
12 | */ |
||
13 | trait AdmineticUser |
||
14 | { |
||
15 | use HasPreference, HasRole, HasSlack, LogsActivity; |
||
16 | |||
17 | // Forget cache on updating or saving and deleting |
||
18 | public static function boot() |
||
19 | { |
||
20 | parent::boot(); |
||
21 | |||
22 | static::saving(function () { |
||
23 | self::cacheKey(); |
||
24 | }); |
||
25 | |||
26 | static::deleting(function () { |
||
27 | self::cacheKey(); |
||
28 | }); |
||
29 | } |
||
30 | |||
31 | // Cache Keys |
||
32 | private static function cacheKey() |
||
33 | { |
||
34 | Cache::has('users') ? Cache::forget('users') : ''; |
||
35 | } |
||
36 | |||
37 | // Logs |
||
38 | protected static $logName = 'user'; |
||
39 | |||
40 | public function getActivitylogOptions(): LogOptions |
||
41 | { |
||
42 | return LogOptions::defaults(); |
||
43 | } |
||
44 | |||
45 | // Relations |
||
46 | |||
47 | public function profile() |
||
48 | { |
||
49 | return $this->hasOne(Profile::class); |
||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||
50 | } |
||
51 | } |
||
52 |