Commit 65a6c1a6 authored by gxx's avatar gxx

模糊查询开发。

parent b2bb0ad6
...@@ -17,5 +17,5 @@ interface UserServiceContract ...@@ -17,5 +17,5 @@ interface UserServiceContract
public function update($id,$phone,$user_name,$real_name,$gender,$email,$head_icon); public function update($id,$phone,$user_name,$real_name,$gender,$email,$head_icon);
public function simpleSearch(); // public function simpleSearch();
} }
\ No newline at end of file
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use App\Contracts\UserServiceContract; use App\Contracts\UserServiceContract;
use App\Models\User;
use App\Util\Message; use App\Util\Message;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Facades\Storage; use Illuminate\Support\Facades\Storage;
...@@ -35,9 +36,6 @@ class UserController extends Controller ...@@ -35,9 +36,6 @@ class UserController extends Controller
public function update(Request $request) public function update(Request $request)
{ {
$id = $request->id; $id = $request->id;
$user_name = $request->user_name; $user_name = $request->user_name;
$real_name = $request->real_name; $real_name = $request->real_name;
...@@ -82,4 +80,20 @@ class UserController extends Controller ...@@ -82,4 +80,20 @@ class UserController extends Controller
return Message::makeError('无次用户'); return Message::makeError('无次用户');
} }
} }
public function simpleSearch(Request $request)
{
$content = $request->search;
$user_name = User::where('user_name','like','%'.$content.'%')->get();
$phone = User::where('phone','like','%'.$content.'%')->get();
$email = User::where('email','like','%'.$content.'%')->get();
$result = [$user_name,$phone,$email];
dd($result);
}
} }
...@@ -4,13 +4,16 @@ namespace App\Models; ...@@ -4,13 +4,16 @@ namespace App\Models;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Database\Eloquent\SoftDeletes;
use Laravel\Scout\Searchable;
class User extends Model class User extends Model
{ {
use SoftDeletes; use SoftDeletes,Searchable;
protected $dates = ['delete_at']; protected $dates = ['delete_at'];
protected $hidden =['password']; protected $hidden =['password'];
protected $table = 'users';
protected $fillable=["user_name","phone","password"]; protected $fillable=["user_name","phone","password"];
...@@ -20,6 +23,15 @@ class User extends Model ...@@ -20,6 +23,15 @@ class User extends Model
} }
public function toSearchableArray()
{
return [
'user_name' => $this->user_name,
'real_name' => $this->real_name,
];
}
public function EmailCheck() public function EmailCheck()
{ {
return $this->hasOne('App\EmailCheck'); return $this->hasOne('App\EmailCheck');
......
...@@ -6,9 +6,12 @@ ...@@ -6,9 +6,12 @@
"type": "project", "type": "project",
"require": { "require": {
"php": ">=7.0.0", "php": ">=7.0.0",
"elasticsearch/elasticsearch": "^5.3",
"fideloper/proxy": "~3.3", "fideloper/proxy": "~3.3",
"laravel/framework": "5.5.*", "laravel/framework": "5.5.*",
"laravel/tinker": "~1.0" "laravel/scout": "^3.0",
"laravel/tinker": "~1.0",
"tamayo/laravel-scout-elastic": "^3.0"
}, },
"require-dev": { "require-dev": {
"filp/whoops": "~2.0", "filp/whoops": "~2.0",
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "8f2120fa77d42a42b4210cdbe1c114e2", "content-hash": "31667d774c1e0cb4754ae6075f8d724d",
"packages": [ "packages": [
{ {
"name": "dnoegel/php-xdg-base-dir", "name": "dnoegel/php-xdg-base-dir",
...@@ -217,6 +217,61 @@ ...@@ -217,6 +217,61 @@
], ],
"time": "2017-01-30T22:07:36+00:00" "time": "2017-01-30T22:07:36+00:00"
}, },
{
"name": "elasticsearch/elasticsearch",
"version": "v5.3.0",
"source": {
"type": "git",
"url": "https://github.com/elastic/elasticsearch-php.git",
"reference": "50e5b1c63db68839b8acc1f4766769570a27a448"
},
"dist": {
"type": "zip",
"url": "https://files.phpcomposer.com/files/elastic/elasticsearch-php/50e5b1c63db68839b8acc1f4766769570a27a448.zip",
"reference": "50e5b1c63db68839b8acc1f4766769570a27a448",
"shasum": ""
},
"require": {
"guzzlehttp/ringphp": "~1.0",
"php": "^5.6|^7.0",
"psr/log": "~1.0"
},
"require-dev": {
"cpliakas/git-wrapper": "~1.0",
"doctrine/inflector": "^1.1",
"mockery/mockery": "0.9.4",
"phpunit/phpunit": "^4.7|^5.4",
"sami/sami": "~3.2",
"symfony/finder": "^2.8",
"symfony/yaml": "^2.8"
},
"suggest": {
"ext-curl": "*",
"monolog/monolog": "Allows for client-level logging and tracing"
},
"type": "library",
"autoload": {
"psr-4": {
"Elasticsearch\\": "src/Elasticsearch/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"Apache-2.0"
],
"authors": [
{
"name": "Zachary Tong"
}
],
"description": "PHP Client for Elasticsearch",
"keywords": [
"client",
"elasticsearch",
"search"
],
"time": "2017-07-19T18:44:30+00:00"
},
{ {
"name": "erusev/parsedown", "name": "erusev/parsedown",
"version": "1.6.3", "version": "1.6.3",
...@@ -316,6 +371,107 @@ ...@@ -316,6 +371,107 @@
], ],
"time": "2017-06-15T17:19:42+00:00" "time": "2017-06-15T17:19:42+00:00"
}, },
{
"name": "guzzlehttp/ringphp",
"version": "1.1.0",
"source": {
"type": "git",
"url": "https://github.com/guzzle/RingPHP.git",
"reference": "dbbb91d7f6c191e5e405e900e3102ac7f261bc0b"
},
"dist": {
"type": "zip",
"url": "https://files.phpcomposer.com/files/guzzle/RingPHP/dbbb91d7f6c191e5e405e900e3102ac7f261bc0b.zip",
"reference": "dbbb91d7f6c191e5e405e900e3102ac7f261bc0b",
"shasum": ""
},
"require": {
"guzzlehttp/streams": "~3.0",
"php": ">=5.4.0",
"react/promise": "~2.0"
},
"require-dev": {
"ext-curl": "*",
"phpunit/phpunit": "~4.0"
},
"suggest": {
"ext-curl": "Guzzle will use specific adapters if cURL is present"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.1-dev"
}
},
"autoload": {
"psr-4": {
"GuzzleHttp\\Ring\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Michael Dowling",
"email": "mtdowling@gmail.com",
"homepage": "https://github.com/mtdowling"
}
],
"description": "Provides a simple API and specification that abstracts away the details of HTTP into a single PHP function.",
"time": "2015-05-20T03:37:09+00:00"
},
{
"name": "guzzlehttp/streams",
"version": "3.0.0",
"source": {
"type": "git",
"url": "https://github.com/guzzle/streams.git",
"reference": "47aaa48e27dae43d39fc1cea0ccf0d84ac1a2ba5"
},
"dist": {
"type": "zip",
"url": "https://files.phpcomposer.com/files/guzzle/streams/47aaa48e27dae43d39fc1cea0ccf0d84ac1a2ba5.zip",
"reference": "47aaa48e27dae43d39fc1cea0ccf0d84ac1a2ba5",
"shasum": ""
},
"require": {
"php": ">=5.4.0"
},
"require-dev": {
"phpunit/phpunit": "~4.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.0-dev"
}
},
"autoload": {
"psr-4": {
"GuzzleHttp\\Stream\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Michael Dowling",
"email": "mtdowling@gmail.com",
"homepage": "https://github.com/mtdowling"
}
],
"description": "Provides a simple abstraction over streams of data",
"homepage": "http://guzzlephp.org/",
"keywords": [
"Guzzle",
"stream"
],
"time": "2014-10-12T19:18:40+00:00"
},
{ {
"name": "jakub-onderka/php-console-color", "name": "jakub-onderka/php-console-color",
"version": "0.1", "version": "0.1",
...@@ -535,6 +691,71 @@ ...@@ -535,6 +691,71 @@
], ],
"time": "2017-09-24T19:09:38+00:00" "time": "2017-09-24T19:09:38+00:00"
}, },
{
"name": "laravel/scout",
"version": "v3.0.10",
"source": {
"type": "git",
"url": "https://github.com/laravel/scout.git",
"reference": "681c15a26bbc973528af2e77e0bb61981dc07206"
},
"dist": {
"type": "zip",
"url": "https://files.phpcomposer.com/files/laravel/scout/681c15a26bbc973528af2e77e0bb61981dc07206.zip",
"reference": "681c15a26bbc973528af2e77e0bb61981dc07206",
"shasum": ""
},
"require": {
"illuminate/bus": "~5.4",
"illuminate/contracts": "~5.4",
"illuminate/database": "~5.4",
"illuminate/pagination": "~5.4",
"illuminate/queue": "~5.4",
"illuminate/support": "~5.4",
"php": ">=5.6.4"
},
"require-dev": {
"algolia/algoliasearch-client-php": "^1.10",
"mockery/mockery": "~0.9",
"phpunit/phpunit": "~5.0"
},
"suggest": {
"algolia/algoliasearch-client-php": "Required to use the Algolia engine (^1.10)."
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.0-dev"
},
"laravel": {
"providers": [
"Laravel\\Scout\\ScoutServiceProvider"
]
}
},
"autoload": {
"psr-4": {
"Laravel\\Scout\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Taylor Otwell",
"email": "taylor@laravel.com"
}
],
"description": "Laravel Scout provides a driver based solution to searching your Eloquent models.",
"keywords": [
"algolia",
"laravel",
"search"
],
"time": "2017-09-14T12:32:30+00:00"
},
{ {
"name": "laravel/tinker", "name": "laravel/tinker",
"version": "v1.0.2", "version": "v1.0.2",
...@@ -1254,6 +1475,52 @@ ...@@ -1254,6 +1475,52 @@
], ],
"time": "2017-09-22T20:46:04+00:00" "time": "2017-09-22T20:46:04+00:00"
}, },
{
"name": "react/promise",
"version": "v2.5.1",
"source": {
"type": "git",
"url": "https://github.com/reactphp/promise.git",
"reference": "62785ae604c8d69725d693eb370e1d67e94c4053"
},
"dist": {
"type": "zip",
"url": "https://files.phpcomposer.com/files/reactphp/promise/62785ae604c8d69725d693eb370e1d67e94c4053.zip",
"reference": "62785ae604c8d69725d693eb370e1d67e94c4053",
"shasum": ""
},
"require": {
"php": ">=5.4.0"
},
"require-dev": {
"phpunit/phpunit": "~4.8"
},
"type": "library",
"autoload": {
"psr-4": {
"React\\Promise\\": "src/"
},
"files": [
"src/functions_include.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Jan Sorgalla",
"email": "jsorgalla@gmail.com"
}
],
"description": "A lightweight implementation of CommonJS Promises/A for PHP",
"keywords": [
"promise",
"promises"
],
"time": "2017-03-25T12:08:31+00:00"
},
{ {
"name": "swiftmailer/swiftmailer", "name": "swiftmailer/swiftmailer",
"version": "v6.0.1", "version": "v6.0.1",
...@@ -2057,6 +2324,49 @@ ...@@ -2057,6 +2324,49 @@
], ],
"time": "2017-07-28T06:06:09+00:00" "time": "2017-07-28T06:06:09+00:00"
}, },
{
"name": "tamayo/laravel-scout-elastic",
"version": "3.0.6",
"source": {
"type": "git",
"url": "https://github.com/ErickTamayo/laravel-scout-elastic.git",
"reference": "85bc852ca059910c77d98c6960e7999a6cec5ea6"
},
"dist": {
"type": "zip",
"url": "https://files.phpcomposer.com/files/ErickTamayo/laravel-scout-elastic/85bc852ca059910c77d98c6960e7999a6cec5ea6.zip",
"reference": "85bc852ca059910c77d98c6960e7999a6cec5ea6",
"shasum": ""
},
"require": {
"elasticsearch/elasticsearch": "^5.0",
"laravel/scout": "^3.0",
"php": ">=5.6.4"
},
"require-dev": {
"fzaninotto/faker": "~1.4",
"mockery/mockery": "0.9.*",
"phpunit/phpunit": "~5.0"
},
"suggest": {
"elasticsearch/elasticsearch": "Required to use the Elasticsearch engine (^5.0)."
},
"type": "library",
"autoload": {
"psr-4": {
"ScoutEngines\\Elasticsearch\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"description": "Elastic Driver for Laravel Scout",
"keywords": [
"elastic",
"elasticsearch",
"laravel",
"scout"
],
"time": "2017-08-21T14:07:01+00:00"
},
{ {
"name": "tijsverkoyen/css-to-inline-styles", "name": "tijsverkoyen/css-to-inline-styles",
"version": "2.2.0", "version": "2.2.0",
......
...@@ -186,6 +186,9 @@ return [ ...@@ -186,6 +186,9 @@ return [
App\Providers\SMSServiceProvider::class, App\Providers\SMSServiceProvider::class,
App\Providers\UserServiceProvider::class, App\Providers\UserServiceProvider::class,
], ],
/* /*
......
...@@ -25,6 +25,35 @@ ...@@ -25,6 +25,35 @@
</div> </div>
<!-- /.box-header --> <!-- /.box-header -->
<div class="box-body"> <div class="box-body">
<form action="{{url('user/search')}}">
<div class="row">
<div class="col-lg-6">
<div class="input-group">
<input type="text" class="form-control" placeholder="Search for..." name="search">
<span class="input-group-btn">
<button class="btn btn-default" > 搜索 </button>
</span>
</div><!-- /input-group -->
</div><!-- /.col-lg-6 -->
</div><!-- /.row -->
</form>
<br>
<table id="example2" class="table table-bordered table-hover"> <table id="example2" class="table table-bordered table-hover">
<thead> <thead>
<tr> <tr>
......
...@@ -44,6 +44,8 @@ Route::group(['prefix'=> 'user'],function (){ ...@@ -44,6 +44,8 @@ Route::group(['prefix'=> 'user'],function (){
Route::get('updatePage/{id}','UserController@updatePage')->name('user.updatePage'); Route::get('updatePage/{id}','UserController@updatePage')->name('user.updatePage');
Route::post('update','UserController@update')->name('user.update'); Route::post('update','UserController@update')->name('user.update');
Route::get('search','UserController@simpleSearch')->name('user.search');
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment