定制 theamasoud/laravel-search 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

theamasoud/laravel-search

最新稳定版本:v1.0.0

Composer 安装命令:

composer require theamasoud/laravel-search

包简介

A Laravel package to search easily in columns, multiple columns and json columns

README 文档

README

Installation

First, install the package through Composer.

composer require theamasoud/laravel-search

or add this in your project's composer.json file .

"require": {
  "theamasoud/laravel-search": "1.*",
}

Usage

Traits

TheAMasoud\LaravelSearch\Searchable

Add the Searchable trait to your model:

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use TheAMasoud\LaravelSearch\Searchable;

class Message extends Model
{
    use Searchable;
    protected $fillable = ['name','email','subject','message'];
}

Normal Search

first how to make a normel search or fillter, you should use search() method.
and you should pass a two parameters column you need to search or fillter in and the request key thet come from your request

Request key:

Normal Search Example:

$messages = Message::search('name','search')->get();
  • In this example I am trying to search or filter in name column in messages table and the data I will search about it's come from request key search like:($request->search)

Search Multiple

By multiple search you can search in multiple columns and multiple values from request.
how to make a multiple search or fillter, you should use searchMultiple() method.
and you should pass a one array parameter column you need to search or fillter in array key and the request key thet come from your request as a value of key like:['name'=>'search_name','bio'=>'search_bio']

Request keys:

Search Multiple Example:

$messages = Message::searchMultiple(['title'=>'search_title','description'=>'search_desc'])->get();
  • In this example I am trying to search or filter in title column in messages table and the data I will search about it's come from request key search_title like:($request->search) etc... with description

Search In Multiple Columns

By search in multiple you can search in multiple columns and one value from request.
how to make a search in multiple or fillter, you should use searchInMultiple() method.
and you should pass a two parameters columns you need to search or fillter in and the request key thet come from your request as a value of key

Request keys:

Search In Multiple Example:

$messages = Message::searchInMultiple(['title','description','etc...'],'search')->get();
  • In this example I am trying to search or filter in title and description column in messages table and the data I will search about it's come from request key search like:($request->search)

Search In Json Column

By search in json you can search in json column and value from request.
how to make a search in multiple or fillter, you should use jsonSearch() method.
and you should pass a two parameters column you need to search or fillter in and the request key thet come from your request as a value of key

Request keys:

Search In Json Example:

My json colums has:
{
    "ar":"نص عربي",
    "en":"English text"
}
$messages = Message::jsonSearch('title->ar','search')->get();
  • In this example I am trying to search or filter in title column in messages table and the data I will search about it's come from request key search like:($request->search)

统计信息

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

GitHub 信息

  • Stars: 6
  • Watchers: 1
  • Forks: 5
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-08-31

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固