Skip to content

Commit

Permalink
Merge pull request #9 from codefornebraska/task/8-formatting-updates
Browse files Browse the repository at this point in the history
Task/8 formatting updates
  • Loading branch information
barobba authored Oct 4, 2022
2 parents 4c5a4e2 + 9e58ece commit 7a9cede
Show file tree
Hide file tree
Showing 122 changed files with 663 additions and 628 deletions.
3 changes: 1 addition & 2 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@
'no_short_bool_cast' => true,
'no_singleline_whitespace_before_semicolons' => true,
'no_spaces_around_offset' => ['positions' => ['inside']],
'no_trailing_comma_in_list_call' => true,
'no_trailing_comma_in_singleline_array' => true,
'no_trailing_comma_in_singleline' => true,
'no_unneeded_control_parentheses' => ['statements' => ['break', 'clone', 'continue', 'echo_print', 'return', 'switch_case', 'yield']],
// https://github.com/FriendsOfPHP/PHP-CS-Fixer/issues/4159
// 'no_unused_imports' => true,
Expand Down
8 changes: 4 additions & 4 deletions app/Actions/Fortify/CreateNewUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
namespace App\Actions\Fortify;

use App\Models\User;
use Illuminate\Validation\Rule;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Validator;
use Illuminate\Validation\Rule;
use Laravel\Fortify\Contracts\CreatesNewUsers;

class CreateNewUser implements CreatesNewUsers
Expand All @@ -21,7 +21,7 @@ class CreateNewUser implements CreatesNewUsers
public function create(array $input)
{
Validator::make($input, [
'name' => ['required', 'string', 'max:255'],
'name' => ['required', 'string', 'max:255'],
'email' => [
'required',
'string',
Expand All @@ -33,8 +33,8 @@ public function create(array $input)
])->validate();

return User::create([
'name' => $input['name'],
'email' => $input['email'],
'name' => $input['name'],
'email' => $input['email'],
'password' => Hash::make($input['password']),
]);
}
Expand Down
4 changes: 2 additions & 2 deletions app/Actions/Fortify/UpdateUserPassword.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ public function update($user, array $input)
{
Validator::make($input, [
'current_password' => ['required', 'string'],
'password' => $this->passwordRules(),
'password' => $this->passwordRules(),
])->after(function ($validator) use ($user, $input) {
if (! isset($input['current_password']) || ! Hash::check($input['current_password'], $user->password)) {
if (!isset($input['current_password']) || !Hash::check($input['current_password'], $user->password)) {
$validator->errors()->add('current_password', __('The provided password does not match your current password.'));
}
})->validateWithBag('updatePassword');
Expand Down
20 changes: 11 additions & 9 deletions app/Actions/Fortify/UpdateUserProfileInformation.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

namespace App\Actions\Fortify;

use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Support\Facades\Validator;
use Illuminate\Validation\Rule;
use Illuminate\Support\Facades\Validator;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Laravel\Fortify\Contracts\UpdatesUserProfileInformation;

class UpdateUserProfileInformation implements UpdatesUserProfileInformation
Expand Down Expand Up @@ -33,12 +33,14 @@ public function update($user, array $input)
if ($input['email'] !== $user->email &&
$user instanceof MustVerifyEmail) {
$this->updateVerifiedUser($user, $input);
} else {
$user->forceFill([
'name' => $input['name'],
'email' => $input['email'],
])->save();

return;
}

$user->forceFill([
'name' => $input['name'],
'email' => $input['email'],
])->save();
}

/**
Expand All @@ -51,8 +53,8 @@ public function update($user, array $input)
protected function updateVerifiedUser($user, array $input)
{
$user->forceFill([
'name' => $input['name'],
'email' => $input['email'],
'name' => $input['name'],
'email' => $input['email'],
'email_verified_at' => null,
])->save();

Expand Down
6 changes: 3 additions & 3 deletions app/Console/Commands/LegiScanImport.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ protected function translateStates(): static
'name' => $state->state_name,
'abbreviation' => $state->state_abbr,
'biennium' => $state->biennium,
'carry_over' => $state->carry_over,
'carry_over' => $state->carry_over,
'capitol' => $state->capitol,
'latitude' => $state->latitude,
'longitude' => $state->longitude,
Expand All @@ -62,7 +62,7 @@ protected function translateStates(): static

$progress->finish();

$this->info("\n".$this->separator);
$this->info("\n" . $this->separator);

return $this;
}
Expand All @@ -89,7 +89,7 @@ protected function importLegiscanData(): static
);

$this->info('Importing LegiScan data. This may take a minute.');

exec($command);

Log::info('LegiScan import completed');
Expand Down
3 changes: 2 additions & 1 deletion app/Console/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class Kernel extends ConsoleKernel
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
protected function schedule(Schedule $schedule)
{
Expand All @@ -25,7 +26,7 @@ protected function schedule(Schedule $schedule)
*/
protected function commands()
{
$this->load(__DIR__.'/Commands');
$this->load(__DIR__ . '/Commands');

require base_path('routes/console.php');
}
Expand Down
8 changes: 4 additions & 4 deletions app/Exceptions/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace App\Exceptions;

use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Throwable;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;

class Handler extends ExceptionHandler
{
Expand All @@ -13,7 +13,7 @@ class Handler extends ExceptionHandler
* @var array<class-string<\Throwable>, \Psr\Log\LogLevel::*>
*/
protected $levels = [
//

];

/**
Expand All @@ -22,7 +22,7 @@ class Handler extends ExceptionHandler
* @var array<int, class-string<\Throwable>>
*/
protected $dontReport = [
//

];

/**
Expand All @@ -40,11 +40,11 @@ class Handler extends ExceptionHandler
* Register the exception handling callbacks for the application.
*
* @return void
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function register()
{
$this->reportable(function (Throwable $e) {
//
});
}
}
4 changes: 2 additions & 2 deletions app/Http/Controllers/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

namespace App\Http\Controllers;

use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;

class Controller extends BaseController
{
Expand Down
14 changes: 8 additions & 6 deletions app/Http/Controllers/Pages/HomeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,20 @@

namespace App\Http\Controllers\Pages;

use App\Http\Controllers\Controller;
use App\Models\LegiScan\State;
use App\Http\Controllers\Controller;

class HomeController extends Controller
{
public function index()
{
$states = State::whereNotIn('state_abbr', ['DC', 'US'])->get();

$dc = State::where('state_abbr', 'DC')->first();
$us = State::where('state_abbr', 'US')->first();
$states = State::nonNational()->get();
$districtOfColumbia = State::where('abbreviation', 'DC')->first();
$unitedStates = State::where('abbreviation', 'US')->first();

return view('pages.home.index', compact('states', 'dc', 'us'));
return view('pages.home.index')
->withStates($states)
->withDistrictOfColumbia($districtOfColumbia)
->withUnitedStates($unitedStates);
}
}
4 changes: 2 additions & 2 deletions app/Http/Controllers/Pages/StateHomeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

namespace App\Http\Controllers\Pages;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Models\LegiScan\Bill;
use App\Models\LegiScan\State;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;

class StateHomeController extends Controller
{
Expand Down
18 changes: 9 additions & 9 deletions app/Http/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,15 @@ class Kernel extends HttpKernel
* @var array<string, class-string|string>
*/
protected $routeMiddleware = [
'auth' => \App\Http\Middleware\Authenticate::class,
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
'auth.session' => \Illuminate\Session\Middleware\AuthenticateSession::class,
'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
'can' => \Illuminate\Auth\Middleware\Authorize::class,
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
'auth' => \App\Http\Middleware\Authenticate::class,
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
'auth.session' => \Illuminate\Session\Middleware\AuthenticateSession::class,
'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
'can' => \Illuminate\Auth\Middleware\Authorize::class,
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class,
'signed' => \App\Http\Middleware\ValidateSignature::class,
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
'signed' => \App\Http\Middleware\ValidateSignature::class,
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
];
}
38 changes: 20 additions & 18 deletions app/Http/Livewire/BillTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

namespace App\Http\Livewire;

use Livewire\Component;
use App\Models\LegiScan\Bill;
use App\Traits\Livewire\WithPerPagePagination;
use Livewire\Component;

class BillTable extends Component
{
Expand All @@ -14,7 +14,8 @@ class BillTable extends Component
'search' => ['initial' => null, 'as' => 'q'],
];

public $state_id;
public $stateId;

public $search = null;

public function updatedSearch()
Expand All @@ -25,36 +26,37 @@ public function updatedSearch()
public function query()
{
return Bill::query()
->when($this->state_id,
fn($query) => $query->where('state_id', $this->state_id)
)
;
->when(
$this->stateId,
fn ($query) => $query->where('state_id', $this->stateId)
);
}

public function applyFilters($query)
{
return $query
->when($this->search,
fn($query) => $query
->when(
$this->search,
fn ($query) => $query
->where(
fn($subquery) => $subquery
->where('bill_number', 'like', '%'.$this->search.'%')
->orWhere('title', 'like', '%'.$this->search.'%')
->orWhere('description', 'like', '%'.$this->search.'%')
)
)
;
fn ($subquery) => $subquery
->where('bill_number', 'like', '%' . $this->search . '%')
->orWhere('title', 'like', '%' . $this->search . '%')
->orWhere('description', 'like', '%' . $this->search . '%')
)
);
}

public function render()
{
$bill_count = $this->query()->count();
$bills = $this->applyPagination(
$billCount = $this->query()->count();
$bills = $this->applyPagination(
$this->applyFilters($this->query()->orderByDesc('status_date'))
);

$has_filters = $this->hasFilters();

return view('livewire.bill-table', compact('bills', 'bill_count', 'has_filters'));
return view('livewire.bill-table', compact('bills', 'billCount', 'has_filters'));
}

public function hasFilters()
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Middleware/Authenticate.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class Authenticate extends Middleware
*/
protected function redirectTo($request)
{
if (! $request->expectsJson()) {
if (!$request->expectsJson()) {
return route('login');
}
}
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Middleware/EncryptCookies.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ class EncryptCookies extends Middleware
* @var array<int, string>
*/
protected $except = [
//

];
}
2 changes: 1 addition & 1 deletion app/Http/Middleware/PreventRequestsDuringMaintenance.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ class PreventRequestsDuringMaintenance extends Middleware
* @var array<int, string>
*/
protected $except = [
//

];
}
2 changes: 1 addition & 1 deletion app/Http/Middleware/RedirectIfAuthenticated.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

namespace App\Http\Middleware;

use App\Providers\RouteServiceProvider;
use Closure;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use App\Providers\RouteServiceProvider;

class RedirectIfAuthenticated
{
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Middleware/TrustProxies.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace App\Http\Middleware;

use Illuminate\Http\Middleware\TrustProxies as Middleware;
use Illuminate\Http\Request;
use Illuminate\Http\Middleware\TrustProxies as Middleware;

class TrustProxies extends Middleware
{
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Middleware/VerifyCsrfToken.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ class VerifyCsrfToken extends Middleware
* @var array<int, string>
*/
protected $except = [
//

];
}
Loading

0 comments on commit 7a9cede

Please sign in to comment.