:3
This commit is contained in:
24
resources/views/posts/create.blade.php
Normal file
24
resources/views/posts/create.blade.php
Normal file
@ -0,0 +1,24 @@
|
||||
@extends('layouts.app')
|
||||
|
||||
@section('content')
|
||||
<div class="container">
|
||||
<h1>Create New Post</h1>
|
||||
|
||||
<form method="POST" action="{{ route('posts.store') }}">
|
||||
@csrf
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Title</label>
|
||||
<input type="text" name="title" class="form-control" required>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Content</label>
|
||||
<textarea name="content" class="form-control" rows="5" required></textarea>
|
||||
</div>
|
||||
|
||||
<button class="btn btn-success">Save</button>
|
||||
<a href="{{ route('posts.index') }}" class="btn btn-secondary">Cancel</a>
|
||||
</form>
|
||||
</div>
|
||||
@endsection
|
24
resources/views/posts/edit.blade.php
Normal file
24
resources/views/posts/edit.blade.php
Normal file
@ -0,0 +1,24 @@
|
||||
@extends('layouts.app')
|
||||
|
||||
@section('content')
|
||||
<div class="container">
|
||||
<h1>Edit Post</h1>
|
||||
|
||||
<form method="POST" action="{{ route('posts.update', $post->id) }}">
|
||||
@csrf @method('PUT')
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Title</label>
|
||||
<input type="text" name="title" class="form-control" value="{{ $post->title }}" required>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Content</label>
|
||||
<textarea name="content" class="form-control" rows="5" required>{{ $post->content }}</textarea>
|
||||
</div>
|
||||
|
||||
<button class="btn btn-success">Update</button>
|
||||
<a href="{{ route('posts.index') }}" class="btn btn-secondary">Cancel</a>
|
||||
</form>
|
||||
</div>
|
||||
@endsection
|
41
resources/views/posts/index.blade.php
Normal file
41
resources/views/posts/index.blade.php
Normal file
@ -0,0 +1,41 @@
|
||||
@extends('layouts.app')
|
||||
|
||||
@section('content')
|
||||
<div class="container">
|
||||
<h1>Posts</h1>
|
||||
|
||||
<a href="{{ route('posts.create') }}" class="btn btn-primary mb-3">Create New Post</a>
|
||||
|
||||
@if(session('success'))
|
||||
<div class="alert alert-success">{{ session('success') }}</div>
|
||||
@endif
|
||||
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Title</th>
|
||||
<th>Content (preview)</th>
|
||||
<th>Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@forelse($posts as $post)
|
||||
<tr>
|
||||
<td>{{ $post->title }}</td>
|
||||
<td>{{ \Illuminate\Support\Str::limit($post->content, 50) }}</td>
|
||||
<td>
|
||||
<a href="{{ route('posts.show', $post->id) }}" class="btn btn-sm btn-info">View</a>
|
||||
<a href="{{ route('posts.edit', $post->id) }}" class="btn btn-sm btn-warning">Edit</a>
|
||||
<form action="{{ route('posts.destroy', $post->id) }}" method="POST" style="display:inline-block">
|
||||
@csrf @method('DELETE')
|
||||
<button class="btn btn-sm btn-danger" onclick="return confirm('Delete this post?')">Delete</button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
@empty
|
||||
<tr><td colspan="3">No posts found.</td></tr>
|
||||
@endforelse
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
@endsection
|
14
resources/views/posts/show.blade.php
Normal file
14
resources/views/posts/show.blade.php
Normal file
@ -0,0 +1,14 @@
|
||||
@extends('layouts.app')
|
||||
|
||||
@section('content')
|
||||
<div class="container">
|
||||
<h1>{{ $post->title }}</h1>
|
||||
|
||||
<div class="mb-4">
|
||||
<p>{{ $post->content }}</p>
|
||||
</div>
|
||||
|
||||
<a href="{{ route('posts.edit', $post->id) }}" class="btn btn-warning">Edit</a>
|
||||
<a href="{{ route('posts.index') }}" class="btn btn-secondary">Back</a>
|
||||
</div>
|
||||
@endsection
|
Reference in New Issue
Block a user