/**
  * Store a newly created resource in storage.
  *
  * @param $id
  * @return Response
  */
 public function store($id)
 {
     $commentable_id = Input::get('commentable_id');
     $commentable_type = Input::get('commentable_type');
     $val = $this->commentRepository->getCreateForm();
     if (!$val->isValid()) {
         return Redirect::back()->withInput()->withErrors($val->getErrors());
     }
     if (!($record = $this->commentRepository->create(array_merge(['user_id' => Auth::user()->id, 'commentable_id' => $commentable_id, 'commentable_type' => $commentable_type], $val->getInputData())))) {
         return Redirect::back()->with('errors', $this->commentRepository->errors())->withInput();
     }
     if ($commentable_type == 'EventModel') {
         return Redirect::action('EventsController@show', $id)->with('success', trans('word.comment_posted'));
     } else {
         return Redirect::action('BlogsController@show', $id)->with('success', trans('word.comment_posted'));
     }
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $val = $this->contactRepository->getCreateForm();
     if (!$val->isValid()) {
         return Redirect::back()->with('errors', $val->getErrors())->withInput();
     }
     $contact = $this->contactRepository->getFirst();
     if ($contact) {
         if (!$this->contactRepository->update($contact->id, $val->getInputData())) {
             return Redirect::back()->with('errors', $this->contactRepository->errors())->withInput();
         }
     } else {
         if (!$this->contactRepository->create($val->getInputData())) {
             return Redirect::back()->with('errors', $this->contactRepository->errors())->withInput();
         }
     }
     return Redirect::action('AdminContactsController@index')->with('success', 'Saved');
 }
 public static function storeCategory()
 {
     $params = $_POST;
     $category = new Category(array('title' => $params['title'], 'user_id' => self::get_user_logged_in()->id));
     $errors = $category->errors();
     if (count($errors) > 0) {
         Redirect::to('/categories/create', array('errors' => $errors));
     }
     $category->save();
     Redirect::to('/tasks/category/' . $category->id);
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id)
 {
     $this->categoryRepository->findById($id);
     $val = $this->categoryRepository->getEditForm($id);
     if (!$val->isValid()) {
         return Redirect::back()->with('errors', $val->getErrors())->withInput();
     }
     if (!$this->categoryRepository->update($id, $val->getInputData())) {
         return Redirect::back()->with('errors', $this->categoryRepository->errors())->withInput();
     }
     return Redirect::action('AdminCategoriesController@index')->with('success', 'Updated');
 }
 public static function store()
 {
     $params = $_POST;
     $categoryAttributes = array('name' => $params['name']);
     $category = new Category($categoryAttributes);
     $categoryErrors = $category->errors();
     if (count($categoryErrors) == 0) {
         $category->save();
         Redirect::to('/category', array('message' => 'Luokka lisätty onnistuneesti.'));
     } else {
         View::make('/reminders/add_new_category.html', array('categoryErrors' => $categoryErrors, 'categoryAttributes' => $categoryAttributes));
     }
 }