mirror of
https://github.com/Aviortheking/CA_LARAVEL.git
synced 2025-06-19 12:29:19 +00:00
add seeder for post & routing for list of post
This commit is contained in:
@ -4,6 +4,8 @@ namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
use DB;
|
||||
|
||||
class HomeController extends Controller
|
||||
{
|
||||
/**
|
||||
@ -13,7 +15,7 @@ class HomeController extends Controller
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('auth');
|
||||
// $this->middleware('auth');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -33,4 +35,10 @@ class HomeController extends Controller
|
||||
return view('adminHome');
|
||||
|
||||
}
|
||||
public function blog() {
|
||||
|
||||
$posts = DB::table('posts')->get();
|
||||
|
||||
return view('blog', ['posts' => $posts]);
|
||||
}
|
||||
}
|
||||
|
14
app/Post.php
Normal file
14
app/Post.php
Normal file
@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Post extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'title', 'content'
|
||||
];
|
||||
|
||||
protected $table = 'posts';
|
||||
}
|
Reference in New Issue
Block a user