kevinpijning/laravel-searchable 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

kevinpijning/laravel-searchable

Composer 安装命令:

composer require kevinpijning/laravel-searchable

包简介

Easy table searching for Laravel

README 文档

README

This package let you easily search through models by a Searchable trait.

Setup

Composer

Pull this package in through Composer

{
    "require": {
        "kevinpijning/laravel-searchable": "dev-master"
    }
}

$ composer update

Add the package to your application service providers in config/app.php

'providers' => [

    App\Providers\RouteServiceProvider::class,

    /*
     * Third Party Service Providers...
     */
     KevinPijning\LaravelSearchable\LaravelSearchableServiceProvider::class,
],

Publish the view:

php artisan vendor:publish

Usage

Use Searchable trait inside your Eloquent model(s). Define $searchable array (see example code below).

use KevinPijning\LaravelSearchable\Searchable;

class User extends Model implements AuthenticatableContract, CanResetPasswordContract 
{
	use Authenticatable, CanResetPassword, Searchable;
	...

	public $searchable = ['id',
	                    'name',
	                    'email',
	                    'created_at',
	                    'updated_at'];
	                    
	...
}

Searchable trait adds Searchable scope to the models so you can use it with paginate.

Blade extension

There is one blade extension for you to use @searchableform

@searchableform

This will include a search form to your page.

Full example

Routes

Route::get('users', ['as' => 'users.index', 'uses' => 'HomeController@index']);

Controller

use App\User;

public function index()
{
    $users = User::searchable()->paginate(10);
    
    return view('user.index')->withUsers($users);
}

View

Pagination included

@searchableform

@foreach($users as $user)
	{{ $user->name }}
@endforeach

{!! $users->appends(\Request::except('page'))->render() !!}

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-05-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固