mirror of
https://github.com/rico-vz/HeimerdingerLoL.git
synced 2025-12-06 18:20:48 +01:00
feat: Add PostsController and configure routes
- Added a new file `PostsController.php` in the `app/Http/Controllers` directory.
- Implemented the `index()` method to retrieve all posts using the Sheets facade.
- Implemented the `show()` method to display a single post using route model binding with Sheets.
- Updated the `RouteServiceProvider.php` file to bind the 'post' route parameter to retrieve posts from the Sheets collection.
- Created a new configuration file `sheets.php` in the `config` directory, defining default settings for collections and their corresponding sheet classes, path parsers, content parsers, and extensions.
- Added a new markdown file `hello-world.md` in the `content/posts` directory as an example post.
- Created two new blade view files: `index.blade.php` and `show.blade.php`, under the `resources/views/posts` directory, for displaying lists of posts and individual post details respectively.
- Modified the existing web routes (`web.php`) to include routes for accessing posts.
The changes enable users to view all posts on `/posts`, as well as access individual post details at `/post/{post}`.
This commit is contained in:
22
app/Http/Controllers/PostsController.php
Normal file
22
app/Http/Controllers/PostsController.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Spatie\Sheets\Facades\Sheets;
|
||||
use Spatie\Sheets\Sheet;
|
||||
|
||||
class PostsController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
$posts = Sheets::all();
|
||||
|
||||
return view('posts.index', compact('posts'));
|
||||
}
|
||||
|
||||
public function show(Sheet $post)
|
||||
{
|
||||
dd($post);
|
||||
return view('posts.show', compact('post'));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user