<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Models\Pathway;

class PathwayController extends Controller
{
    public function index(Request $request)
    {
        $search = $request->get('search');
        
        $pathways = Pathway::active()
            ->when($search, function ($query, $search) {
                return $query->search($search);
            })
            ->ordered()
            ->paginate(12);
        
        return view('pathway', compact('pathways', 'search'));
    }
}