public function lastMessage()
{
return $this->hasOne('App\Models\Message','chat_id', 'id')->latest();
}
$chats = Chat::with('lastMessage')->get();
@foreach ($chats as $chat)
{{ $chat->lastMessage->name }}
@endforeach
Vue.component('comp', require('./components/Comp.vue'));
<div id="app">
<comp
:users="{{json_encode($users)}}"
></comp>
</div>
public function tags()
{
return $this->belongsToMany('как в доках');
}
$user = User::with('tags.posts')
->find(Auth::id());
@foreach ($user->tags as $tag)
@foreach ($tag->posts as $post)
{{ $post->name }}
@endforeach
@endforeach
public function scopeOfUser($query, $userId)
{
return $query->whereHas('users', function($query) use($userId) {
$query->where('user_tag.user_id',$userId);
});
}
$posts = Post::with('tags')
->whereHas('tags', function($query) use($userId) {
$query->ofUser($userId);
})->get();
if ($request->ajax()) {
return json;
}
$users = User::with(['services' => function($query) {
$query->with('tariff','platform')
->wherePivot('status',true);
}])->get();
$content = Storage::disk('s3')->get($path);
$header = [
'Content-Type' => 'application/pdf',
'Content-Disposition' => 'inline; filename="'.$file->name.'"'
];
return Response::make($content, 200, $header);
->whereBetween('created_at', [now()->subDays(10), now()])
->where('created_at', '>=', now()->subDays(10)) ;
->whereDate('created_at', now()->subDays(10));
$follower->follower->username_slug
$userinfo->following()->count()
$userinfo->following()->take(12)->get()
href="/profile/{{ $following->followed->username_slug }}"
route('name', $slug)
dd($usersinfo)
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