-
app/Models/Link.php
Open in GitHubuse Illuminate\Database\Eloquent\Model; class Link extends Model { public function scopeByUser(Builder $query, int $userId): Builder { return $query->where('user_id', $userId); } }
-
app/Http/Controllers/App/DashboardController.php
Open in GitHubuse App\Http\Controllers\Controller; use App\Models\Link; use App\Models\LinkList; use App\Models\Note; use App\Models\Tag; use Illuminate\Contracts\View\View; class DashboardController extends Controller { public function index(): View { $recentLinks = Link::byUser(auth()->user()->id) ->latest() ->limit(5) ->get(); $recentTags = Tag::byUser(auth()->user()->id) ->latest() ->limit(25) ->get(); $recentLists = LinkList::byUser(auth()->user()->id) ->latest() ->limit(15) ->get(); $brokenLinks = Link::byUser(auth()->user()->id) ->where('status', '>', 1) ->count(); return view('dashboard', [ 'recent_links' => $recentLinks, 'recent_tags' => $recentTags, 'recent_lists' => $recentLists, ]); } }