Skip to content

Commit

Permalink
Apply fixes from StyleCI
Browse files Browse the repository at this point in the history
  • Loading branch information
BadChoice authored and StyleCIBot committed Jul 24, 2018
1 parent 230f5c7 commit 7dfab33
Show file tree
Hide file tree
Showing 12 changed files with 31 additions and 26 deletions.
13 changes: 7 additions & 6 deletions app/Filters/TicketFilters.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,18 @@

use Schema;

class TicketFilters{
public function apply($query, $filters){

class TicketFilters
{
public function apply($query, $filters)
{
$availableFields = Schema::getColumnListing('tickets');

collect($filters)->filter(function($value, $filter) use($availableFields){
collect($filters)->filter(function ($value, $filter) use ($availableFields) {
return in_array($filter, $availableFields);
})->each(function($value, $filter) use(&$query){
})->each(function ($value, $filter) use (&$query) {
$query = $query->where($filter, $value);
});

return $query;
}
}

5 changes: 3 additions & 2 deletions app/Http/Controllers/Api/CommentsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ class CommentsController extends ApiController
public function store(Ticket $ticket)
{
$comment = $ticket->addComment(null, request('body'), request('new_status'));
if (! $comment){
$this->respond(['id' => null, 'message' => "Can not create a comment with empty body"], Response::HTTP_OK);
if (! $comment) {
$this->respond(['id' => null, 'message' => 'Can not create a comment with empty body'], Response::HTTP_OK);
}

return $this->respond(['id' => $comment->id], Response::HTTP_CREATED);
}
}
8 changes: 5 additions & 3 deletions app/Http/Controllers/TicketsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

namespace App\Http\Controllers;

use App\Filters\TicketFilters;
use App\Requester;
use App\Ticket;
use App\Requester;
use App\Filters\TicketFilters;
use App\Repositories\TicketsRepository;

class TicketsController extends Controller
Expand Down Expand Up @@ -75,13 +75,15 @@ public function reopen(Ticket $ticket)
return back();
}

public function update(Ticket $ticket) {
public function update(Ticket $ticket)
{
$this->validate(request(), [
'requester' => 'required|array',
'priority' => 'required|integer',
//'title' => 'required|min:3',
]);
$ticket->updateWith(request('requester'), request('priority'));

return back();
}
}
1 change: 0 additions & 1 deletion app/Repositories/TicketsRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 +70,4 @@ public function search($text)
$query->where('title', 'like', "%{$text}%")->orWhere('body', 'like', "%{$text}%");
});
}

}
16 changes: 9 additions & 7 deletions app/Ticket.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,14 @@ public static function createAndNotify($requester, $title, $body, $tags)
return $ticket;
}

public function updateWith($requester, $priority) {
public function updateWith($requester, $priority)
{
$requester = Requester::findOrCreate($requester['name'] ?? 'Unknown', $requester['email'] ?? null);
$this->update([
"priority" => $priority,
"requester_id" => $requester->id
'priority' => $priority,
'requester_id' => $requester->id,
]);

return $this;
}

Expand Down Expand Up @@ -256,10 +258,10 @@ public function statusName()
public function priorityName()
{
switch ($this->priority) {
case static::PRIORITY_LOW : return 'low';
case static::PRIORITY_NORMAL : return 'normal';
case static::PRIORITY_HIGH : return 'high';
case static::PRIORITY_BLOCKER : return 'blocker';
case static::PRIORITY_LOW: return 'low';
case static::PRIORITY_NORMAL: return 'normal';
case static::PRIORITY_HIGH: return 'high';
case static::PRIORITY_BLOCKER: return 'blocker';
}
}

Expand Down
2 changes: 1 addition & 1 deletion resources/lang/ca/ticket.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,5 @@
'low' => 'Baixa',
'normal' => 'Normal',
'high' => 'Alta',
'blocker' => 'Bloquejant'
'blocker' => 'Bloquejant',
];
2 changes: 1 addition & 1 deletion resources/lang/de/ticket.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,5 @@
'low' => 'Low*',
'normal' => 'Normal*',
'high' => 'High*',
'blocker' => 'Blocker*'
'blocker' => 'Blocker*',
];
2 changes: 1 addition & 1 deletion resources/lang/en/ticket.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,5 @@
'low' => 'Low',
'normal' => 'Normal',
'high' => 'High',
'blocker' => 'Blocker'
'blocker' => 'Blocker',
];
2 changes: 1 addition & 1 deletion resources/lang/es/ticket.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,5 @@
'low' => 'Baja',
'normal' => 'Normal',
'high' => 'Alta',
'blocker' => 'Bloqueador'
'blocker' => 'Bloqueador',
];
2 changes: 1 addition & 1 deletion resources/lang/fr/ticket.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,5 @@
'low' => 'Low*',
'normal' => 'Normal*',
'high' => 'High*',
'blocker' => 'Blocker*'
'blocker' => 'Blocker*',
];
2 changes: 1 addition & 1 deletion resources/lang/nl/ticket.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,5 @@
'low' => 'Low*',
'normal' => 'Normal*',
'high' => 'High*',
'blocker' => 'Blocker*'
'blocker' => 'Blocker*',
];
2 changes: 1 addition & 1 deletion resources/lang/ptbr/ticket.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,5 @@
'low' => 'Low*',
'normal' => 'Normal*',
'high' => 'High*',
'blocker' => 'Blocker*'
'blocker' => 'Blocker*',
];

0 comments on commit 7dfab33

Please sign in to comment.