public static function boot()
 {
     parent::boot();
     ArticleImage::creating(function ($image) {
         $image->order = ArticleImage::where('blog_article_id', '=', $image->blog_article_id)->count() + 1;
     });
     ArticleImage::deleted(function ($image) {
         $images = ArticleImage::where('blog_article_id', '=', $image->blog_article_id)->orderBy('order', 'asc')->get();
         $i = 1;
         foreach ($images as $image) {
             $image->order = $i;
             $i++;
             $image->save();
         }
     });
 }
 public function order($id)
 {
     $image = ArticleImage::findOrFail($id);
     $order = $image->order;
     $image->order = \Input::get('order');
     $image->save();
     if ($order > $image->order) {
         $images = ArticleImage::where('blog_article_id', '=', $image->blog_article_id)->orderBy('order', 'asc')->orderBy('updated_at', 'desc')->get();
     } else {
         $images = ArticleImage::where('blog_article_id', '=', $image->blog_article_id)->orderBy('order', 'asc')->orderBy('updated_at', 'asc')->get();
     }
     $i = 1;
     foreach ($images as $image) {
         $image->order = $i;
         $i++;
         $image->save();
     }
     \Session::flash('message', 'Article Image order successfully updated!');
     return \Redirect::back();
 }