本文整理汇总了PHP中app\Category::All方法的典型用法代码示例。如果您正苦于以下问题:PHP Category::All方法的具体用法?PHP Category::All怎么用?PHP Category::All使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Category
的用法示例。
在下文中一共展示了Category::All方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: edit
/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return Response
*/
public function edit($id)
{
// get the job
$job = Job::find($id);
$category = Category::All();
// show the edit form and pass the nerd
return View::make('job.edit')->with('job', $job)->with('category', $category);
}
示例2: update
/**
* Update a new Note: load date and forward to view
*
* @param Request $request, Note $note
* @return view
*/
public function update(Request $request, Note $note)
{
$categories = Category::All(['id', 'name']);
$tags = Tag::All(['id', 'name', 'css_class']);
$user = User::find($request->user()->id);
//get next id
$notes = DB::table('notes')->leftjoin('categories', 'notes.category_id', '=', 'categories.id')->select('notes.id as id');
//handle categories
$ses_category_id = $request->session()->get('note_category_id');
if ($ses_category_id) {
$notes->where('category_id', '=', $ses_category_id);
}
//handle search tags
$search = $request->session()->get('note_search');
if (strlen($search) > 0) {
$search_array = explode(",", $search);
$tags_sel = Tag::find($search_array);
foreach (explode(",", $search) as $s) {
$notes->where('tag_ids', 'like', "%," . $s . ",%");
}
}
//handle search
if ($request->btn_search == "s") {
if ($request->search_text) {
$request->session()->put('note_search_text', $request->search_text);
} else {
$request->session()->forget('note_search_text');
}
}
$search_text = $request->session()->get('note_search_text');
if (strlen($search_text) > 0) {
$notes->where(function ($query) use($search_text) {
$query->where('notes.title', 'like', "%" . $search_text . "%")->orWhere('notes.description', 'like', "%" . $search_text . "%");
});
}
//handle sort order
$order = $request->session()->get('note_order');
if (!$order) {
$order = 'title';
}
//handle sort direction
$dir = $request->session()->get('note_dir');
if (!$dir) {
$dir = 'ASC';
}
$pagination_number = $request->session()->get('pagination_number');
$notes = $notes->orderBy('notes.' . $order, $dir)->orderBy('notes.title', 'ASC')->paginate($pagination_number);
$previous_id = 0;
$next_id = 0;
$counter = 0;
$found = false;
foreach ($notes as $temp) {
if ($found) {
$next_id = $temp->id;
break;
}
if ($temp->id == $note->id) {
$found = true;
}
$counter++;
if (!$found) {
$previous_id = $temp->id;
}
}
return view('notes.update', ['categories' => $categories, 'note' => $note, 'category_id' => False, 'tags' => $tags, 'tags_sel' => $tags_sel = Tag::find(explode(",", $note->tag_ids)), 'previous_id' => $previous_id, 'next_id' => $next_id, 'counter' => $counter, 'total' => count($notes), 'page' => $request->session()->get('note_page'), 'filetab' => $request->filetab])->withNote($note);
}
示例3: update
/**
* Update a new task: load date and forward to view
*
* @param Request $request, Task $task
* @return view
*/
public function update(Request $request, Tag $tag)
{
$categories = Category::All(['id', 'name']);
return view('tags.update', ['categories' => $categories, 'tag' => $tag, 'category_id' => False, 'page' => $request->session()->get('tag_page')])->withTag($tag);
}