-3
我開始學習Laravel,當他創建一篇新文章時,我想將當前用戶(已登錄)添加到我的發佈數據表中。我跟蹤了一些youtube視頻,但我現在沒有完全檢查我的表單發送的數據或如何查找用戶名數據?我如何在Laravel中調試表單或會話數據?如何檢查Laravel中的數據?
我的遷移文件:
public function up()
{
Schema::create('role_user', function (Blueprint $table) {
$table->increments('id');
$table->string('title');
$table->string('author');
$table->integer('role_id')->unsigned(); $table->timestamps();
});
}
我PostController.php:
public function store(Request $request)
{
$post = new Post([
'title' => $request->get('title'),
'post' => $request->get('post'),
'author' => ???
]);
$post->save();
return redirect('/post');
}
如何獲得當前用戶,這是在記錄並存儲在我的數據庫信息?作者匹配我用戶表的ID。
發佈您的代碼更加具體 –
https://laracasts.com/series/laravel-from-scratch-2017 –
@SR_我編輯上面的代碼! – weristsam