私は私のアプリで登録したユーザとの投稿を公開しようとしているが、このエラーが起こった: 列は、SQL laravelには見られない5.4
をそして、私はXAMPPを使用していて、私の記事の表は、この絵 です
マイPostController
は次のとおりです。
use App\Post;
class PostsController extends Controller
{
public function __construct()
{
$this->middleware('auth')->except(['index','show']);
}
public function index()
{
$posts=Post::latest()->get();
return view('posts.index',compact('posts'));
}
public function show(Post $post)
{
return view('posts.show',compact('post'));
}
public function create()
{
return view('posts.create');
}
public function store()
{
$this->validate(request(),[
'title'=>'required',
'body' => 'required|min:5'
]);
Post::create(request([
'title' => request('title'),
'body' => request('body'),
'user_id' =>auth()->id()
//auth()->user()->id*/
]));
return redirect()->home;
}
}
とPostモデル:
class Post extends Model
{
public function comments()
{
return $this->hasMany(Comment::class);
}
public function user()
{
return $this->belongsTo(User::class);
}
}
解析に役立つLaravelコード(Model + Controller)を表示できますか? –
@NapoleãoWingertはい私は私の質問を編集しました。 –