| Conditions | 3 |
| Paths | 3 |
| Total Lines | 21 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 36 | public function create($user) |
||
| 37 | { |
||
| 38 | $fromUser = Auth::user(); |
||
| 39 | $contacts = User::all(); |
||
| 40 | $threads = collect([]); |
||
| 41 | |||
| 42 | $activeThread = Thread::firstOrCreate([ |
||
| 43 | 'from_user_id' => $fromUser->id, |
||
| 44 | 'to_user_id' => $user, |
||
| 45 | ]); |
||
| 46 | |||
| 47 | if (isset($fromUser)) { |
||
| 48 | if ($fromUser->threads()->exists()) { |
||
| 49 | $threads = $fromUser->threads()->with('messages')->get(); |
||
| 50 | } |
||
| 51 | } |
||
| 52 | |||
| 53 | $threads = collect([$activeThread])->merge($threads); |
||
| 54 | |||
| 55 | return view('vendor.messenger.index', compact('threads', 'activeThread', 'contacts')); |
||
| 56 | } |
||
| 57 | |||
| 72 |
Since your code implements the magic getter
_get, this function will be called for any read access on an undefined variable. You can add the@propertyannotation to your class or interface to document the existence of this variable.If the property has read access only, you can use the @property-read annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
See also the PhpDoc documentation for @property.