route('articles.edit', $article)
public function __construct()
{
$this->authorizeResource(Article::class, 'article');
}
User::withCount(['posts' => function($query) {
$query->whereDate('created_at', '>=', now()->startOfWeek());
}])
->orderByDesc('posts_count')
->take(3)
->get();
Article::whereYear('created_at', now()->year)
->whereMonth('created_at', now()->month)
->orWhere(function ($query) {
$query->whereYear('created_at', now()->subYear()->year)
->whereMonth('created_at', now()->month);
})
->get()
->groupBy(function($article) {
return Carbon::parse($article->created_at)
->format('m-Y');
});
return $file->user_id === $user->id;
$this->authorize('download', $file);
return Storage::disk($disk)->download($path);
$user->posts()
->latest()
->get();
return !$post->isPaid or optional($user)->hasSubscription;
Gate::allows('view', $this)
return $this->membership_ends_at >= now();
\DB::table('users')
->where('active', true)
->whereDate('updated_at', '<=', now()->subMonths(3))
->update(['active' => false]);
$buildingId = $request->input('building_id');
Post::published()
->whereCategoryId($request->input('posts_type'))
->when($buildingId, function ($query, $buildingId) {
return $query->whereHas('buildings', function ($query) use($buildingId) {
$query->whereId($buildingId);
});
})
->with('buildings')
->latest('published_at')
->paginate(6);
public function attributes()
{
return $this->hasOne(UserAttribute::class);
}
public function city()
{
return $this->belongsTo(City::class);
}
User::with('attributes.city', 'services')
->paginate($perPage);