public function post_edit() { $rules = array('id' => 'required|exists:news', 'title' => 'required|max:255', 'content' => 'required', 'image' => 'image|max:2500'); $validation = Validator::make(Input::all(), $rules); if ($validation->fails()) { Messages::add('error', $validation->errors->all()); return Redirect::to('admin/' . $this->views . '/edit/' . Input::get('id'))->with_input(); } else { $article = News::find(Input::get('id')); $article->title = Input::get('title'); $article->url_title = Str::slug(Input::get('title'), '-'); $article->content = Input::get('content'); $article->save(); $upload_details = array('upload_field_name' => 'image', 'upload_type' => 'news', 'upload_link_id' => $article->id, 'remove_existing_for_link' => false, 'title' => $article->title, 'path_to_store' => path('public') . 'uploads/', 'resizing' => array('small' => array('w' => 200, 'h' => 200), 'thumb' => array('w' => 150, 'h' => 150))); $upload = Uploadr::upload($upload_details); Messages::add('success', 'News article saved'); return Redirect::to('admin/' . $this->views . '/edit/' . Input::get('id')); } }
public function post_edit() { $rules = array('id' => 'required|exists:news', 'title' => 'required|max:255', 'content' => 'required', 'image' => 'image|max:2500'); $validation = Validator::make(Input::all(), $rules); if ($validation->fails()) { Messages::add('error', $validation->errors->all()); return Redirect::to('admin/' . $this->views . '/edit')->with_input(); } else { $article = News::find(Input::get('id')); $article->title = Input::get('title'); $article->url_title = Str::slug(Input::get('title'), '-'); $article->content = Input::get('content'); $article->save(); $upload = Uploadr::upload('image', 'news', $article->id, true); if ($upload) { WideImage::load('./uploads/' . $upload->filename)->resize(200, 200)->saveToFile('./uploads/' . $upload->small_filename); WideImage::load('./uploads/' . $upload->small_filename)->crop('center', 'center', 150, 150)->saveToFile('./uploads/' . $upload->thumb_filename); } Messages::add('success', 'News article saved'); return Redirect::to('admin/' . $this->views . ''); } }
public function post_edit() { $rules = array('id' => 'required|exists:gallery_images', 'title' => 'required|max:255', 'gallery_id' => 'required|integer|exists:gallery,id', 'image' => 'image|max:2500'); $validation = Validator::make(Input::all(), $rules); if ($validation->fails()) { Messages::add('error', $validation->errors->all()); return Redirect::to('admin/' . $this->views . '/edit')->with_input(); } else { $image = Image::find(Input::get('id')); $image->title = Input::get('title'); $image->gallery_id = Input::get('gallery_id'); $image->save(); $upload_details = array('upload_field_name' => 'image', 'upload_type' => 'image', 'upload_link_id' => $image->id, 'remove_existing_for_link' => true, 'title' => $image->title, 'path_to_store' => path('public') . 'uploads/', 'resizing' => array('small' => array('w' => 200, 'h' => 200), 'thumb' => array('w' => 150, 'h' => 150))); $upload = Uploadr::upload($upload_details); Messages::add('success', 'Image Saved'); return Redirect::to('admin/' . $this->views . ''); } }