<?php

namespace Modules\Block\Http\Controllers;

use App\Functions\ResponseHelper;
use App\Http\Controllers\BasicController;
use Illuminate\Http\Request;
use Modules\Block\Entities\Model;
use Modules\Block\Http\Resources\BlockResource;

class APIController extends BasicController
{
    public function blocks()
    {
        return ResponseHelper::make(Model::select('title')->orderBy('title')->get());
    }
    public function paginated()
    {
        return ResponseHelper::make(Model::select('title as id','address as title')->orderBy('title')->when(request('title'), function ($query) {
                    return $query->where('title', 'LIKE','%'. request('title') .'%');
                })->paginate(15));
    }
}
