requiring auth just for certain pages
This commit is contained in:
parent
b63ea93b7e
commit
c7437eb990
@ -5,13 +5,16 @@ namespace App\Http\Controllers;
|
||||
use App\Models\Post;
|
||||
use App\Models\User;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Routing\Controllers\Middleware;
|
||||
use Illuminate\Routing\Controllers\HasMiddleware;
|
||||
|
||||
class PostController extends Controller implements HasMiddleware
|
||||
{
|
||||
public static function middleware()
|
||||
{
|
||||
return ["auth"];
|
||||
return [
|
||||
new Middleware("auth", except: ["show", "index"])
|
||||
];
|
||||
}
|
||||
|
||||
public function index(User $user, Request $request)
|
||||
|
@ -26,25 +26,27 @@
|
||||
|
||||
<div class="md:w-1/2 p-5">
|
||||
<div class="shadow bg-white p-5 mb-5">
|
||||
<p class="text-xl font-bold text-center mb-4">Add a new Comment</p>
|
||||
@auth
|
||||
<p class="text-xl font-bold text-center mb-4">Add a new Comment</p>
|
||||
|
||||
<form action="#">
|
||||
@csrf
|
||||
<div class="mb-5">
|
||||
<label for="comment" class="mb-2 block uppercase text-gray-500 font-bold">Comment</label>
|
||||
<textarea id="comment" name="comment" placeholder="Add a new comment"
|
||||
class="border p-3 w-full rounded-lg @error('comment')border-red-500 @enderror"></textarea>
|
||||
<form action="#">
|
||||
@csrf
|
||||
<div class="mb-5">
|
||||
<label for="comment" class="mb-2 block uppercase text-gray-500 font-bold">Comment</label>
|
||||
<textarea id="comment" name="comment" placeholder="Add a new comment"
|
||||
class="border p-3 w-full rounded-lg @error('comment')border-red-500 @enderror"></textarea>
|
||||
|
||||
@error('comment')
|
||||
<p class="bg-red-500 text-white my-2 rounded-lg text-sm p-2 text-center">
|
||||
{{ $message }}
|
||||
</p>
|
||||
@enderror
|
||||
</div>
|
||||
@error('comment')
|
||||
<p class="bg-red-500 text-white my-2 rounded-lg text-sm p-2 text-center">
|
||||
{{ $message }}
|
||||
</p>
|
||||
@enderror
|
||||
</div>
|
||||
|
||||
<input type="submit" value="Add Comment"
|
||||
class="bg-sky-600 hover:bg-sky-700 transition-colors cursor-pointer uppercase font-bold w-full p-3 text-white rounded-lg">
|
||||
</form>
|
||||
<input type="submit" value="Add Comment"
|
||||
class="bg-sky-600 hover:bg-sky-700 transition-colors cursor-pointer uppercase font-bold w-full p-3 text-white rounded-lg">
|
||||
</form>
|
||||
@endauth
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
x
Reference in New Issue
Block a user