-
app/Models/Board.php
Open in GitHubuse Illuminate\Database\Eloquent\Model; class Board extends Model { // public function scopeVisible($query) { return $query->where('visible', true); } // }
-
app/Http/Controllers/ProjectController.php
Open in GitHubuse App\Models\Project; class ProjectController extends Controller { public function show($id) { $project = Project::query()->where('slug', $id)->firstOrFail(); return view('project', [ 'project' => $project, 'boards' => $project->boards()->visible()->with(['items' => function ($query) { return $query ->popular() ->withCount('votes'); }])->get() ]); } }