@@ 46-64 (lines=19) @@ | ||
43 | * |
|
44 | * @return \Illuminate\Http\RedirectResponse |
|
45 | */ |
|
46 | public function store(PostFormRequest $request) |
|
47 | { |
|
48 | $post = new Post(); |
|
49 | $post->title = $request->title; |
|
50 | $post->slug = str_slug($request->title); |
|
51 | $post->category_id = $request->category; |
|
52 | $post->published_at = Carbon::createFromFormat('Y-m-d\TH:i', $request->published_at); |
|
53 | $post->featured = $request->has('featured'); |
|
54 | $post->visible = $request->has('visible'); |
|
55 | $post->body = $request->body; |
|
56 | ||
57 | $post->save(); |
|
58 | ||
59 | $post->syncTags($request->tags); |
|
60 | ||
61 | Notificator::success('Post created successfully'); |
|
62 | ||
63 | return redirect()->route('backend.posts.edit', $post); |
|
64 | } |
|
65 | ||
66 | /** |
|
67 | * Show the form for editing the specified resource. |
|
@@ 86-103 (lines=18) @@ | ||
83 | * |
|
84 | * @return \Illuminate\Http\RedirectResponse |
|
85 | */ |
|
86 | public function update(PostFormRequest $request, Post $post) |
|
87 | { |
|
88 | $post->title = $request->title; |
|
89 | $post->slug = str_slug($request->title); |
|
90 | $post->category_id = $request->category; |
|
91 | $post->published_at = Carbon::createFromFormat('Y-m-d\TH:i', $request->published_at); |
|
92 | $post->featured = $request->has('featured'); |
|
93 | $post->visible = $request->has('visible'); |
|
94 | $post->body = $request->body; |
|
95 | ||
96 | $post->save(); |
|
97 | ||
98 | $post->syncTags($request->tags); |
|
99 | ||
100 | Notificator::success('Post edited successfully'); |
|
101 | ||
102 | return redirect()->route('backend.posts.edit', $post); |
|
103 | } |
|
104 | ||
105 | /** |
|
106 | * Remove the specified resource from storage. |