I'm not having much luck tying to get past the following error
BadMethodCallException in Builder.php
Call to undefined method Illuminate\Database\Query\Builder::posts()
The project I'm working on is a simple timeline for a social network. Although I'm stuck when calling the following route (creating a post)
Route::group(['middleware' => ['web', 'auth']], function () {
Route::get('home', 'TimelineController@index');
Route::post('/posts', 'PostController@create');
});
POST returns the 500 error I specified above. A quick search for the "unimplemented" method post() returns:
Searching 5094 files for "posts()"
C:\Users\Administrator\Code\instyle\app\User.php:
16 ];
17
18: public function posts()
19 {
20 return $this->hasMany('Instyle\Post');
C:\Users\Administrator\Code\instyle\app\Http\Controllers \PostController.php:
17 ]);
18
19: $createdPost = $request->user()->posts()->create([
20 'body' => $request->body,
21 ]);
Since I'm having trouble pinpointing this error I'll happily elaborate on any file you require. Thanks!
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire