P
P
prystapchuk-dev2021-10-28 09:56:09
Laravel
prystapchuk-dev, 2021-10-28 09:56:09

Laravel 8: How to fix a white screen on one of the site pages?

Hi all. Recently started learning Laravel. I made an elementary site that displays a list of posts. It is possible to edit the post and delete it. So on the page that displays the post deletion confirmation form, I just get a "white screen" without errors, without anything. I haven't been able to fix it for 3 hours now. I will be very grateful for your help.

The output route of the deletion confirmation form and the deletion of the post itself:

Route::get('/home/{bb}/delete', [\App\Http\Controllers\HomeController::class, 'showDeleteBbForm'])
    ->name('bb.delete');
Route::delete('/home/{bb}', [\App\Http\Controllers\HomeController::class, 'destroyBb'])
    ->name('bb.destroy');

Controller methods:
public function showDeleteBbForm(Bb $bb)
    {
      return view('bb_delete', ['bb' => $bb]);
    }

    public function destroyBb(Bb $bb)
    {
        $bb->delete();
        return redirect()->route('home');
    }


Viewing the output of all posts:
@extends('layouts.base')
@section('title', 'My posts')
@section('main')
<p class="text-right"><a href="{{ route('bb.add') }}"> Add posts</a></p>
@if(count($bbs) > 0)
    <table class="table table-striped">
        <thead>
            <tr>
                <th>Product</th>
                <th>Price</th>
                <th colspan="2">&nbsp;</th>
            </tr>
        </thead>
        <tbody>
        @foreach($bbs as $bb)
            <tr>
                <td><h3>{{ $bb->title }}</h3></td>
                <td>{{ $bb->price }}</td>
                <td>
                    <a href="{{ route('bb.edit', ['bb' => $bb->id]) }}">Edit</a>
                    <a href="{{ route('bb.delete', ['bb' => $bb->id]) }}">Delete</a>
                </td>
            </tr>
        @endforeach
        </tbody>
    </table>
@endif
@endsection


Presentation of the bb_delete.blade.php deletion confirmation form output:
@section('title', 'Delete posts :: My posts')
@section('main')
            <h2>{{ $bb->title }}</h2>
            <p>{{ $bb->content }}</p>
            <p>{{ $bb->price }} UAH</p>
            <p> Author: {{ $bb->user->name }} </p>
            <form action="{{ route('bb.destroy', ['bb' => $bb->id]) }}"
                  method="POST">
                @csrf
                @method('DELETE')
                <input type="submit" class="btn btn-danger" value="Delete">
            </form>
@endsection('main')

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Samuel_Leonardo, 2021-10-28
@prystapchuk-dev

missing layout in 2nd template

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question