agregada la opcion de published a los posts

This commit is contained in:
Daniel Cortés
2019-10-17 08:00:53 -03:00
parent 877477503c
commit 2fcbf51071
8 changed files with 49 additions and 2 deletions

View File

@@ -9,8 +9,11 @@ class BlogController extends Controller
{
public function index()
{
$posts = Post::where('is_published', true)
->orderBy('created_at', 'desc')
->take(3)
->get();
$posts = Post::orderBy('created_at', 'desc')->take(3)->get();
return view('blog.index', ['posts' => $posts] );
}

View File

@@ -21,6 +21,7 @@ class PostController extends Controller
$post = new Post();
$post->title = $request->title;
$post->md = $request->md;
$post->is_published = $request->has('published');
$post->save();
return redirect()->route('admin.post.index');
@@ -41,6 +42,7 @@ class PostController extends Controller
$post->title = $request->title;
$post->md = $request->md;
$post->is_published = $request->has('published');
$post->update();
return redirect()->route('admin.post.index');