Php 拉雷维尔高级搜索
我有这些桌子:Php 拉雷维尔高级搜索,php,laravel,search,project,Php,Laravel,Search,Project,我有这些桌子: players player_histories clubs 我想在playerhistory中搜索。 如果我们搜索球员姓名,那么所有球员的详细信息都会显示出来 在播放器表中: $table->string('name'); $table->date('DOB'); $table->string('permanent_address'); $table->string('temporary_
players
player_histories
clubs
我想在playerhistory
中搜索。
如果我们搜索球员姓名,那么所有球员的详细信息都会显示出来
在播放器表中:
$table->string('name');
$table->date('DOB');
$table->string('permanent_address');
$table->string('temporary_address');
$table->string('blood_group');
$table->float('height');
$table->float('weight');
$table->string('complexion');
$table->bigInteger('contact_home');
在俱乐部桌上:
$table->integer('club_id')->unsigned()->index();
$table->foreign('club_id')->references('id')->on('clubs')->onDelete('cascade');
$table->integer('championship_id')->unsigned()->index();
$table->foreign('championship_id')->references('id')->on('championship_details')->onDelete('cascade');
$table->string('game_result_status');
在playerhistories表中
$table->integer('player_id')->unsigned()->index();
$table->foreign('player_id')->references('id')->on('players')->onDelete('cascade');
$table->integer('previous_club_id')->unsigned()->index();
$table->foreign('previous_club_id')->references('id')->on('clubs')->onDelete('cascade');
$table->integer('current_club_id')->unsigned()->index();
$table->foreign('current_club_id')->references('id')->on('clubs')->onDelete('cascade');
$table->float('salary');
我的过程:
http://www.blade.php
Route::post(
'search/player',
array(
'as' => 'search/player',
'uses' => 'PlayerHistoryController@searchPlayer'
)
))
查看页面
{!! Form::open(array('method' => 'Post', 'url' => 'search/player')) !!}
<div class="col-md-3">
</div>
<div class="col-md-3">
<div class="form-group">
<label class="sr-only" for="search_text">Search Text</label>
{!! Form::text('search_text',null,array('class'=>'form-control', 'placeholder' => 'Search player')) !!}
</div>
</div>
<div class="col-md-2">
{!! form::submit('Search Player',[' class'=>'btn btn-primary form-control'])!!}
{!! Form::close() !!}
存储库:
public function searchByPlayer(){
$first = $this->makeModel()->where('player_id', "LIKE", '%' . $search_text . '%')->where('permanent_address', "LIKE", '%' . $search_text . '%');
}
我想在player\u id
中输入一个名字。怎么可能呢?我们是否必须使用union
来搜索在1个搜索文本中输入的每个字段
先谢谢你
public function searchByPlayer(){
$first = $this->makeModel()->where('player_id', "LIKE", '%' . $search_text . '%')->where('permanent_address', "LIKE", '%' . $search_text . '%');
}