class Comment extends Model
{
protected $fillabele = ['body','user_id','discussion_id'];
public function user()
{
return $this->belongsTo(User::class);
}
public function discussion()
{
return $this->belongsTo(Dicussion::class);
}
}
class CommentsController extends Controller
{
public function store(Requests\PostCommentRequest $request)
{
dd($request->all());
Comment::create(array_merge($request->all(),['user_id' => \Auth::user()->id]));
return redirect()->action('PostsController@show',['id' => '2']);
}
}
在这里create 页面报__token