Exemplo n.º 1
0
 public static function update($id)
 {
     self::check_logged_in();
     $params = $_POST;
     $attributes = array('id' => $id, 'name' => $params['name']);
     $vendor = new Vendor($attributes);
     $errors = $vendor->errors();
     if (count($errors) > 0) {
         $vendor = Vendor::find($id);
         View::make('vendor/edit.html', array('errors' => $errors, 'given_name' => $params['name'], 'vendor' => $vendor));
     } else {
         $vendor->update();
         Redirect::to('/vendors/' . $vendor->id, array('message' => 'The vendor has been modified successfully!'));
     }
 }