| Conditions | 3 |
| Paths | 3 |
| Total Lines | 26 |
| Code Lines | 16 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 21 | public function store(Request $request) |
||
| 22 | { |
||
| 23 | if (!$request->wantsJson()) { |
||
| 24 | return response("Contacts can only be created via json requests", 400); |
||
| 25 | } |
||
| 26 | |||
| 27 | $validator = Validator::make($request->all(), [ |
||
| 28 | 'name' => 'required|max:255', |
||
| 29 | 'email' => 'required|email|max:255', |
||
| 30 | 'filter_tags' => 'max:255', |
||
| 31 | ]); |
||
| 32 | |||
| 33 | if ($validator->fails()) { |
||
| 34 | return response($validator->getMessageBag(), 422); |
||
| 35 | } |
||
| 36 | |||
| 37 | $contact = new Contact; |
||
| 38 | $contact->name = $request->get('name'); |
||
| 39 | $contact->email = $request->get('email'); |
||
| 40 | $contact->filter_tags = $request->get('filter_tags'); |
||
| 41 | $contact->active = true; |
||
| 42 | $contact->save(); |
||
| 43 | |||
| 44 | //Re-fetch so we have a full record |
||
| 45 | return Contact::findOrFail($contact->id); |
||
|
|
|||
| 46 | } |
||
| 47 | |||
| 55 |
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.