I'm new here. With Laravel, I want to save data with multiple selection features. however, the methods in the model file I created do not appear.I'm new to larvae, how can I fix it? I couldn't run the multiple-selection feature.
Method in controller
public function saveForm()
{
$movi_name = $req->input('movi_name');
$release_date = $req->input('release_date');
$data = array(
'movi_name' => $movi_name,
'release_date' => $release_date
);
$categories = request(categories);
$entry = Movie::insert($data) /*Model File and Save Data*/
$entry->categories()->attach($categories);
}
Method in my model file
protected $table = 'film';
public function categories()
{
return $this->belongsToMany('App\Models\Kategori', 'category_movie');
}
it should be that the selected films have to be included in the categories.. But
call to member function categories() on boolean
Sorry for bad English