Skip to content
This repository has been archived by the owner on Jun 17, 2021. It is now read-only.

Commit

Permalink
Fix missing idol's id in 2 controllers
Browse files Browse the repository at this point in the history
  • Loading branch information
miyacorata committed May 8, 2020
1 parent 69dbba0 commit e706a59
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
24 changes: 20 additions & 4 deletions app/Http/Controllers/IdolController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Illuminate\Database\Eloquent\ModelNotFoundException;
use Illuminate\Http\Request;
use App\Idol;

class IdolController extends Controller
{
Expand All @@ -14,19 +15,34 @@ class IdolController extends Controller
*/
public function index(Request $request)
{
// 属性絞り込み
$type = $request->input('type') ?: false;
if(!empty($type) and array_search($type,config('ouranos.acceptableTypes')) === false){
abort(404,__('messages.idol.index.incorrect'));
}elseif(!empty($type)){
$idols = \App\Idol::select()->leftjoin('c_k_names','idols.id','=','c_k_names.idol_id')->where('type',$type)->get();
$idols = Idol::select('idols.*','c_k_names.id as cknameid','c_k_names.name_zh','c_k_names.name_ko',
'c_k_names.name_zh_separate','c_k_names.name_ko_separate',
'c_k_names.subname_zh','c_k_names.subname_ko')
->leftjoin('c_k_names','idols.id','=','c_k_names.idol_id')->where('type',$type)->get();
if($idols->isEmpty()) abort(404);
$idol_count = $idols->count();
}else{
$idols = \App\Idol::select()->leftjoin('c_k_names','idols.id','=','c_k_names.idol_id')->get();
$idols = Idol::select('idols.*','c_k_names.id as cknameid','c_k_names.name_zh','c_k_names.name_ko',
'c_k_names.name_zh_separate','c_k_names.name_ko_separate',
'c_k_names.subname_zh','c_k_names.subname_ko')
->leftjoin('c_k_names','idols.id','=','c_k_names.idol_id')->get();
$idol_count = $idols->count();
}
$description = 'アイドルを属性ごとに一覧できます。'.config('ouranos.defaultDescription');
return view('idol.index',compact('idols','type','idol_count','description'));

// 動作モード
$mode = $request->input('mode') ?: 'normal';
if($mode !== 'normal' && $mode !== 'sortable')abort(400);
if($mode === 'normal'){
return view('idol.index',compact('idols','type','idol_count','description'));
}else /*if ($mode === 'sortable')*/{
return view('idol.index-table',compact('idols','type','idol_count','description'));
}
}

/**
Expand Down Expand Up @@ -59,7 +75,7 @@ public function index(Request $request)
public function show($name_r)
{
try{
$idol = \App\Idol::select('idols.*','c_k_names.id as cknameid','c_k_names.name_zh','c_k_names.name_ko',
$idol = Idol::select('idols.*','c_k_names.id as cknameid','c_k_names.name_zh','c_k_names.name_ko',
'c_k_names.name_zh_separate','c_k_names.name_ko_separate',
'c_k_names.subname_zh','c_k_names.subname_ko')
->leftjoin('c_k_names','idols.id','=','c_k_names.idol_id')
Expand Down
4 changes: 3 additions & 1 deletion app/Http/Controllers/SearchController.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ public function search(Request $request){
}

// 検索開始
$search = Idol::select();
$search = Idol::select('idols.*','c_k_names.id as cknameid','c_k_names.name_zh','c_k_names.name_ko',
'c_k_names.name_zh_separate','c_k_names.name_ko_separate',
'c_k_names.subname_zh','c_k_names.subname_ko');
$query_info = array();
$order_by = "id";
$order_direction = "asc";
Expand Down

0 comments on commit e706a59

Please sign in to comment.