Beispiel #1
0
 public function edit($id)
 {
     $post = $this->services->getEdit($id);
     authorize_other('edit_services', 'edit_others_services', $post->author_id);
     $data = ['title' => 'Cập nhật Dịch vụ', 'item' => $post];
     return view('backend.services.edit', $data);
 }
Beispiel #2
0
 public function edit($id)
 {
     $page = $this->page->getEdit($id);
     authorize_other('edit_pages', 'edit_others_pages', $page->author_id);
     $data = ['title' => 'Cập nhật trang', 'item' => $page, 'templates' => ['' => 'Giao diện mặc định'] + $this->templates];
     return view('backend.page.edit', $data);
 }
Beispiel #3
0
 public function edit($id)
 {
     $cats = $this->tax->all('cat', current_lang());
     $post = $this->post->getEdit($id);
     authorize_other('edit_posts', 'edit_others_posts', $post->author_id);
     $currcats = $post->cats()->lists('id')->toArray();
     $data = ['title' => 'Cập nhật bài viết', 'cat_checklists' => $this->tax->cat_checklists($cats, 0, $currcats), 'availtags' => $this->tax->listType('tag'), 'currtags' => $post->tags()->lists('id')->toArray(), 'item' => $post];
     return view('backend.post.edit', $data);
 }
Beispiel #4
0
 public function update($id, Request $request)
 {
     authorize_other('edit_users', 'edit_others_users', $id);
     try {
         $this->user->update($id, $request);
         return redirect()->route('admin.user.index')->with('Mess', 'Cập nhật thành công');
     } catch (\App\Exceptions\ValidateException $ex) {
         return redirect()->back()->withInput()->withErrors($ex->getError());
     }
 }
Beispiel #5
0
 public function update($id, $request)
 {
     $post = $this->find($id);
     authorize_other('edit_posts', 'edit_others_posts', $post->author_id);
     if ($this->valid($request->all(), $this->rules())) {
         $post->image = get_path($request->get('image'));
         $post->status = $request->get('status');
         $post->author_id = auth()->user()->id;
         $post->update();
         $sync_langs = [];
         foreach (get_langs() as $lang) {
             $datalang = $request->get($lang->code);
             $name = $datalang['name'];
             $slug = $datalang['slug'];
             $post_desc = ['name' => $name, 'slug' => trim($slug) == '' ? toSlug($name) : toSlug($slug), 'excerpt' => $datalang['excerpt'], 'content' => $datalang['content']];
             $sync_langs[$lang->id] = $post_desc;
         }
         $post->langs()->sync($sync_langs);
         $post->cats()->detach();
         if ($request->has('cats')) {
             $post->cats()->attach($request->get('cats'));
         }
         if ($request->has('newtags')) {
             $newtags = $request->get('newtags');
             foreach ($newtags as $tag) {
                 $newtag = new $this->tax();
                 $newtag->type = 'tag';
                 $newtag->dfname = $tag;
                 $newtag->dfslug = toSlug($tag);
                 $newtag->save();
                 $post->tags()->attach($newtag->id);
             }
         }
         if ($request->has('availtags')) {
             $post->tags()->attach($request->get('availtags'));
         }
     } else {
         throw new ValidateException($this->getError());
     }
 }
Beispiel #6
0
 public function delete($id)
 {
     $page = $this->find($id);
     authorize_other('delete_pages', 'delete_others_pages', $page->author_id);
     $page->langs()->detach();
     $page->delete();
 }