Apply fixes from StyleCI

This commit is contained in:
Manish Verma
2016-12-13 13:14:54 +00:00
committed by StyleCI Bot
parent 857d3004eb
commit 88f3df2180
161 changed files with 4729 additions and 3879 deletions

View File

@@ -1,9 +1,9 @@
<?php
namespace App\Http\Requests\helpdesk;
use App\Model\helpdesk\Settings\CommonSettings;
use App\Http\Requests\Request;
use App\Model\helpdesk\Settings\CommonSettings;
/**
* AgentRequest.
@@ -29,10 +29,11 @@ class AgentRequest extends Request
*/
public function rules()
{
$check = $this->check(new CommonSettings);
$check = $this->check(new CommonSettings());
if ($check != 0) {
return $check;
}
return [
'user_name' => 'required|unique:users|max:30',
'first_name' => 'required|max:30',
@@ -45,15 +46,18 @@ class AgentRequest extends Request
'agent_time_zone' => 'required',
// 'phone_number' => 'phone:IN',
'mobile' => 'unique:users',
'team' => 'required',
'team' => 'required',
];
}
/**
*@category Funcion to set rule if send opt is enabled
*@param Object $settings (instance of Model common settings)
*
*@param object $settings (instance of Model common settings)
*
*@author manish.verma@ladybirdweb.com
*@return array|int
*
*@return array|int
*/
public function check($settings)
{
@@ -72,8 +76,8 @@ class AgentRequest extends Request
// 'phone_number' => 'phone:IN',
// 'mobile' => 'phone:IN',
'team' => 'required',
'mobile' => 'required|unique:users',
'country_code' => 'required',
'mobile' => 'required|unique:users',
'country_code' => 'required',
];
} else {
return 0;

View File

@@ -29,7 +29,7 @@ class ChangepasswordRequest extends Request
public function rules()
{
return [
'change_password' => 'required',
// 'message' => 'required',
];

View File

@@ -5,7 +5,6 @@ namespace App\Http\Requests\helpdesk;
use App\Http\Requests\Request;
use App\Model\helpdesk\Settings\CommonSettings;
/**
* CompanyRequest.
*
@@ -30,11 +29,12 @@ class ClientRequest extends Request
*/
public function rules()
{
$check = $this->check(new CommonSettings);
$check = $this->check(new CommonSettings());
if ($check != 0) {
return $check;
$custom_rule = $this->getCustomRule();
$rules = array_merge($check, $custom_rule);
return $rules;
}
$current_rule = [
@@ -45,70 +45,83 @@ class ClientRequest extends Request
];
$custom_rule = $this->getCustomRule();
$rules = array_merge($current_rule, $custom_rule);
return $rules;
}
public function getHelpTopic(){
public function getHelpTopic()
{
$help_topics = new \App\Model\helpdesk\Manage\Help_topic();
$topic = $this->input('helptopic');
$help_topic = $help_topics->where('id',$topic)->first();
$help_topic = $help_topics->where('id', $topic)->first();
return $help_topic;
}
public function getCustomRule(){
$custom_form = "";
public function getCustomRule()
{
$custom_form = '';
$help_topic = $this->getHelpTopic();
if($help_topic){
if ($help_topic) {
$custom_form = $help_topic->custom_form;
}
return $this->getForm($custom_form);
}
public function getForm($formid){
$id = "";
public function getForm($formid)
{
$id = '';
$forms = new \App\Model\helpdesk\Form\Forms();
$form = $forms->where('id',$formid)->first();
if($form){
$form = $forms->where('id', $formid)->first();
if ($form) {
$id = $form->id;
}
return $this->getFields($id);
}
public function getFields($formid){
public function getFields($formid)
{
$rules = [];
$field = new \App\Model\helpdesk\Form\Fields();
$fields = $field->where('forms_id',$formid)->get();
if($fields->count()>0){
foreach($fields as $fd){
if($fd->required==='1'){
$rules[str_replace(" ",'_',$fd->name)]="required";
$fields = $field->where('forms_id', $formid)->get();
if ($fields->count() > 0) {
foreach ($fields as $fd) {
if ($fd->required === '1') {
$rules[str_replace(' ', '_', $fd->name)] = 'required';
}
$rules = array_merge($rules,$this->getChild($fd->id));
$rules = array_merge($rules, $this->getChild($fd->id));
}
}
return $rules;
}
public function getChild($fieldid){
public function getChild($fieldid)
{
$children = new \App\Model\helpdesk\Form\FieldValue();
$childs = $children->where('field_id',$fieldid)->get();
$childs = $children->where('field_id', $fieldid)->get();
$rules = [];
if($childs->count()>0){
foreach($childs as $child){
if ($childs->count() > 0) {
foreach ($childs as $child) {
$child_formid = $child->child_id;
return $this->getForm($child_formid);
}
}
return [];
}
/**
*@category Funcion to set rule if send opt is enabled
*@param Object $settings (instance of Model common settings)
*
*@param object $settings (instance of Model common settings)
*
*@author manish.verma@ladybirdweb.com
*@return array|int
*
*@return array|int
*/
public function check($settings)
{

View File

@@ -1,7 +1,10 @@
<?php
namespace App\Http\Requests\helpdesk;
use App\Http\Requests\Request;
use App\Model\helpdesk\Settings\CommonSettings;
/**
* CreateTicketRequest.
*
@@ -18,14 +21,16 @@ class CreateTicketRequest extends Request
{
return true;
}
public function wantsJson()
{
if(in_array('api',$this->segments())){
if (in_array('api', $this->segments())) {
return true;
}
return false;
}
/**
* Get the validation rules that apply to the request.
*
@@ -33,14 +38,15 @@ class CreateTicketRequest extends Request
*/
public function rules()
{
$check = $this->check(new CommonSettings);
$check = $this->check(new CommonSettings());
if ($check != 0) {
return $check;
}
return [
'email' => 'required|email|max:60',
'email' => 'required|email|max:60',
'first_name' => 'required|min:3|max:40',
'helptopic' => 'required',
'helptopic' => 'required',
// 'dept' => 'required',
'sla' => 'required',
'subject' => 'required|min:5',
@@ -48,11 +54,15 @@ class CreateTicketRequest extends Request
'priority' => 'required',
];
}
/**
*@category Funcion to set rule if send opt is enabled
*@param Object $settings (instance of Model common settings)
*
*@param object $settings (instance of Model common settings)
*
*@author manish.verma@ladybirdweb.com
*@return array|int
*
*@return array|int
*/
public function check($settings)
{
@@ -61,9 +71,9 @@ class CreateTicketRequest extends Request
// dd($settings->status, $email_mandatory->status);
if (($settings->status == '1' || $settings->status == 1) && ($email_mandatory->status == '1' || $email_mandatory->status == 1)) {
return [
'email' => 'required|email|max:60',
'email' => 'required|email|max:60',
'first_name' => 'required|min:3|max:40',
'helptopic' => 'required',
'helptopic' => 'required',
// 'dept' => 'required',
'sla' => 'required',
'subject' => 'required|min:5',
@@ -76,9 +86,11 @@ class CreateTicketRequest extends Request
return 0;
} elseif (($settings->status == '0' || $settings->status == 0) && ($email_mandatory->status == '0' || $email_mandatory->status == 0)) {
$rule = $this->onlyMobleRequired();
return $rule;
} elseif (($settings->status == '1' || $settings->status == 1) && ($email_mandatory->status == '0' || $email_mandatory->status == 0)) {
$rule = $this->onlyMobleRequired();
return $rule;
} else {
return 0;
@@ -87,15 +99,17 @@ class CreateTicketRequest extends Request
/**
*@category function to make only moble required rule
*
*@param null
*
*@return array
*/
public function onlyMobleRequired()
{
return [
'email' => 'email|max:60',
'email' => 'email|max:60',
'first_name' => 'required|min:3|max:40',
'helptopic' => 'required',
'helptopic' => 'required',
// 'dept' => 'required',
'sla' => 'required',
'subject' => 'required|min:5',
@@ -105,4 +119,4 @@ class CreateTicketRequest extends Request
'mobile' => 'required',
];
}
}
}

View File

@@ -4,14 +4,15 @@ namespace App\Http\Requests\helpdesk\Job;
use App\Http\Requests\Request;
class TaskRequest extends Request {
class TaskRequest extends Request
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize() {
public function authorize()
{
return true;
}
@@ -20,27 +21,28 @@ class TaskRequest extends Request {
*
* @return array
*/
public function rules() {
public function rules()
{
return [
'fetching-commands' => 'required_if:email_fetching,1',
'fetching-commands' => 'required_if:email_fetching,1',
'notification-commands' => 'required_if:notification_cron,1',
'work-commands' => 'required_if:condition,1',
'workflow-dailyAt' => 'required_if:work-commands,dailyAt',
'notification-dailyAt' => 'required_if:notification-commands,dailyAt',
'fetching-dailyAt' => 'required_if:fetching-commands,dailyAt',
'work-commands' => 'required_if:condition,1',
'workflow-dailyAt' => 'required_if:work-commands,dailyAt',
'notification-dailyAt' => 'required_if:notification-commands,dailyAt',
'fetching-dailyAt' => 'required_if:fetching-commands,dailyAt',
];
}
public function messages() {
public function messages()
{
return [
'fetching-commands.required_if' => 'Please choose your Email Fetching timing',
'notification-commands.required_if'=>'Please choose your Email Notification timing',
'work-commands.required_if'=>'Please choose your Auto-close Workflow timing',
'workflow-dailyAt.required_if'=>'Please enter the time for Auto-close Workflow timing',
'notification-dailyAt.required_if'=>'Please enter the time for Email Notification timing',
'fetching-dailyAt.required_if'=>'Please enter the time for Email Fetching timing',
'fetching-commands.required_if' => 'Please choose your Email Fetching timing',
'notification-commands.required_if'=> 'Please choose your Email Notification timing',
'work-commands.required_if' => 'Please choose your Auto-close Workflow timing',
'workflow-dailyAt.required_if' => 'Please enter the time for Auto-close Workflow timing',
'notification-dailyAt.required_if' => 'Please enter the time for Email Notification timing',
'fetching-dailyAt.required_if' => 'Please enter the time for Email Fetching timing',
];
}
}

View File

@@ -30,11 +30,12 @@ class LableUpdate extends Request
public function rules()
{
$label_data = \Request::segments();
$label = Label::find($label_data[1]);
$label = Label::find($label_data[1]);
return [
'title' => 'required|max:10|unique:labels,title,'.$label->id,
'color' => 'required|regex:/#([a-fA-F0-9]{3}){1,2}\b/',
'order' => 'required|integer'
];
'order' => 'required|integer',
];
}
}

View File

@@ -23,52 +23,56 @@ class MailRequest extends Request
*/
public function rules()
{
$id = $this->segment(2);
$email_address_rule = 'required|email|unique:emails';
if($id){
if ($id) {
$email_address_rule = 'required|email|unique:emails,id,'.$id;
}
$rules = [
'email_address' => $email_address_rule,
'email_name' => 'required',
'password' => 'required',
'sending_protocol'=>'required_if:sending_status,on',
$rules = [
'email_address' => $email_address_rule,
'email_name' => 'required',
'password' => 'required',
'sending_protocol'=> 'required_if:sending_status,on',
];
$driver = $this->input('sending_protocol');
$driver_rules = $this->getDriver($driver);
$rules = array_merge($rules,$driver_rules);
$rules = array_merge($rules, $driver_rules);
return $rules;
}
public function getDriver($serviceid){
public function getDriver($serviceid)
{
$rules = [];
$mail_services = new \App\Model\MailJob\MailService();
$mail_service = $mail_services->find($serviceid);
if($mail_service){
if ($mail_service) {
$short = $mail_service->short_name;
$rules = $this->getRules($short);
}
return $rules;
}
public function getRules($short){
public function getRules($short)
{
$rules = [];
switch ($short){
case "mailgun":
$rules = [
'domain'=>'required',
'secret'=>'required',
switch ($short) {
case 'mailgun':
$rules = [
'domain'=> 'required',
'secret'=> 'required',
];
return $rules;
case "mandrill":
$rules = [
'secret'=>'required',
case 'mandrill':
$rules = [
'secret'=> 'required',
];
return $rules;
default :
default:
return $rules;
}
}

View File

@@ -29,18 +29,14 @@ class PriorityRequest extends Request
public function rules()
{
return [
'priority' => 'required|max:10',
'status' => 'required',
'priority_desc' => 'required|max:255',
'priority_color' => 'required',
'ispublic' => 'required',
'priority_successfully_updated'=>'priority successfully updated',
'priority_successfully_created!!!'=>'priority successfully created',
'priority' => 'required|max:10',
'status' => 'required',
'priority_desc' => 'required|max:255',
'priority_color' => 'required',
'ispublic' => 'required',
'priority_successfully_updated' => 'priority successfully updated',
'priority_successfully_created!!!'=> 'priority successfully created',
];
}

View File

@@ -36,8 +36,8 @@ class ProfileRequest extends Request
}
/**
*Check the mobile number is unique or not.
*
*Check the mobile number is unique or not
*@return string
*/
public function checkMobile()

View File

@@ -25,16 +25,19 @@ class QueueRequest extends Request
{
$request = $this->except('_token');
$rules = $this->setRule($request);
return $rules;
}
public function setRule($request){
public function setRule($request)
{
$rules = [];
if(count($request)>0){
foreach($request as $key=>$value){
$rules[$key]='required';
if (count($request) > 0) {
foreach ($request as $key=>$value) {
$rules[$key] = 'required';
}
}
return $rules;
}
}

View File

@@ -29,10 +29,11 @@ class RegisterRequest extends Request
*/
public function rules()
{
$check = $this->check(new CommonSettings);
$check = $this->check(new CommonSettings());
if ($check != 0) {
return $check;
}
return [
'email' => 'required|max:50|email|unique:users',
'full_name' => 'required',
@@ -43,9 +44,12 @@ class RegisterRequest extends Request
/**
*@category Funcion to set rule if send opt is enabled
*@param Object $settings (instance of Model common settings)
*
*@param object $settings (instance of Model common settings)
*
*@author manish.verma@ladybirdweb.com
*@return array|int
*
*@return array|int
*/
public function check($settings)
{

View File

@@ -1,9 +1,9 @@
<?php
namespace App\Http\Requests\helpdesk;
use App\Model\helpdesk\Settings\CommonSettings;
use App\Http\Requests\Request;
use App\Model\helpdesk\Settings\CommonSettings;
/**
* Sys_userRequest.
@@ -28,24 +28,28 @@ class Sys_userRequest extends Request
* @return array
*/
public function rules()
{
$check = $this->check(new CommonSettings);
{
$check = $this->check(new CommonSettings());
if ($check != 0) {
return $check;
}
return [
'first_name' => 'required',
'user_name' => 'required|min:3|unique:users,user_name',
'email' => 'required|unique:users,email',
'mobile' => 'unique:users',
'first_name' => 'required',
'user_name' => 'required|min:3|unique:users,user_name',
'email' => 'required|unique:users,email',
'mobile' => 'unique:users',
];
}
/**
*@category Funcion to set rule if send opt is enabled
*@param Object $settings (instance of Model common settings)
*
*@param object $settings (instance of Model common settings)
*
*@author manish.verma@ladybirdweb.com
*@return array|int
*
*@return array|int
*/
public function check($settings)
{
@@ -53,19 +57,21 @@ class Sys_userRequest extends Request
$email_mandatory = CommonSettings::select('status')->where('option_name', '=', 'email_mandatory')->first();
if (($settings->status == '1' || $settings->status == 1) && ($email_mandatory->status == '1' || $email_mandatory->status == 1)) {
return [
'first_name' => 'required',
'user_name' => 'required|min:3|unique:users,user_name',
'email' => 'required|unique:users,email',
'country_code' => 'required',
'mobile' => 'required|unique:users',
'first_name' => 'required',
'user_name' => 'required|min:3|unique:users,user_name',
'email' => 'required|unique:users,email',
'country_code' => 'required',
'mobile' => 'required|unique:users',
];
} elseif (($settings->status == '0' || $settings->status == 0) && ($email_mandatory->status == '1' || $email_mandatory->status == 1)) {
return 0;
} elseif (($settings->status == '0' || $settings->status == 0) && ($email_mandatory->status == '0' || $email_mandatory->status == 0)) {
$rule = $this->onlyMobleRequired();
return $rule;
} elseif (($settings->status == '1' || $settings->status == 1) && ($email_mandatory->status == '0' || $email_mandatory->status == 0)) {
$rule = $this->onlyMobleRequired();
return $rule;
} else {
return 0;
@@ -74,17 +80,19 @@ class Sys_userRequest extends Request
/**
*@category function to make only moble required rule
*
*@param null
*
*@return array
*/
public function onlyMobleRequired()
{
return [
'first_name' => 'required',
'user_name' => 'required|min:3|unique:users,user_name',
'email' => 'unique:users,email',
'country_code' => 'required',
'mobile' => 'required|unique:users',
'first_name' => 'required',
'user_name' => 'required|min:3|unique:users,user_name',
'email' => 'unique:users,email',
'country_code' => 'required',
'mobile' => 'required|unique:users',
];
}
}

View File

@@ -3,6 +3,7 @@
namespace App\Http\Requests\helpdesk;
use App\Http\Requests\Request;
//use Illuminate\Http\Request as Req;
/**
* Sys_userUpdate.
@@ -29,10 +30,10 @@ class Sys_userUpdate extends Request
public function rules()
{
return [
'first_name' => 'required',
'user_name' => 'required|min:3|unique:users,user_name,'.$this->segment(2),
'email' => 'required|email|unique:users,email,'.$this->segment(2),
'mobile' => 'unique:users,mobile,'.$this->segment(2),
'first_name' => 'required',
'user_name' => 'required|min:3|unique:users,user_name,'.$this->segment(2),
'email' => 'required|email|unique:users,email,'.$this->segment(2),
'mobile' => 'unique:users,mobile,'.$this->segment(2),
];
}
}

View File

@@ -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;
}
}
}