承接 assemble/eloquentsearch 相关项目开发

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

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

assemble/eloquentsearch

Composer 安装命令:

composer require assemble/eloquentsearch

包简介

Search and retrieve an eloquent model entity based on complex search criteria from the model relations.

README 文档

README

Installation

Add this line to your providers array:

Assemble\EloquentSearch\EloquentSearchServiceProvider::class,

Add this line to your aliases array:

'EloquentSearch' => Assemble\EloquentSearch\Facades\EloquentSearcher::class,

You will need to run php artisan vendor:publish to publish the config file to your instalation, Once run, you can find it in config/eloquenet_search.php. This config file is used to controll which models are used to search/return entities of.

Configuration

The config file can be found in the laravel config folder at config/eloquent_search.php, here you can define the classes related to your models as below.

return [
	'search_models' => [
		/* 
			Add your searchable eloquent models here, this is an example of user model usage.

			If you have your models sitting in the app root as default, something like this should find them.
			
				'user' => User::class,
	    	
	    	Otherwise if you have them elsewhere or the application cant seem to find them, try prefix them as such.
	    
	    		'user' => App\Models\User::class,

	    */
	   	
	    'user' => User::class,

	]
];

Usage

To make use of the search functionality, you will need to implement a $searchable property on your models to detail which fields and relations are searchable.

/*
*   Searchable Fields
*/
public $searchable = [
    'name', 'user_id', // fields
    'user', 'tags', // relations
];

You can also implement the method 'isSearchable' in your models for the searcher to determine if it is allowed to search/return that model.

public function isSearchable(){
	// Do your checks to determine if the model may be searched by the user
	return true;
}

This feature lets you restrict user searches to only the models they are allowed to see.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-02-24

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固