本文整理汇总了PHP中app\models\Project::whereIn方法的典型用法代码示例。如果您正苦于以下问题:PHP Project::whereIn方法的具体用法?PHP Project::whereIn怎么用?PHP Project::whereIn使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Project
的用法示例。
在下文中一共展示了Project::whereIn方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: projectsUserIsMember
public function projectsUserIsMember($userid)
{
$userInProjects = DB::table('project_user')->where('user_id', '=', $userid)->get(['project_id']);
$wherein = [];
foreach ($userInProjects as $value) {
$wherein[] = $value->project_id;
}
return Project::whereIn('id', $wherein)->get();
}
示例2: getIndex
public function getIndex($criteria = Null)
{
Session::put('step', '1');
Session::put('last_insert_id', '');
$searchKey = \Input::get('srch-term') ? \Input::get('srch-term') : Null;
$projects = Project::whereIn('active', [0, 1]);
if ($criteria != Null) {
switch ($criteria) {
case "active":
$projects = Project::where('active', 1);
break;
case "inactive":
$projects = Project::where('active', 0);
break;
case "featured":
$projects = Project::where('featured', 1);
break;
case "suspended":
$projects = Project::where('status', 1);
break;
case "flaged":
$projects = Project::where('flag', 1);
break;
case "uflaged":
$projects = Project::where('user_flagged', 1);
break;
}
}
if ($searchKey != Null) {
$projects->Where(function ($query) use($searchKey) {
//echo $searchKey; exit;
$query->where('name', 'LIKE', '%' . $searchKey . '%');
});
}
$results = $projects->orderBy('id', 'desc')->paginate($this->show_per_page);
return view('admin.project.index', ['projects' => $results, 'searchKey' => $searchKey, 'dataStat' => $this->project_repo->projectDataStat()]);
}
示例3: postSearch
public function postSearch(Request $request)
{
$searchKey = $request->get('srch-term');
//DB::connection()->enableQueryLog();
$results = Project::whereIn('active', [0, 1])->Where(function ($query) use($searchKey) {
$query->where('name', 'LIKE', '%' . $searchKey . '%');
})->paginate($this->show_per_page);
//$queries = DB::getQueryLog();
if ($results) {
return view('admin.project.index', ['users' => $results, 'result_count' => count($results), 'dataStat' => $this->project_repo->projectDataStat(), 'searchKey' => $searchKey]);
} else {
return Redirect::back()->with('message', 'No results found');
}
}