简体   繁体   中英

No query results for model [App\Card]

I have the following problem:

No query results for model [App\\Card].

My Route.php :

Route::post('/cards/{card}/notes' , 'NotesController@store');

My NotesController :

public function store(Request $request)
    {
    return $request->all();
    }

And my View :

@section('content')
    <div class="row">
        <div class="col-md-6  col-md-offset-3">
            <h1>  {{  $card->title }}</h1>
            <h4>  {{  $card->created_at }}</h4>

            <ul class="list-group">
                @foreach($card->notes as $note)
                    <li class="list-group-item">{{ $note->body }}</li>
                @endforeach

            </ul>

            <hr>
            <h3>Add a New Note</h3>

            <form action="post" action="/cards/{{ $card->id }}/notes">
            <div class="form-group">
                <textarea name="body" class="form-control"></textarea>
            </div>  

            <div class="form-group">
                <button type="submit" class="btn btn-success">Add note</button>
            </div>  

            </form>
        </div>
    </div>
@stop

I have two database tables - cards and notes.

This is my route.php

Route::get('/' , 'PagesController@home');
Route::get('/about' , 'PagesController@about');

Route::get('cards' , 'CardsController@index');
Route::get('cards/{card}' , 'CardsController@show');

Route::post('/cards/{card}/notes' , 'NotesController@store');

Yes i have records in tables here is pics cards 在此处输入图片说明 Notes 在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM