Skip to content

Commit

Permalink
Apply fixes from StyleCI
Browse files Browse the repository at this point in the history
  • Loading branch information
xaviqv authored and StyleCIBot committed Sep 10, 2020
1 parent 9661150 commit 1ab5e12
Show file tree
Hide file tree
Showing 68 changed files with 3,218 additions and 3,194 deletions.
3 changes: 2 additions & 1 deletion src/Controllers/CommentsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@

class CommentsController extends Controller
{
use Attachments, Purifiable;
use Attachments;
use Purifiable;

protected $member;

Expand Down
3 changes: 2 additions & 1 deletion src/Controllers/ConfigurationsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function index()
$table_section = ['subject_content_column', 'list_text_max_length', 'check_last_update_seconds', 'length_menu', 'max_agent_buttons', 'calendar_month_filter', 'paginate_items'];
$features_section = ['departments_feature', 'departments_notices_feature', 'ticket_attachments_feature'];
$email_section = ['status_notification', 'comment_notification', 'queue_emails', 'assigned_notification',
'list_owner_notification', 'status_owner_notification', 'email.template', 'email.owner.newticket.template', 'email.account.name', 'email.account.mailbox', 'custom_recipients', ];
'list_owner_notification', 'status_owner_notification', 'email.template', 'email.owner.newticket.template', 'email.account.name', 'email.account.mailbox', 'custom_recipients', ];
$tickets_section = ['default_priority_id', 'default_status_id', 'default_close_status_id', 'default_reopen_status_id',
'attachments_ticket_max_size', 'attachments_ticket_max_files_num', 'attachments_mimes',
'attachments_path', 'thumbnails_path', 'oldest_year', 'html_replacements', 'use_default_status_id', 'delete_modal_type', ];
Expand Down Expand Up @@ -107,6 +107,7 @@ public function store(Request $request)

Session::flash('status', 'Setting saved successfully.');
\Cache::forget('panichd::settings'); // refresh cached settings

return redirect()->action('\PanicHD\PanicHD\Controllers\ConfigurationsController@index');
}

Expand Down
6 changes: 4 additions & 2 deletions src/Controllers/DashboardController.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ public function index($indicator_period = 2)
$active_tab = 'cat';
}

return view('panichd::admin.index',
return view(
'panichd::admin.index',
compact(
'tickets_count',
'a_tickets_count',
Expand All @@ -79,6 +80,7 @@ public function index($indicator_period = 2)
'categories_share',
'agents_share',
'active_tab'
));
)
);
}
}
3 changes: 2 additions & 1 deletion src/Controllers/FiltersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@

class FiltersController extends Controller
{
use CacheVars, TicketFilters;
use CacheVars;
use TicketFilters;

// $a_filters is in TicketFilters trait

Expand Down
32 changes: 16 additions & 16 deletions src/Controllers/NotificationsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,10 +204,10 @@ public function newComment(Comment $comment, $request)
if (!is_null($recipient)) {
// Register the notified email
$notification = CommentNotification::create([
'comment_id' => $comment->id,
'name' => $recipient->name,
'email' => $recipient->email,
'member_id' => $member_id,
'comment_id' => $comment->id,
'name' => $recipient->name,
'email' => $recipient->email,
'member_id' => $member_id,
]);

// Add email to actual mail recipients
Expand Down Expand Up @@ -296,29 +296,29 @@ public function notificationResend(Request $request)
if (is_null($notification)) {
// Register the notified email
$notification = CommentNotification::create([
'comment_id' => $comment->id,
'name' => $recipient->name,
'email' => $recipient->email,
'member_id' => $recipient->id,
'comment_id' => $comment->id,
'name' => $recipient->name,
'email' => $recipient->email,
'member_id' => $recipient->id,
]);

if ($comment->notifications->count() == 0) {
// No previous registered notifications
if ($ticket->agent->id == $comment->owner->id) {
// Message from agent to owner, so we register the non registered past owner notification
$notification = CommentNotification::create([
'comment_id' => $comment->id,
'name' => $ticket->owner->name,
'email' => $ticket->owner->email,
'member_id' => $ticket->owner->id,
'comment_id' => $comment->id,
'name' => $ticket->owner->name,
'email' => $ticket->owner->email,
'member_id' => $ticket->owner->id,
]);
} elseif ($ticket->owner->id == $comment->owner->id) {
// Message from owner to agent, so we register the non registered past agent notification
$notification = CommentNotification::create([
'comment_id' => $comment->id,
'name' => $ticket->agent->name,
'email' => $ticket->agent->email,
'member_id' => $ticket->agent->id,
'comment_id' => $comment->id,
'name' => $ticket->agent->name,
'email' => $ticket->agent->email,
'member_id' => $ticket->agent->id,
]);
}
}
Expand Down
38 changes: 27 additions & 11 deletions src/Controllers/TicketsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@

class TicketsController extends Controller
{
use Attachments, CacheVars, Purifiable, TicketFilters;
use Attachments;
use CacheVars;
use Purifiable;
use TicketFilters;

protected $tickets;
protected $member;
Expand Down Expand Up @@ -102,12 +105,12 @@ public function getTicketCollectionFrom($ticketList)
}
} elseif (in_array($field, $this->a_search_fields_text)) {
if ($field == 'content') {
$collection->where(function ($query) use ($search_fields, $value) {
$collection->where(function ($query) use ($value) {
$query->where('content', 'like', '%'.$value.'%')
->orWhere('html', 'like', '%'.$value.'%');
});
} elseif ($field == 'intervention') {
$collection->where(function ($query) use ($search_fields, $value) {
$collection->where(function ($query) use ($value) {
$query->where('intervention', 'like', '%'.$value.'%')
->orWhere('intervention_html', 'like', '%'.$value.'%');
});
Expand Down Expand Up @@ -405,10 +408,10 @@ public function renderTicketTable($collection, $ticketList)

$collection->editColumn('subject', function ($ticket) {
$field = (string) link_to_route(
Setting::grab('main_route').'.show',
$ticket->subject,
$ticket->id
);
Setting::grab('main_route').'.show',
$ticket->subject,
$ticket->id
);

if ($this->member->id == $ticket->agent_id and $ticket->read_by_agent != '1') {
$field = '<span class="unread_ticket_text">'.$field.'</span>';
Expand Down Expand Up @@ -1142,7 +1145,7 @@ public function register_search_fields(Request $request)
'fields' => $a_error_fields,
'search_fields' => $search_fields ?? [],
'search_URL' => $search_URL ?? '',
]);
]);
}

/**
Expand Down Expand Up @@ -1821,7 +1824,7 @@ public function show($id)
// Category tags
$tag_lists = Category::whereHas('tags')
->with([
'tags'=> function ($q1) use ($id) {
'tags'=> function ($q1) {
$q1->select('id', 'name');
},
])
Expand Down Expand Up @@ -1888,8 +1891,21 @@ public function show($id)
$ticket->timestamps = true;
}

$data = compact('ticket', 'a_reasons', 'a_tags_selected', 'status_lists', 'complete_status_list', 'agent_lists', 'tag_lists',
'comments', 'a_notifications', 'c_members', 'a_resend_notifications', 'close_perm', 'reopen_perm');
$data = compact(
'ticket',
'a_reasons',
'a_tags_selected',
'status_lists',
'complete_status_list',
'agent_lists',
'tag_lists',
'comments',
'a_notifications',
'c_members',
'a_resend_notifications',
'close_perm',
'reopen_perm'
);
$data['menu'] = 'show';

return view('panichd::tickets.show', $data);
Expand Down
3 changes: 2 additions & 1 deletion src/Events/CommentCreated.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@

class CommentCreated
{
use InteractsWithSockets, SerializesModels;
use InteractsWithSockets;
use SerializesModels;
public $comment;

/**
Expand Down
3 changes: 2 additions & 1 deletion src/Events/CommentUpdated.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@

class CommentUpdated
{
use InteractsWithSockets, SerializesModels;
use InteractsWithSockets;
use SerializesModels;
public $original;
public $modified;

Expand Down
3 changes: 2 additions & 1 deletion src/Events/TicketCreated.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@

class TicketCreated
{
use InteractsWithSockets, SerializesModels;
use InteractsWithSockets;
use SerializesModels;
public $ticket;

/**
Expand Down
3 changes: 2 additions & 1 deletion src/Events/TicketUpdated.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@

class TicketUpdated
{
use InteractsWithSockets, SerializesModels;
use InteractsWithSockets;
use SerializesModels;
public $original;
public $modified;

Expand Down
3 changes: 2 additions & 1 deletion src/Mail/PanicHDNotification.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@

class PanicHDNotification extends Mailable
{
use Queueable, SerializesModels;
use Queueable;
use SerializesModels;

private $template;
private $data;
Expand Down
24 changes: 12 additions & 12 deletions src/Models/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ class Configuration extends Model
public $table = 'panichd_settings';

public $fillable = [
'lang',
'slug',
'value',
'default',
];
'lang',
'slug',
'value',
'default',
];

// Null lang column if no value is being stored.

Expand All @@ -31,14 +31,14 @@ public function setLangAttribute($lang)
* @var array
*/
protected $casts = [
'id' => 'integer',
'lang' => 'string',
'slug' => 'string',
'value' => 'string',
'default' => 'string',
];
'id' => 'integer',
'lang' => 'string',
'slug' => 'string',
'value' => 'string',
'default' => 'string',
];

public static $rules = [

];
];
}
12 changes: 2 additions & 10 deletions src/Models/Member.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,8 @@ public function maxLevel()
{
if ($this->isAdmin()) {
return 3;

} elseif ($this->isAgent()) {
return 2;

} else {
return 1;
}
Expand All @@ -169,14 +167,12 @@ public function currentLevel()
{
if ($this->isAdmin()) {
return 3;

} elseif ($this->isAgent()) {
if (session()->exists('panichd_filter_currentLevel') and session('panichd_filter_currentLevel') == 1) {
return 1;
} else {
return 2;
}

} else {
return 1;
}
Expand Down Expand Up @@ -264,7 +260,6 @@ public function canManageTicket($id)
{
if ($this->isAdmin()) {
return true;

} elseif ($ticket = Ticket::find($id)) {
if ($this->id == $ticket->agent_id or (Setting::grab('agent_restrict') == 0 and $this->categories()->where('id', $ticket->category_id)->count() == 1)) {
return true;
Expand All @@ -285,7 +280,6 @@ public function canViewNewTickets()
{
if ($this->isAdmin()) {
return true;

} elseif ($this->isAgent() and $this->currentLevel() == 2) {
if (Setting::grab('agent_restrict') == 1) {
return $this->categories()->wherePivot('autoassign', '1')->count() == 0 ? false : true;
Expand Down Expand Up @@ -376,7 +370,7 @@ public function getEditTicketCategories()
}

/**
* Get related tickets as agent
* Get related tickets as agent.
*/
public function ticketsAsAgent()
{
Expand Down Expand Up @@ -407,10 +401,8 @@ public function scopeVisible($query)

if ($member->panichd_admin) {
return $query->orderBy('name', 'ASC');

} elseif ($member->panichd_agent) {
return $query->VisibleForAgent($member->id);

} else {
return $query->where('id', '0');
}
Expand All @@ -427,7 +419,7 @@ public function scopeVisible($query)
public function scopeVisibleForAgent($query, $id)
{
$member = \PanicHDMember::findOrFail(auth()->user()->id);

if ($member->currentLevel() == 2) {
// Depends on agent_restrict
if (Setting::grab('agent_restrict') == 0) {
Expand Down
2 changes: 1 addition & 1 deletion src/Models/Setting.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public static function grab($slug)
*/
// Cache::flush();

$setting = Cache::remember('panichd::settings.' . $slug, \Carbon\Carbon::now()->addMinutes(60), function () use ($slug) {
$setting = Cache::remember('panichd::settings.'.$slug, \Carbon\Carbon::now()->addMinutes(60), function () use ($slug) {
$settings = Cache::remember('panichd::settings', \Carbon\Carbon::now()->addMinutes(60), function () {
return Table::all();
});
Expand Down
4 changes: 2 additions & 2 deletions src/Models/Ticket.php
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ public function getDateForHumans($date_field, $distant_dates_text = false)
$date_text = trans('panichd::lang.datetime-text', [
'date' => $text_to_format,
'time' => $this->getTime($date_field),
]);
]);
}

return $date_text;
Expand Down Expand Up @@ -571,7 +571,7 @@ public function scopeFromOwner($query, $id)
}

/**
* Get tickets from specified Agent
* Get tickets from specified Agent.
*
* @param $query
* @param $id
Expand Down
Loading

0 comments on commit 1ab5e12

Please sign in to comment.