GET '/posts/slug/'
{
post: { /* ... */ }
}
GET '/posts/slug/comments/'
{
comments: { /* ... */ }
}
GET '/posts/slug/comments/users/'
{
users: { /* ... */ }
}
GET '/posts/slug/author/'
{
author: { /* ... */ }
}
GET '/posts/slug/meta/'
{
meta: { /* ... */ }
}
GET '/posts/slug/'
{
post: { /* ... */ },
linked: {
users: { /* ... */ },
comments: { /* ... */ },
meta: { /* ... */ },
},
}
public function users() {
return $this->belongsToMany('App\User', 'user_department', 'departament_id', 'user_id');
}
$departaments = Department::with('users')
->get();
@foreach ($departaments as $departament)
@foreach ($departament->users as $user)
{{$user->name}}
@endforeach
@endforeach
// удаляем поле
Schema::table('auto', function (Blueprint $table) {
$table->dropColumn('remove_field');
});
// добавляем поле
Schema::table('auto', function (Blueprint $table) {
$table->integer('add_field')->nullable();
});