Как сделать пагинацию через строку запроса (Get параметр)
подскажите как найти решение.
Нужно сделать пагинацию через строку запроса. Результат: api/employes?page=2&limit=40&tags=3,4
Я пока смог только разобраться как вывести по id.
Контроллер:
class EmployeController extends Controller
{
public function index()
{
$employes = Employe::all()->toArray();
return array_reverse($employes);
}
public function show($user_id)
{
$user = Employe::findOrFail($user_id);
return $user;
}
}
Фрагмент Api роута:
Route::middleware('api')->group(function () {
Route::resource('employes', EmployeController::class);
});
Модель:
class Employe extends Model
{
use HasFactory;
protected $fillable = ['position_id', 'name', 'surname', 'addname'];
public function tags()
{
return $this->belongsToMany(Tag::class, 'employe_tag', 'employe_id', 'tag_id');
}
}