You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

61 lines
1.2 KiB
PHTML

<?php
namespace App\Http\Controllers;
use App\Http\Requests\StorePostRequest;
use App\Models\BlogPost;
use Illuminate\Http\Request;
class PostController extends Controller
{
public function __construct()
{
$this->middleware('auth')->except('show');
}
public function index()
{
//todo: change this to overview of blog posts for blog post. Add admin method for mgmt
return view('posts.index', [
'posts' => BlogPost::all()->reverse()
]);
}
public function create()
{
return view('posts.create');
}
public function store(StorePostRequest $request)
{
$validated = $request->validated();
BlogPost::create([
'title' => $validated['title'],
'content' => $validated['content'],
'location' => $validated['location'],
]);
return redirect()->route('posts.index');
}
public function show($id)
{
return view('posts.show', [
'post' => BlogPost::find($id)
]);
}
public function edit($id)
{
}
public function update(Request $request, $id)
{
}
public function destroy($id)
{
}
}