class User extends Model
{
/**
* The roles that belong to the user.
*/
public function roles()
{
return $this->belongsToMany('App\Role');
}
}
$roles = App\User::find(1)->roles()->orderBy('name')->get();
id
name
id_user
id
name
id_user
direction_id
execute_id
class Direction extends Model
{
protected $table = 'direction';
protected $fillable = ['id_user', 'name'];
public function executes()
{
return $this->hasManyThrough('App\Execute', 'App\Execute_direction');
}
}
class Execute_direction extends Model
{
protected $table = 'execute_direction';
protected $fillable = ['direction_id', 'execute_id'];
public $timestamps = false;
public function execute()
{
return $this->hasOne('App\Execute');
}
}
Auth::user()->executes
В моем случае$directions = Direction::where('id_user', Auth::user()->id)->executes()->get();
foreach ($directions as $value){
$execute[] = $value->name;
foreach (Direction::find($value->id)->executes()->get() as $item){
$execute[] = $item->name;
}
}
<VirtualHost *:80>
ServerName api.yii2-app
DirectoryIndex index.php
DocumentRoot /var/www/trainingYii/web/
<Directory /var/www/trainingYii/backend/web/>
Options +FollowSymLinks +MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog /var/www/trainingYii/backend/runtime/logyii2-app/runtime/logs/apache-error.log
CustomLog /var/www/trainingYii/backend/runtime/logs/apache-access.log combined
</VirtualHost>