many-to-many relationship – save data - development

many-to-many relationship – save data

I made relationship between Film and Performer model.
Into Films model:

  public function Performers(){
    return $this->belongsToMany('AppPerformer');
  }

Into Performer model

public function Films(){
  return $this->belongsToMany('AppFilms');
}

I created table films_performer and relationship works, if I would add data manually. I hove w problem with save data into film_performer after send form. Into controller I attach it.

$film->performers()->attach($request->performers);

I don’t have any errors. I used dd($request to check array performers and everything is ok)larave



from Laravel Questions and Answers https://laravelquestions.com/php/many-to-many-relationship-save-data/
via Lzo Media

Comments

Popular posts from this blog

ng-show doesn’t work correct with value boolean

ng-include of inline SVG does not display gradient except in Chrome

Using PHP and MySQL data to generate PDF letters like in MS Word mailmerge functionality - development