From 67c377fe1d87bfb127bcbfa952e9119bd341d4e8 Mon Sep 17 00:00:00 2001 From: Zach DeCook Date: Thu, 27 Dec 2018 01:05:36 -0500 Subject: * Playlists: Set up many to many relationship --- laravel/app/Playlist.php | 14 ++++++++++++++ laravel/app/Song.php | 5 ++++- 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 laravel/app/Playlist.php (limited to 'laravel/app') diff --git a/laravel/app/Playlist.php b/laravel/app/Playlist.php new file mode 100644 index 0000000..7284b0e --- /dev/null +++ b/laravel/app/Playlist.php @@ -0,0 +1,14 @@ +belongsToMany('App\Song'); + } +} diff --git a/laravel/app/Song.php b/laravel/app/Song.php index 876617f..0565ff6 100644 --- a/laravel/app/Song.php +++ b/laravel/app/Song.php @@ -7,5 +7,8 @@ use Illuminate\Database\Eloquent\Model; class Song extends Model { public $fillable = ['number', 'title', 'author', 'key', 'text']; - // + public function playlists() + { + return $this->belongsToMany('App\Playlist'); + } } -- cgit 1.4.1