@@ -8,10 +8,10 @@ discard block |
||
8 | 8 | |
9 | 9 | class PostController extends Controller { |
10 | 10 | |
11 | - /** |
|
12 | - * Saves a new post to the database |
|
13 | - */ |
|
14 | - public function store(Request $request) { |
|
11 | + /** |
|
12 | + * Saves a new post to the database |
|
13 | + */ |
|
14 | + public function store(Request $request) { |
|
15 | 15 | // ... |
16 | 16 | // validation can be done here before saving |
17 | 17 | // with $this->validate($request, $rules) |
@@ -30,5 +30,5 @@ discard block |
||
30 | 30 | |
31 | 31 | // return post as response, Laravel automatically serializes this to JSON |
32 | 32 | return response($post, 201); |
33 | - } |
|
33 | + } |
|
34 | 34 | } |
@@ -18,7 +18,7 @@ |
||
18 | 18 | // ... |
19 | 19 | |
20 | 20 | // get data to save in an associative array using $request->only() |
21 | - $data = $request->only(['title', 'description']); |
|
21 | + $data = $request->only([ 'title', 'description' ]); |
|
22 | 22 | |
23 | 23 | // save post and assign return value of created post to $post array |
24 | 24 | $post = Post::create($data); |