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

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

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

mawuekom/laravel-searchable

Composer 安装命令:

composer require mawuekom/laravel-searchable

包简介

Laravel package to make easy search on Eloquent model

README 文档

README

This package is provided with a service provider and trait to make search on your eloquent model

Installation

You can install the package via composer:

composer require mawuekom/laravel-searchable

Usage

Laravel

Go to config/app.php, and add this in the providers key

'providers' => [
    ...
    Mawuekom\LaravelSearchable\LaravelSearchableServiceProvider::class,
    ...
]

Lumen

Go to bootstrap/app.php, and add this in the specified key

// Add provider 
$app->register(Mawuekom\LaravelSearchable\LaravelSearchableServiceProvider::class);

Your model which inherits an eloquent model

<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Post extends Model
{
    ...

    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [
        'title',
        'content'
    ];

     ...
}

Use it to make search

use App\Models\Post;

Post::whereLike(['title', 'content'], 'Post title');

You can also include Searchable Trait in your model.

<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Mawuekom\LaravelSearchable\Searchable;

class Post extends Model
{
    use Searchable;

    ...
}

Once done, you can make your reseach like this

use App\Models\Post;

Post::search(['title', 'content'], 'Post title') ->get();

Once done, enjoy it.

Testing

composer test

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security and Report bug

If you discover any security related issues, please email seddorephraim7@gmail.com or contact me on Twitter @ephraimseddor instead of using the issue tracker.

License

The MIT License (MIT). Please see License File for more information.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-07-17

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固