Save form data in laravel

前端 未结 1 1692
悲哀的现实
悲哀的现实 2020-12-31 19:02

Right now I have a form with gender, options and user_id. My public function store (Request $request) looks like this :

public function store(Re         


        
相关标签:
1条回答
  • 2020-12-31 19:44

    You can use mass assignment feature by using create() method:

    public function store(Request $request)
    {
        Appointment::create($request->all());
    }
    

    Don't forget to fill all columns in $fillable array in Appointment model:

    protected $fillable = ['gender', 'options', 'user_id', 'another_one'];
    
    0 讨论(0)
提交回复
热议问题