承接 renatobalbino/laravel-filterable 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

renatobalbino/laravel-filterable

最新稳定版本:v1.0.0

Composer 安装命令:

composer require renatobalbino/laravel-filterable

包简介

Filter package to Laravel/Lumen

README 文档

README

Filter model by query string

Example: domain.com/route?id=1

Install package

composer require leandreaci/filterable *@dev

Using

Create a file in your Laravel/Lumen project

  • app/Filters/ExampleFilter.php
<?php


namespace App;


use Carbon\Carbon;
use Leandreaci\Filterable\QueryFilter;

class ExampleFilter extends QueryFilter
{

    public function id($id)
    {
        return $this->builder->where('id', $id);
    }

    public function start($date)
    {
        try{
            $formattedDate = Carbon::createFromFormat('Y-m-d', $date)->startOfDay()->toDateTimeString();
            return $this->builder->where('created_at','>', $formattedDate);
        }catch (\Exception $exception)
        {
            return $this->builder;
        }
    }
    

}
  • Use the Trait Filterable to you Model want to Filter
<?php

namespace App;

use Illuminate\Database\Eloquent\Model;
use Leandreaci\Filterable\Filterable;

class ExampleModel extends Model
{
    use Filterable;
}

?>
  • In Controller
<?php

namespace App\Http\Controllers;

use App\ExampleModel;

class TransactionController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @param ExampleFilter $filter
     * @return TransactionsCollection
     */
    public function index(ExampleFilter $filter)
    {
        return  ExampleModel::filter($filter)
                               ->paginate(10);
    }
}
?>

统计信息

  • 总下载量: 6
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-11-12