Exemplo n.º 1
0
 /**
  * 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);
 }
 /**
  * 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);
 }
Exemplo n.º 3
0
 /**
  * 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);
 }