本文整理汇总了PHP中Project::orderBy方法的典型用法代码示例。如果您正苦于以下问题:PHP Project::orderBy方法的具体用法?PHP Project::orderBy怎么用?PHP Project::orderBy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Project
的用法示例。
在下文中一共展示了Project::orderBy方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getData
/**
* [getData]
* @return [type] [description]
*/
public function getData()
{
$Model = $this->modelName;
$all_reminders = $Model::all($this->dataTableColumns);
$data = [];
foreach ($all_reminders as $reminder) {
// load relations
$load_curr_project = $reminder->project;
$load_curr_user = $reminder->user;
$curr_reminder = $reminder;
Debugbar::info($reminder);
if (isset($reminder->user_id) && isset($reminder->project_id)) {
$curr_proj = (object) ['id' => $reminder->reminder_id, 'name' => $reminder->project->name];
$curr_user = (object) ['id' => $reminder->user_id, 'username' => $reminder->user->username];
$curr_entry = (object) ['DT_RowId' => 'row_' . $reminder->id, 'reminders' => $curr_reminder, 'users' => $curr_user, 'projects' => $curr_proj];
$data[] = $curr_entry;
}
}
$all_projects = Project::orderBy('name', 'DESC')->get(['id', 'name']);
$projects = [];
foreach ($all_projects as $project) {
$tmp_project = (object) ['value' => $project->id, 'label' => $project->name];
$projects[] = $tmp_project;
}
$all_users = User::all(['id', 'username']);
$users = [];
foreach ($all_users as $user) {
$tmp_user = (object) ['value' => $user->id, 'label' => $user->username];
$users[] = $tmp_user;
}
$ret = ['data' => $data, 'projects' => $projects, 'users' => $users];
return Response::json($ret);
}
示例2: getProjects
private function getProjects()
{
$projects = [];
foreach (\Project::orderBy('title', 'ASC')->get() as $project) {
$projects[$project['id']] = $project['title'];
}
return $projects;
}
示例3: index
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index()
{
if (Input::get('search') == null || Input::get('search') == '') {
$projects = Project::orderBy('created_at', 'DESC')->paginate(5);
} else {
$projects = Project::where('title', 'like', '%' . Input::get('search') . '%')->orderBy('projects.created_at', 'DESC')->paginate(5);
}
return View::make('admin/projects/index', compact('projects'));
}
示例4: getAllProjects
public function getAllProjects()
{
$all_projects = Project::orderBy('name', 'ASC')->get(['id', 'name', 'company_id']);
$projects = [];
foreach ($all_projects as $project) {
$projects[] = (object) ['value' => $project->id, 'label' => utf8_encode($project->company_id . '|' . $project->name)];
}
return $projects;
}
示例5: index
public function index()
{
$projects = Project::orderBy('sortorder')->get();
$miscs = Misc::all();
$bio = Misc::where('name', '=', 'bio')->firstOrFail();
$resumeURL = Misc::where('name', '=', 'resumeURL')->firstOrFail();
$githubURL = Misc::where('name', '=', 'githubURL')->firstOrFail();
return View::make('projects.index')->with('projects', $projects)->with('bio', $bio)->with('resumeURL', $resumeURL)->with('githubURL', $githubURL);
}
示例6: paginate
/**
* Get paginated projects.
*
* @param int $page Number of projects per page
* @param int $limit Results per page
* @param bool $all Show published or all
*
* @return StdClass Object with $items and $totalItems for pagination
*/
public function paginate($page = 1, $limit = 10, $all = false)
{
$result = new \StdClass();
$result->page = $page;
$result->limit = $limit;
$result->totalItems = 0;
$result->items = array();
$query = $this->project->orderBy('created_at', 'DESC')->where('lang', $this->getLang());
$projects = $query->skip($limit * ($page - 1))->take($limit)->get();
$result->totalItems = $this->totalProjects();
$result->items = $projects->all();
return $result;
}
示例7: show
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function show($page = NULL)
{
parent::show();
if (is_numeric($page)) {
$page = Page::find($page);
}
if ($page == NULL) {
return View::make('404', compact('settings'));
}
$projects = Project::orderBy('id', 'asc')->paginate(2);
$seo = $page->seo;
$banner = TRUE;
return View::make('pages.show', compact('page', 'banner', 'settings', 'seo', 'projects'));
}
示例8: getData
/**
* [getData - get all projects data for DT]
* @return [json] [DT compatible object]
*/
public function getData($model = null)
{
$Model = $this->modelName;
$num_skip = 0;
$num_items = 10;
$recordsTotal = 0;
$recordsFiltered = 0;
if (isset($_GET['start'])) {
$num_skip = (int) $_GET['start'];
}
if (isset($_GET['length'])) {
$num_items = (int) $_GET['length'];
}
if (isset($_GET['search'])) {
$search_value = $_GET['search']['value'];
}
$all_projects = Project::orderBy('projects.id', 'DESC');
if ($model !== null) {
$all_projects->where('projects.company_id', '=', (int) $model->id);
if (!empty($search_value)) {
$all_projects->whereRaw("(projects.name LIKE '%" . $search_value . "%')");
}
} else {
if (!empty($search_value)) {
$all_projects->join('companies', 'projects.company_id', '=', 'companies.id')->whereRaw("(projects.name LIKE '%" . $search_value . "%' OR companies.bedrijfsnaam LIKE '%" . $search_value . "%')");
}
}
$recordsTotal = $all_projects->count();
$recordsFiltered = $recordsTotal;
if ($num_skip > 0) {
$all_projects->skip($num_skip);
}
$all_projects = $all_projects->take($num_items)->get();
Debugbar::info(count($all_projects));
$data = [];
foreach ($all_projects as $project) {
// load relations
$load_curr_company = $project->company;
$curr_company = $project->company !== NULL ? (object) ['id' => $project->company_id, 'bedrijfsnaam' => utf8_encode($project->company->bedrijfsnaam)] : (object) null;
$data[] = (object) ['DT_RowId' => 'row_' . $project->id, 'projects' => $project, 'companies' => $curr_company];
}
$ret = ['data' => $data, 'recordsTotal' => $recordsTotal, 'recordsFiltered' => $recordsFiltered, 'companies' => $this->getAllCompanies()];
return Response::json($ret);
}
示例9: function
}
}
Route::get('thumbtest', function () {
$images = Image::all();
$html = "";
foreach ($images as $image) {
$source = $image->url;
$dest = public_path() . "/thumbs/" . $image->id . ".jpg";
$html .= "Source: " . $image->url . " --- Dest: {$dest}<br>";
make_thumb($source, $dest, 100);
}
return $html;
});
Route::get('publish', function () {
ob_start();
$projects = Project::orderBy('sortorder')->get();
$bio = Misc::where('name', '=', 'bio')->firstOrFail();
$resumeURL = Misc::where('name', '=', 'resumeURL')->firstOrFail();
$githubURL = Misc::where('name', '=', 'githubURL')->firstOrFail();
$images = Image::all();
foreach ($images as $image) {
$source = $image->url;
$dest = public_path() . "/thumbs/{$image->id}.jpg";
echo "Writing thumbnail {$dest}...";
if (make_thumb($source, $dest, 200)) {
echo "success";
$image->thumbnail = asset("thumbs/{$image->id}.jpg");
} else {
echo "failure";
$image->thumbnail = $source;
}
示例10: getExamples
/**
* @param int $limit
* @return mixed
*/
public function getExamples($limit = 4)
{
return $this->project->orderBy('date', 'desc')->take($limit)->get();
}