Applied fixes from StyleCI
This commit is contained in:

committed by
StyleCI Bot

parent
09bf25b5e2
commit
e2390f67d4
@@ -9,14 +9,15 @@ use App\Http\Requests\Request;
|
||||
*
|
||||
* @author Ladybird <info@ladybirdweb.com>
|
||||
*/
|
||||
class TicketRequest extends Request {
|
||||
|
||||
class TicketRequest extends Request
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize() {
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -25,39 +26,42 @@ class TicketRequest extends Request {
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules() {
|
||||
$error = "";
|
||||
public function rules()
|
||||
{
|
||||
$error = '';
|
||||
try {
|
||||
$size = $this->size();
|
||||
if ($size > 800 || $size==0) {
|
||||
throw new \Exception("File size exceeded", 422);
|
||||
if ($size > 800 || $size == 0) {
|
||||
throw new \Exception('File size exceeded', 422);
|
||||
}
|
||||
} catch (\Exception $ex) {
|
||||
dd($ex);
|
||||
$error = $this->error($ex);
|
||||
$error = $this->error($ex);
|
||||
}
|
||||
// return [
|
||||
// 'attachment' => 'not_in:'.$error,
|
||||
// ];
|
||||
}
|
||||
|
||||
public function size() {
|
||||
|
||||
public function size()
|
||||
{
|
||||
$files = $this->file('attachment');
|
||||
if (!$files) {
|
||||
throw new \Exception("exceeded", 422);
|
||||
}
|
||||
throw new \Exception('exceeded', 422);
|
||||
}
|
||||
$size = 0;
|
||||
if (count($files) > 0) {
|
||||
foreach ($files as $file) {
|
||||
$size +=$file->getSize();
|
||||
$size += $file->getSize();
|
||||
}
|
||||
}
|
||||
|
||||
return $size;
|
||||
}
|
||||
|
||||
public function error($e) {
|
||||
public function error($e)
|
||||
{
|
||||
if ($this->ajax() || $this->wantsJson()) {
|
||||
|
||||
$message = $e->getMessage();
|
||||
if (is_object($message)) {
|
||||
$message = $message->toArray();
|
||||
@@ -66,5 +70,4 @@ class TicketRequest extends Request {
|
||||
return $message;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user