agregada la opcion de published a los posts
This commit is contained in:
@@ -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] );
|
||||
}
|
||||
|
||||
|
||||
@@ -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');
|
||||
|
||||
Reference in New Issue
Block a user