/**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     // Declare the rules for the form validation
     $rules = array('title' => 'required|min:3', 'content' => 'required|min:3|not_in:<p></p>', 'image' => 'image|max:30000000');
     // Create a new validator instance from our validation rules
     $validator = Validator::make(Input::all(), $rules);
     // If validation fails, we'll exit the operation now.
     if ($validator->fails()) {
         // Ooops.. something went wrong
         return Redirect::back()->withInput()->withErrors($validator);
     }
     // Create a new portfolio post
     $post = new PortfolioPost();
     // Update the portfolio post data
     $post->title = e(Input::get('title'));
     if (empty($post->slug)) {
         $post->slug = e(Str::slug(Input::get('title')));
     } else {
         $post->slug = e(Str::slug(Input::get('slug')));
     }
     $post->content = e(Input::get('content'));
     $post->draft = e(Input::get('draft'));
     $post->lang = e(Input::get('lang'));
     $post->content = e(Input::get('content'));
     $post->meta_title = e(Input::get('meta-title'));
     $post->meta_description = e(Input::get('meta-description'));
     $post->meta_keywords = e(Input::get('meta-keywords'));
     $post->user_id = Sentry::getId();
     $image = Input::file('image');
     if (!empty($image)) {
         $filename = $post->slug . '_' . date('d-m-Y') . '.' . $image->getClientOriginalExtension();
         $uploadSuccess = Input::file('image')->move($this->destinationPath, $filename);
         $post->image = e($filename);
     }
     // Was the portfolio post created?
     if ($post->save()) {
         $tags = explode(',', Input::get('portfoliotags'));
         foreach ($tags as $tag) {
             if (PortfolioTag::where('name', '=', $tag)->count() == 0) {
                 $newTag = new PortfolioTag();
                 $newTag->name = ucwords($tag);
                 $newTag->slug = Str::slug($tag);
                 $newTag->save();
             } else {
                 $newTag = PortfolioTag::where('name', '=', $tag)->first();
             }
             $post->tags()->attach($newTag->id);
         }
         // Redirect to the new portfolio post page
         return Redirect::route('portfolio.show', array('portfolio' => $post->slug))->with('success', Lang::get('modules/portfolio/messages.success.create'));
     }
     // Redirect to the portfolio post create page
     return Redirect::route('portfolio.create')->with('error', Lang::get('modules/portfolio/messages.error.create'));
 }