PHP code example of tes / laravel-relafilter

1. Go to this page and download the library: Download tes/laravel-relafilter library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

tes / laravel-relafilter example snippets


use App\Models\Employee;

class EmployeeList extends Component
{
    public array $search = [];

    public function render()
    {
        $employees = Employee::filter($this->search)->get();

        return view('livewire.employee-list', compact('employees'));
    }
}

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

public function index(Request $request)
{
    $employees = Employee::filter($request->input())->get();

    return view('employees.index', compact('employees'));
}

if (isset($flatFilters['start']) && isset($flatFilters['end'])) {
    $query->whereBetween('start_date', [
        $flatFilters['start'],
        Carbon::parse($flatFilters['end'])->endOfDay(),
    ]);
}

[
    'company.name:like' => 'Tesla',
    'current_company_position.position.name:like' => 'Developer',
    'status' => 'active',
    'created_at:>' => '2024-01-01',
    'start' => '2024-06-01',
    'end' => '2024-06-30',
]

use Tes\LaravelRelafilter\Traits\HasRelafilter;

class Employee extends Model
{
    use HasRelafilter;
}