Example #1
0
 /**
  * This function it will analyse the new data with the old one and check what it will be updated in the defined project
  */
 public function post_edit()
 {
     $id = Input::get('id');
     $olddata = Project::find($id);
     $post_title = Input::get('title');
     $post_body = Input::get('project_body');
     $slug = Str::slug(Input::get('title'));
     $edit_info = array();
     if (strcmp($olddata->title, $post_title) != 0) {
         $edit_info["title"] = $post_title;
     }
     if (strcmp($olddata->post_body, $post_body) != 0) {
         $edit_info["project_body"] = $post_body;
     }
     if (strcmp($olddata->slug, $slug) != 0) {
         $edit_info["slug"] = $slug;
     }
     $rules = array('cover' => 'image', 'slug' => 'unique:projects', 'title' => 'unique:projects|min:3|max:255');
     $validation = Validator::make($edit_info, $rules);
     if ($validation->fails()) {
         return Redirect::to_route('dojo::edit_project', $id)->with_errors($validation)->with('user', $user);
     } else {
         Project::update($id, $edit_info);
         return Redirect::to_route('dojo::index_project');
     }
 }