本文整理汇总了PHP中app\models\Project::where方法的典型用法代码示例。如果您正苦于以下问题:PHP Project::where方法的具体用法?PHP Project::where怎么用?PHP Project::where使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Project
的用法示例。
在下文中一共展示了Project::where方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getSearch
public function getSearch()
{
$keyword = \Input::get('keyword');
$projects = Project::where('name', '=~', ".*{$keyword}.*")->paginate(6);
$projects->appends(['keyword' => $keyword]);
return view('users.project.main')->with('projects', $projects)->with('keyword', $keyword);
}
示例2: show
/**
* Display the specified resource.
*
* @param int $id
* @return Response
*/
public function show($user, $project_name, $story_id)
{
$project_name = str_post_slug($project_name);
$project = Project::where('name', $project_name)->first();
$project_id = $project->id;
$story = Story::find($story_id);
return view('user.story.show', compact('user', 'project_name', 'project_id', 'story', 'project'));
}
示例3: search
public function search()
{
$ss = Input::get('searchbox');
$data['orgs'] = Organisation::where('organisation', 'like', '%' . $ss . '%')->get();
$data['pros'] = Project::where('project', 'like', '%' . $ss . '%')->get();
$data['tags'] = Tag::where('tag', 'like', '%' . $ss . '%')->get();
$data['ss'] = $ss;
return view('search', $data);
}
示例4: sortByCriteria
public function sortByCriteria($criteria = null, $authId = Null)
{
switch ($criteria) {
case 'active':
$users = $this->model->where('type', 'general')->where('status', '1')->count();
return $users;
break;
case 'inactive':
$users = $this->model->where('type', 'general')->where('status', '0')->count();
return $users;
break;
case 'facebook':
$users = $this->model->where('type', 'general')->where('register_type', 'facebook')->count();
return $users;
break;
case 'googleplus':
$users = $this->model->where('type', 'general')->where('register_type', 'googleplus')->count();
return $users;
break;
case 'twitter':
$users = $this->model->where('type', 'general')->where('register_type', 'twitter')->count();
return $users;
break;
case 'all':
$users = $this->model->where('type', 'general')->count();
return $users;
break;
case 'my_posted_projects':
$myPostedProjectLists = \App\Models\Project::where('active', '1')->where('user_id', $authId)->count();
return $myPostedProjectLists;
break;
case 'my_posted_projects':
$myPostedProjectLists = \App\Models\ProjectUpdates::where('active', '1')->where('user_id', $authId)->count();
return $myPostedProjectLists;
break;
case 'my_backed_projects':
$MyFundedProjectLists = array();
$lists = \App\Models\ProjectFund::where('U_ID', $authId)->whereIn('status', ['Pledged', 'Funded'])->orderBy('created_at', 'desc')->get();
if (count($lists) > 0) {
foreach ($lists as $val) {
$MyFundedProjectLists[] = $val->P_ID;
}
}
$result = array_unique($MyFundedProjectLists);
return count($result);
break;
case 'my_likes_projects':
$myLikeProjects = \App\Models\ProjectFollowers::where('user_id', $authId)->count();
return $myLikeProjects;
break;
case 'my_following_projects':
$myFllowingProjects = \App\Models\ProjectFollowers::where('user_id', $authId)->count();
return $myFllowingProjects;
break;
}
}
示例5: projects
public function projects($search = null, $categories = null, $orderby = null, $paginate = true)
{
$result = null;
/**
* As buscas não são complementares: ou se filtra por termo ou por categoria(s)
* mas nunca por ambos.
*/
if ($paginate) {
/**
* SEARCH
* Se existe um termo de busca, retorna a lista filtrada pelo termo
*/
if (!is_null($search) && !empty($search)) {
return Project::where('name', 'like', "%{$search}%")->paginate(env('PAGINATION_ITEMS', 10));
}
/**
* CATEGORIES
* Se existe uma ou mais categoria(s), retorna a lista filtrada por ela(s)
*/
if (!is_null($categories) && !empty($categories)) {
/**
* Compila-se uma lista distinta projetos associados às caregorias informadas
*/
$projectsFromCategories = DB::table('category_project')->whereIn('category_id', $categories)->distinct()->get(['project_id']);
$projectIds = [];
/**
* Compila-se uma lista apenas com os IDs dos projetos pois
* a lista acima possui array com objetos: [0 => StdClass('project_id': 1)]
*/
foreach ($projectsFromCategories as $value) {
$projectIds[] = $value->project_id;
}
/**
* Por fim retorna-se a lista dos projetos
*/
return Project::whereIn('id', $projectIds)->paginate(env('PAGINATION_ITEMS', 10));
}
/**
* ORDER BY
* Se existe ordenação, retorna a lista ordenada pela instrução recebida
*/
if (!is_null($orderby) && !empty($orderby)) {
$order = explode('|', $orderby);
return Project::orderBy($order[0], $order[1])->paginate(env('PAGINATION_ITEMS', 10));
}
/**
* Caso nem exista nem termo de busca nem categorias, retorna-se a lista completa, paginada.
*/
return Project::paginate(env('PAGINATION_ITEMS', 10));
}
/**
* Este, sem paginação, visa atender à API
*/
return Project::where('name', 'like', "%{$search}%")->get();
}
示例6: index
public function index()
{
$search['text'] = Input::get('search_text');
$search['type'] = Input::get('search_type');
if ($search['type'] == 'user') {
$list = Project::where('manage', 'like', "%{$search['text']}%")->orderBy('id', 'desc')->paginate(15);
} else {
if ($search['type'] == 'name') {
$list = Project::where('name', 'like', "%{$search['text']}%")->orderBy('id', 'desc')->paginate(15);
} else {
$list = Project::orderBy('id', 'desc')->paginate(15);
}
}
return View::make('admin.project_list')->withlist($list)->withsearch($search);
}
示例7: postProject
function postProject(Request $request)
{
/* Make sure the requesting user has a group */
$group = Auth::user()->student->group;
if (!$group) {
return redirect('student/project');
}
$project_id = $request->get('project');
/* When an advanced project has been assigned, no change is possible */
if (!Project::where('advanced', 0)->find($project_id)) {
return redirect('student/project');
}
$project = $group->project;
/* Store the change, but only when not chosen or before deadline. */
if (!$project || !(time() > strtotime(env("WEBDB_PROJECT_DEADLINE")) || $project->advanced)) {
$group->project()->associate(Project::find($project_id));
$group->save();
}
return redirect('student/project');
}
示例8: Projectlist
public function Projectlist($id = Null, $type = Null)
{
$projcon = array("0", "3");
if ($type == 'genres') {
$staffPickRow = Project::where('active', '1')->where('live', '1')->where('project_genre_id', $id)->where('featured', '1')->take(1)->get();
if (count($staffPickRow) > 0) {
$allLists = Project::where('active', '1')->where('live', '1')->where('project_genre_id', $id)->where('featured', '1')->take(1)->get();
} else {
$allLists = Project::where('active', '1')->where('live', '1')->where('project_genre_id', $id)->orderBy('created_at', 'desc')->take(1)->get();
}
} elseif ($type == 'categories') {
$allLists = Project::where('active', '1')->where('live', '1')->where('P_CAT_ID', $id)->whereIn('featured', ['0', '1'])->take(1)->get();
} elseif ($type == 'popular') {
$allLists = Project::where('active', '1')->where('live', '1')->orderBy('rank', 'DESC')->take(3)->get();
} elseif ($type == 'latest') {
$allLists = Project::where('active', '1')->where('live', '1')->orderBy('created_at', 'desc')->take(3)->get();
} else {
$allLists = Project::where('active', '1')->where('live', '1')->get();
}
$result = $this->project_repo->prepareListObj($allLists);
return $result;
}
示例9: 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()]);
}
示例10: all
public function all($type = Null, $criteria = Null)
{
switch ($type) {
case "project":
if ($criteria != Null) {
$lists = \App\Models\Project::where('status', $criteria)->count();
} else {
$lists = \App\Models\Project::all()->count();
}
break;
case "user":
$lists = \App\User::all()->count();
break;
case "category":
$lists = \App\Models\Category::all()->count();
break;
case "genre":
$lists = \App\Models\Genre::all()->count();
break;
default:
$lists = 0;
}
return $lists;
}
示例11: getUimodal
public function getUimodal($modalFor, $user_id)
{
if (isset($modalFor) && $modalFor == 'project-count') {
$projectLists = \App\Models\Project::where('user_id', $user_id)->get();
echo view('admin.user.uimodal', ['modalFor' => $modalFor, 'user_id' => $user_id, 'projectLists' => $projectLists]);
} elseif (isset($modalFor) && $modalFor == 'user-login-count') {
$logHistory = \App\Models\LogActivity::where('user_id', $user_id)->where('action', 'user-login')->orderBy('timestamp')->get();
echo view('admin.user.uimodal', ['modalFor' => $modalFor, 'user_id' => $user_id, 'logHistory' => $logHistory]);
} elseif (isset($modalFor) && $modalFor == 'project_funded_count') {
$fundedDetails = \App\Models\ProjectFund::where('U_ID', $user_id)->where('status', 'Pledged')->orderBy('created_at')->get();
echo view('admin.user.uimodal', ['modalFor' => $modalFor, 'user_id' => $user_id, 'fundedDetails' => $fundedDetails]);
}
}
示例12: getOwedByUserAttribute
/**
* Get the total amount the current user owes the user
* @return mixed
*/
public function getOwedByUserAttribute()
{
$payer = Payer::find(Auth::user()->id);
//Find the projects belonging to the current user and $this user
$projects_with_payee = Project::where('payer_id', $payer->id)->where('payee_id', $this->id)->lists('id');
//Find the timers belonging to those projects,
//but only those that have not been paid for
$timers_with_payee = Timer::whereIn('project_id', $projects_with_payee)->where('paid', 0)->lists('id');
//Find the amount owed
$owed = Timer::whereIn('id', $timers_with_payee)->sum('price');
return (double) $owed;
}
示例13: getWidget
public function getWidget($id)
{
$updateRank = $this->project_repo->updateprojectrank($id);
$featuredProjects = Project::where('id', $id)->get();
$total_backers = ProjectFund::where('P_ID', $id)->count();
$total_fund = ProjectFund::where('P_ID', $id)->sum('paid_amount');
$funded = number_format($total_fund / $featuredProjects[0]['funding_goal'] * 100) . "%";
return view('project.embed', ['_featuredProducts' => $featuredProjects, '_totalBackers' => $total_backers, '_totalFunds' => $total_fund, '_funded' => $funded]);
}
示例14: check_repeat
private function check_repeat($projects_name)
{
$project = Project::where('projects_name', $projects_name)->count();
if ($project) {
return true;
}
}
示例15: function
| Here is where you will register all of the routes in an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/
Route::get('/', function () {
return view('home');
});
Route::get('/about', function () {
return view('about');
});
Route::get('/contact', function () {
return view('contact');
});
Route::get('/projects', function () {
$projects = Project::where('active', 1)->get();
return view('projects', ['projects' => $projects]);
});
Route::post('/contact', function (Request $request) {
$name = $request->input('name');
$email = $request->input('email');
$message = $request->input('message');
if ($email && $name && $message) {
$contactData = ['name' => $name, 'email' => $email, 'message' => $message];
Contact::create($contactData);
}
dispatch(new \App\Jobs\SendContactEmail($name, $email, $message));
return view('mailSent');
});
/*
|--------------------------------------------------------------------------