This commit is contained in:
Manish Verma
2016-12-13 18:18:25 +05:30
parent fc98add11c
commit 2d8e640e9b
2314 changed files with 97798 additions and 75664 deletions

View File

@@ -9,15 +9,14 @@ 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;
}
@@ -26,42 +25,39 @@ 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();
@@ -70,4 +66,5 @@ class TicketRequest extends Request
return $message;
}
}
}