Artist.php 524 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
<?php

namespace App\Models;

use App\Helpers\Constants;
use Illuminate\Database\Eloquent\Model;

class Artist extends Model
{
    protected $table = Constants::TABLE_ARTISTS;

    /**
     * Hàm lấy ds bài hát của 1 ca sĩ
     *
     * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
     */
    public function tracks()
    {
        return $this->belongsToMany(
            'App\Models\Track',
            Constants::TABLE_TRACKS,
            'artist_id',
            'track_id'
        );
    }

}