Navigation | Overlay |
---|---|
t Navigate files | h Toggle hits |
y Change url to tip of branch | m Toggle misses |
b / v Jump to prev/next hit line | p Toggle partial |
z / x Jump to prev/next missed or partial line | 1..9 Toggle flags |
shift + o Open current page in GitHub | a Toggle all on |
/ or ? Show keyboard shortcuts dialog | c Toggle context lines or commits |
1 |
<?php
|
|
2 |
|
|
3 |
namespace Igaster\ModelEvents\Traits; |
|
4 |
|
|
5 |
|
|
6 |
use Igaster\ModelEvents\LogModelEvent; |
|
7 |
|
|
8 |
/**
|
|
9 |
* Note: This trait is Optional
|
|
10 |
* Add this trait to the User Model to enable querying logged events for for a user model
|
|
11 |
*/
|
|
12 |
|
|
13 |
trait UserLogsModelEvents |
|
14 |
{
|
|
15 |
|
|
16 | 1 |
public function modelEvents() |
17 |
{
|
|
18 | 1 |
return $this->hasMany(LogModelEvent::class,'user_id'); |
19 |
}
|
|
20 |
|
|
21 | 1 |
public function getUserModelEvents($count = 0) |
22 |
{
|
|
23 | 1 |
$query = $this->modelEvents()->orderBy('id', 'desc'); |
24 | 1 |
if($count) { |
25 | 1 |
$query->limit($count); |
26 |
}
|
|
27 | 1 |
return $query->get(); |
28 |
}
|
|
29 |
|
|
30 |
}
|
Read our documentation on viewing source code .