Я новичок в Laravel, поэтому я еще не знаком с ошибками, которые он возвращает, я надеюсь, что кто-то может мне помочь.Нет результатов запроса для модели [Пользователь] | laravel
Так что я создал простое приложение с регистрационной формой и формой входа и зарегистрированный пользователь может опубликовать все, что он/она хочет, но я получаю эту ошибку
Это форма, где пользователь может размещать:
@section('content')
<section class="header">
<ul>
<li></li>
<li><a href="{{ URL::route('profile')}}" class="new">Back to Profile</a></li>
</ul>
</section>
<div class="newpost">
<h3>What new today?</h3><br>
<form action="{{URL::route('createPost')}}" method="post" autocomplete="off">
<div class="form-group">
<label for="title">Title</label>
<input type="text" class="form-control" id="title" name="title" placeholder="Title..." required>
</div>
<div class="form-group">
<label for="content">Write Report</label>
<textarea class="form-control" name="content" id="content" placeholder="Write Here..." rows="10"></textarea>
</div>
<button type="submit" class="btn2">Publish</button>
</form>
</div>
@stop
Это маршрут:
Route::get('/Newpost', array(
'uses' => '[email protected]',
'as' => 'newPost'
));
Route::post('/CreatePost/{id}', array(
'uses' => '[email protected]',
'as' => 'createPost'
));
and the controller
public function createPost($id)
{
$users = User::findOrFail($id);
$post = array(
'title' => Input::get('title'),
'content' => Input::get('content')
);
$posts = new Post($post);
$user->post()->save($post);
dd($post);
}
и модель пользователя, где я предполагаю, что вызывает ошибку.
<?php
use Illuminate\Auth\UserTrait;
use Illuminate\Auth\UserInterface;
use Illuminate\Auth\Reminders\RemindableTrait;
use Illuminate\Auth\Reminders\RemindableInterface;
class User extends Eloquent implements UserInterface, RemindableInterface {
use UserTrait, RemindableTrait;
/**
* The database table used by the model.
*
* @var string
*/
protected $table = 'users';
protected $fillable = array('email', 'password');
/**
* The attributes excluded from the model's JSON form.
*
* @var array
*/
protected $hidden = array('password', 'remember_token');
public function getRememberToken()
{
return $this->remember_token;
}
public function setRememberToken($value)
{
$this->remember_token = $value;
}
public function getRememberTokenName()
{
return 'remember_token';
}
public function Post()
{
return $this->hasMany('Post', 'user_id');
}
}
Может кто-нибудь объяснить мне, почему я получаю эту ошибку? Thanks
Возможно, вы захотите добавить ярлык laravel к вашему вопросу –
Какая ошибка вы получаете? – ntzm