Laravel relationship: one function to the different tables
Instead of this:
public function words()
    {
        return $this->belongsToMany('App\Word', definition_word)->withTimestamps();
    }
Use this: With a variable
$table
we can use
words()
function to the different tables.
public function words($table = null)
    {
        return $this->belongsToMany('App\Word', $table)->withTimestamps();
    }
by Luka Tatarishvili
4 years ago
Laravel
relationships
0
Pro tip: use ```triple backticks around text``` to write in code fences