1 | <?php namespace Arcanedev\LaravelMessenger\Traits; |
||
18 | trait Messagable |
||
19 | { |
||
20 | /* ------------------------------------------------------------------------------------------------ |
||
21 | | Traits |
||
22 | | ------------------------------------------------------------------------------------------------ |
||
23 | */ |
||
24 | use ConfigHelper; |
||
25 | |||
26 | /* ------------------------------------------------------------------------------------------------ |
||
27 | | Relationships |
||
28 | | ------------------------------------------------------------------------------------------------ |
||
29 | */ |
||
30 | /** |
||
31 | * Thread relationship. |
||
32 | * |
||
33 | * @return \Illuminate\Database\Eloquent\Relations\belongsToMany |
||
34 | */ |
||
35 | public function discussions() |
||
44 | |||
45 | /** |
||
46 | * Participants relationship. |
||
47 | * |
||
48 | * @return \Illuminate\Database\Eloquent\Relations\HasMany |
||
49 | */ |
||
50 | public function participants() |
||
56 | |||
57 | /** |
||
58 | * Message relationship. |
||
59 | * |
||
60 | * @return \Illuminate\Database\Eloquent\Relations\HasMany |
||
61 | */ |
||
62 | public function messages() |
||
68 | |||
69 | /* ------------------------------------------------------------------------------------------------ |
||
70 | | Main Functions |
||
71 | | ------------------------------------------------------------------------------------------------ |
||
72 | */ |
||
73 | /** |
||
74 | * Returns the new messages count for user. |
||
75 | * |
||
76 | * @return int |
||
77 | */ |
||
78 | public function newMessagesCount() |
||
82 | |||
83 | /** |
||
84 | * Returns all discussions IDs with new messages. |
||
85 | * |
||
86 | * @return array |
||
87 | */ |
||
88 | public function discussionsWithNewMessages() |
||
107 | } |
||
108 |
This check looks for methods that are used by a trait but not required by it.
To illustrate, let’s look at the following code example
The trait
Idable
provides a methodequalsId
that in turn relies on the methodgetId()
. If this method does not exist on a class mixing in this trait, the method will fail.Adding the
getId()
as an abstract method to the trait will make sure it is available.