1 | <?php |
||
16 | class NotificationRepository extends BaseRepository implements NotificationRepositoryInterface |
||
17 | { |
||
18 | use IncludeTopicTrait; |
||
19 | |||
20 | /** |
||
21 | * 生成一条新的 Notification. |
||
22 | * |
||
23 | * @param $attributes |
||
24 | * |
||
25 | * @return Notification |
||
26 | */ |
||
27 | public function store($attributes) |
||
28 | { |
||
29 | $notification = parent::create($attributes); |
||
|
|||
30 | User::whereId($notification->user_id)->increment('notification_count'); |
||
31 | |||
32 | return $notification; |
||
33 | } |
||
34 | |||
35 | public function includeFromUser($default_columns) |
||
36 | { |
||
37 | $available_include = Includable::make('from_user') |
||
38 | ->setDefaultColumns($default_columns) |
||
39 | ->setAllowColumns(User::$includable) |
||
40 | ->setForeignKey('from_user_id'); |
||
41 | |||
42 | app(IncludeManager::class)->add($available_include); |
||
43 | } |
||
44 | |||
45 | public function includeReply($default_columns) |
||
46 | { |
||
47 | $available_include = Includable::make('reply') |
||
48 | ->setDefaultColumns($default_columns) |
||
49 | ->setAllowColumns(User::$includable) |
||
50 | ->setForeignKey('reply_id'); |
||
51 | |||
52 | app(IncludeManager::class)->add($available_include); |
||
53 | } |
||
54 | |||
55 | /** |
||
56 | * Specify Model class name. |
||
57 | * |
||
58 | * @return string |
||
59 | */ |
||
60 | public function model() |
||
64 | |||
65 | /** |
||
66 | * Boot up the repository, pushing criteria. |
||
67 | */ |
||
68 | public function boot() |
||
72 | |||
73 | /** |
||
74 | * 用户最新的通知. |
||
75 | * |
||
76 | * @param $user_id |
||
77 | * |
||
78 | * @return $this |
||
79 | */ |
||
80 | public function userRecent($user_id) |
||
88 | } |
||
89 |
This check looks for a call to a parent method whose name is different than the method from which it is called.
Consider the following code:
The
getFirstName()
method in theSon
calls the wrong method in the parent class.