public function post_edit($user_id) { $avatar = ''; if (\Laravel\Input::has_file('avatar')) { $img = \Laravel\Input::file('avatar'); if ($img['size'] > 100000) { return Redirect::to('administration/users/edit/' . $user_id)->with_input()->with('notice-error', __('tinyissue.file_sizes_errors')); } $arr_size = getimagesize($img['tmp_name']); if ($arr_size[0] > 200 && $arr_size[1] > 200) { return Redirect::to('administration/users/edit/' . $user_id)->with_input()->with('notice-error', __('tinyissue.file_size_errors')); } $destination = "../uploads/avatar/"; $extensions = array('image/png', 'image/jpg', 'image/jpeg'); if (in_array($img['type'], $extensions)) { $name = md5($img['name'] . rand(11111, 99999)) . "." . $this->extensions($img['type']); \Laravel\Input::upload('avatar', $destination, $name); $avatar = 'uploads/avatar/' . $name; } else { return Redirect::to('administration/users/edit/' . $user_id)->with_input()->with('notice-error', __('tinyissue.file_type_errors')); } } $update = User::update_user(Input::all(), $user_id, $avatar); if (!$update['success']) { return Redirect::to('administration/users/edit/' . $user_id)->with_input()->with_errors($update['errors'])->with('notice-error', __('tinyissue.we_have_some_errors')); } return Redirect::to('administration/users')->with('notice', __('tinyissue.user_updated')); }
public function post_new() { $image = 'uploads/project/projectDefault.png'; if (\Laravel\Input::has_file('image')) { $img = \Laravel\Input::file('image'); if ($img['size'] > 100000) { return Redirect::to('projects/new')->with_input()->with('notice-error', __('tinyissue.file_sizes_errors')); } $arr_size = getimagesize($img['tmp_name']); if ($arr_size[0] > 200 && $arr_size[1] > 200) { return Redirect::to('projects/new')->with_input()->with('notice-error', __('tinyissue.file_size_errors')); } $destination = "../uploads/project/"; $extensions = array('image/png', 'image/jpg', 'image/jpeg'); if (in_array($img['type'], $extensions)) { $name = md5($img['name'] . rand(11111, 99999)) . "." . $this->extensions($img['type']); \Laravel\Input::upload('image', $destination, $name); $image = 'uploads/project/' . $name; } else { return Redirect::to('projects/new')->with_input()->with('notice-error', __('tinyissue.file_type_errors')); } } $create = Project::create_project(Input::all(), $image); if ($create['success']) { return Redirect::to($create['project']->to()); } return Redirect::to('projects/new')->with_errors($create['errors'])->with('notice-error', __('tinyissue.we_have_some_errors')); }
public function post_edit() { /* Delete the project */ if (Input::get('delete')) { Project::delete_project(Project::current()); return Redirect::to('projects')->with('notice', __('tinyissue.project_has_been_deleted')); } $image = ''; if (\Laravel\Input::has_file('image')) { $img = \Laravel\Input::file('image'); if ($img['size'] > 100000) { return Redirect::to(Project::current()->to('edit'))->with_input()->with('notice-error', __('tinyissue.file_sizes_errors')); } $arr_size = getimagesize($img['tmp_name']); if ($arr_size[0] > 200 && $arr_size[1] > 200) { return Redirect::to(Project::current()->to('edit'))->with_input()->with('notice-error', __('tinyissue.file_size_errors')); } $destination = "../uploads/project/"; $extensions = array('image/png', 'image/jpg', 'image/jpeg'); if (in_array($img['type'], $extensions)) { $name = md5($img['name'] . rand(11111, 99999)) . "." . $this->extensions($img['type']); \Laravel\Input::upload('image', $destination, $name); $image = 'uploads/project/' . $name; } else { return Redirect::to(Project::current()->to('edit'))->with_input()->with('notice-error', __('tinyissue.file_type_errors')); } } /* Update the project */ $update = Project::update_project(Input::all(), Project::current(), $image); if ($update['success']) { return Redirect::to(Project::current()->to('edit'))->with('notice', __('tinyissue.project_has_been_updated')); } return Redirect::to(Project::current()->to('edit'))->with_errors($update['errors'])->with('notice-error', __('tinyissue.we_have_some_errors')); }
/** * Get the proper error message for an attribute and size rule. * * @param string $bundle * @param string $attribute * @param string $rule * @return string */ protected function size_message($bundle, $attribute, $rule) { // There are three different types of size validations. The attribute // may be either a number, file, or a string. If the attribute has a // numeric rule attached to it, we can assume it is a number. If the // attribute is in the file array, it is a file, otherwise we can // assume the attribute is simply a string. if ($this->has_rule($attribute, $this->numeric_rules)) { $line = 'numeric'; } elseif (array_key_exists($attribute, Input::file())) { $line = 'file'; } else { $line = 'string'; } return Lang::line("{$bundle}validation.{$rule}.{$line}")->get($this->language); }
/** * Get the proper error message for an attribute and size rule. * * @param string $bundle * @param string $attribute * @param string $rule * @return string */ protected function size_message($bundle, $attribute, $rule) { // There are three different types of size validations. The attribute // may be either a number, file, or a string, so we'll check a few // things to figure out which one it is. if ($this->has_rule($attribute, $this->numeric_rules)) { $line = 'numeric'; } elseif (array_key_exists($attribute, Input::file())) { $line = 'file'; } else { $line = 'string'; } return Lang::line("{$bundle}validation.{$rule}.{$line}")->get($this->language); }
/** * Get the proper error message for an attribute and rule. * * @param string $attribute * @param string $rule * @return string */ protected function message($attribute, $rule) { // First we'll check for developer specified, attribute specific messages. // These messages take first priority. They allow the fine-grained tuning // of error messages for each rule. if (array_key_exists($attribute . '_' . $rule, $this->messages)) { return $this->messages[$attribute . '_' . $rule]; } elseif (array_key_exists($rule, $this->messages)) { return $this->messages[$rule]; } elseif (in_array($rule, $this->size_rules)) { if ($this->has_rule($attribute, $this->numeric_rules)) { $line = 'numeric'; } else { $line = array_key_exists($attribute, Input::file()) ? 'file' : 'string'; } return Lang::line("validation.{$rule}.{$line}")->get($this->language); } else { return Lang::line("validation.{$rule}")->get($this->language); } }
protected function size_message($bundle, $attribute, $rule) { if ($this->has_rule($attribute, $this->numeric_rules)) { $line = 'numeric'; } elseif (array_key_exists($attribute, Input::file())) { $line = 'file'; } else { $line = 'string'; } return Lang::line("{$bundle}validation.{$rule}.{$line}")->get($this->language); }