PHP code example of shomisha / unusual-relationships
1. Go to this page and download the library: Download shomisha/unusual-relationships library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
shomisha / unusual-relationships example snippets
class Employee extends Model {
public function tasks()
{
return $this->belongsToMany(Task::class);
}
public function boss()
{
return $this->belongsTo(Boss::class);
}
}
class Boss extends Model {
use Shomisha\UnusualRelationships\HasUnusualRelationships;
public function employees()
{
return $this->hasMany(Employee::class);
}
public function tasks()
{
return $this->belongsToManyThrough(Task::class, Employee::class)
}
}