/**
  * @return \Illuminate\Http\RedirectResponse
  */
 public function logout()
 {
     $user_id = $this->auth_user->id;
     $this->auth->logout();
     $this->tracert->log('users', $user_id, $user_id, 'Logout');
     return redirect()->route('admin.login');
 }
 /**
  * @param string $hash
  * @param string $new_revised
  * @return \Illuminate\Http\RedirectResponse
  */
 public function changeStatus($hash, $new_revised)
 {
     $revised = $this->checkRevised($new_revised);
     if ($revised === false) {
         abort(404);
     }
     $comment = $this->comment->byHash($hash);
     $comment->revised = $revised;
     $comment->save();
     $this->tracert->log('comments', $comment->id, $this->auth_user->id, $new_revised);
     $message = trans('blogify::notify.comment_success', ['action' => $new_revised]);
     session()->flash('notify', ['success', $message]);
     return redirect()->route('admin.comments.index');
 }
 /**
  * @param string $hash
  * @return \Illuminate\Http\RedirectResponse
  */
 public function destroy($hash)
 {
     $category = $this->category->byHash($hash);
     $category_name = $category->name;
     $category->delete();
     $this->tracert->log('categories', $category->id, $this->auth_user->id, 'delete');
     $message = trans('blogify::notify.success', ['model' => 'Categorie', 'name' => $category_name, 'action' => 'deleted']);
     session()->flash('notify', ['success', $message]);
     return redirect()->route('admin.categories.index');
 }
 /**
  * @param string $hash
  * @param \jorenvanhocht\Blogify\Requests\ProfileUpdateRequest $request
  * @return \Illuminate\Http\RedirectResponse
  */
 public function update($hash, ProfileUpdateRequest $request)
 {
     $user = $this->user->byHash($hash);
     $user->lastname = $request->name;
     $user->firstname = $request->firstname;
     $user->username = $request->username;
     $user->email = $request->email;
     if ($request->has('newpassword')) {
         $user->password = $this->hash->make($request->newpassword);
     }
     if ($request->hasFile('profilepicture')) {
         $this->handleImage($request->file('profilepicture'), $user);
     }
     $user->save();
     $this->tracert->log('users', $user->id, $this->auth_user->id, 'update');
     $message = trans('blogify::notify.success', ['model' => 'User', 'name' => $user->fullName, 'action' => 'updated']);
     session()->flash('notify', ['success', $message]);
     return redirect()->route('admin.dashboard');
 }
 /**
  * @return void
  */
 private function storeOrUpdateTags()
 {
     foreach ($this->tags as $tag_name) {
         $t = $this->tag->whereName($tag_name)->first();
         if (count($t) > 0) {
             $tag = $t;
         } else {
             $tag = new Tag();
             $tag->hash = $this->blogify->makeHash('tags', 'hash', true);
         }
         $tag->name = $tag_name;
         $tag->save();
         array_push($this->stored_tags, $tag);
         $this->tracert->log('tags', $tag->id, $this->auth_user->id);
     }
 }
 /**
  * Cancel changes in a post
  * and set being_edited_by
  * back to null
  *
  * @param string $hash
  * @return \Illuminate\Http\RedirectResponse
  */
 public function cancel($hash = null)
 {
     if (!isset($hash)) {
         return redirect()->route('admin.posts.index');
     }
     $userHash = $this->auth_user->hash;
     if ($this->cache->has("autoSavedPost-{$userHash}")) {
         $this->cache->forget("autoSavedPost-{$userHash}");
     }
     $post = $this->post->byHash($hash);
     $post->being_edited_by = null;
     $post->save();
     $this->tracert->log('posts', $post->id, $this->auth_user->id, 'canceled');
     $message = trans('blogify::notify.success', ['model' => 'Post', 'name' => $post->name, 'action' => 'canceled']);
     session()->flash('notify', ['success', $message]);
     return redirect()->route('admin.posts.index');
 }