Skip to content
This repository has been archived by the owner on Jul 26, 2024. It is now read-only.

Commit

Permalink
Merge pull request #11 from ssddanbrown/analysis-RP19wp
Browse files Browse the repository at this point in the history
Apply fixes from StyleCI
  • Loading branch information
ssddanbrown authored May 5, 2023
2 parents 827f73e + baf0862 commit 05a98f7
Show file tree
Hide file tree
Showing 73 changed files with 383 additions and 396 deletions.
8 changes: 4 additions & 4 deletions app/Console/Commands/AddUserCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ public function handle(): int
}

$user = User::query()->where('email', '=', $email)->first();
if (! is_null($user)) {
if (!is_null($user)) {
$update = $this->confirm('User with that email already exists, Do you want to update them?');
if (! $update) {
if (!$update) {
$this->error('Taking no action');

return 1;
Expand All @@ -62,8 +62,8 @@ public function handle(): int
}

$user->fill([
'name' => $name,
'email' => $email,
'name' => $name,
'email' => $email,
'password' => Hash::make($password),
]);
$user->save();
Expand Down
2 changes: 1 addition & 1 deletion app/Console/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ protected function schedule(Schedule $schedule): void
*/
protected function commands(): void
{
$this->load(__DIR__.'/Commands');
$this->load(__DIR__ . '/Commands');

require base_path('routes/console.php');
}
Expand Down
4 changes: 2 additions & 2 deletions app/Http/Controllers/Auth/ConfirmablePasswordController.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ public function show(Request $request): View
*/
public function store(Request $request): RedirectResponse
{
if (! Auth::validate([
'email' => $request->user()->email,
if (!Auth::validate([
'email' => $request->user()->email,
'password' => $request->password,
])) {
return back()->withErrors([
Expand Down
6 changes: 3 additions & 3 deletions app/Http/Controllers/Auth/NewPasswordController.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ public function create(Request $request): View
public function store(Request $request): RedirectResponse
{
$request->validate([
'token' => 'required',
'email' => 'required|email',
'token' => 'required',
'email' => 'required|email',
'password' => 'required|string|confirmed|min:8',
]);

Expand All @@ -43,7 +43,7 @@ public function store(Request $request): RedirectResponse
$request->only('email', 'password', 'password_confirmation', 'token'),
function ($user) use ($request) {
$user->forceFill([
'password' => Hash::make($request->password),
'password' => Hash::make($request->password),
'remember_token' => Str::random(60),
])->save();

Expand Down
4 changes: 2 additions & 2 deletions app/Http/Controllers/CampaignController.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public function index(Request $request): View
$query = Campaign::query()->withCount(['sends', 'rssFeeds'])->orderBy('name');
$search = $request->get('search');
if ($search) {
$query->where('name', 'like', '%'.$search.'%');
$query->where('name', 'like', '%' . $search . '%');
}

$campaigns = $query->paginate(100)->withQueryString();
Expand All @@ -37,7 +37,7 @@ public function show(Request $request, Campaign $campaign): View
->withCount(['feeds']);
$search = $request->get('search');
if ($search) {
$sendQuery->where('name', 'like', '%'.$search.'%');
$sendQuery->where('name', 'like', '%' . $search . '%');
}

$sends = $sendQuery->paginate(100)->withQueryString();
Expand Down
12 changes: 6 additions & 6 deletions app/Http/Controllers/ContactController.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public function index(Request $request): View
$query = Contact::query()->orderBy('email')->withCount(['lists']);
$search = $request->get('search');
if ($search) {
$query->where('email', 'like', '%'.$search.'%');
$query->where('email', 'like', '%' . $search . '%');
}

$contacts = $query->paginate(100)->withQueryString();
Expand All @@ -44,12 +44,12 @@ public function create(): View
public function store(Request $request): RedirectResponse
{
$this->validate($request, [
'email' => 'required|email|unique:contacts,email',
'email' => 'required|email|unique:contacts,email',
'unsubscribed' => 'boolean',
]);

$contact = new Contact([
'email' => $request->get('email'),
'email' => $request->get('email'),
'unsubscribed' => $request->get('unsubscribed') === '1',
]);
$contact->save();
Expand All @@ -72,7 +72,7 @@ public function edit(Contact $contact): View
})->toArray();

return view('contacts.edit', [
'contact' => $contact,
'contact' => $contact,
'listOptions' => $allListOptions,
]);
}
Expand All @@ -83,12 +83,12 @@ public function edit(Contact $contact): View
public function update(Request $request, Contact $contact): RedirectResponse
{
$this->validate($request, [
'email' => "required|email|unique:contacts,email,{$contact->id}",
'email' => "required|email|unique:contacts,email,{$contact->id}",
'unsubscribed' => 'boolean',
]);

$contact->update([
'email' => $request->get('email'),
'email' => $request->get('email'),
'unsubscribed' => $request->get('unsubscribed') === '1',
]);

Expand Down
4 changes: 2 additions & 2 deletions app/Http/Controllers/ContactListController.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class ContactListController extends Controller
public function add(Request $request, Contact $contact): RedirectResponse
{
$this->validate($request, [
'lists' => 'array',
'lists' => 'array',
'lists.*' => 'integer',
]);

Expand All @@ -33,7 +33,7 @@ public function add(Request $request, Contact $contact): RedirectResponse
public function remove(Request $request, Contact $contact): RedirectResponse
{
$this->validate($request, [
'lists' => 'array',
'lists' => 'array',
'lists.*' => 'integer',
]);

Expand Down
12 changes: 6 additions & 6 deletions app/Http/Controllers/DashboardController.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ class DashboardController extends Controller
public function index(): View
{
return view('dashboard.index', [
'recentSends' => $this->recentSends(),
'latestContacts' => $this->latestContacts(),
'popularLists' => $this->popularLists(),
'recentSends' => $this->recentSends(),
'latestContacts' => $this->latestContacts(),
'popularLists' => $this->popularLists(),
'upcomingRssFeeds' => $this->upcomingRssFeeds(),
'counts' => $this->getCounts(),
'counts' => $this->getCounts(),
]);
}

Expand All @@ -30,8 +30,8 @@ protected function getCounts(): array
{
return [
'contacts' => Contact::query()->count(),
'sends' => Send::query()->count(),
'sent' => SendRecord::query()->count(),
'sends' => Send::query()->count(),
'sent' => SendRecord::query()->count(),
];
}

Expand Down
16 changes: 8 additions & 8 deletions app/Http/Controllers/ListController.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ public function index(Request $request): View
$query = MailList::query()->orderBy('name')->withCount('contacts');
$search = $request->get('search');
if ($search) {
$query->where('name', 'like', '%'.$search.'%')
->orWhere('display_name', 'like', '%'.$search.'%');
$query->where('name', 'like', '%' . $search . '%')
->orWhere('display_name', 'like', '%' . $search . '%');
}

$lists = $query->paginate(100)->withQueryString();
Expand All @@ -37,13 +37,13 @@ public function show(MailList $list, Request $request): View
$query = $list->contacts()->orderBy('email');
$search = $request->get('search');
if ($search) {
$query->where('email', 'like', '%'.$search.'%');
$query->where('email', 'like', '%' . $search . '%');
}

$contacts = $query->paginate(100)->withQueryString();

return view('lists.show', [
'list' => $list,
'list' => $list,
'contacts' => $contacts,
]);
}
Expand All @@ -64,9 +64,9 @@ public function create(): View
public function store(Request $request): RedirectResponse
{
$this->validate($request, [
'name' => 'required|max:250',
'name' => 'required|max:250',
'display_name' => 'required|max:250',
'slug' => 'max:250|alpha_dash|unique:mail_lists,slug',
'slug' => 'max:250|alpha_dash|unique:mail_lists,slug',
]);

$list = new MailList($request->all());
Expand Down Expand Up @@ -94,9 +94,9 @@ public function edit(MailList $list): View
public function update(Request $request, MailList $list): RedirectResponse
{
$this->validate($request, [
'name' => 'required|max:250',
'name' => 'required|max:250',
'display_name' => 'required|max:250',
'slug' => "max:250|alpha_dash|unique:mail_lists,slug,{$list->id}",
'slug' => "max:250|alpha_dash|unique:mail_lists,slug,{$list->id}",
]);

$list->fill($request->all());
Expand Down
16 changes: 8 additions & 8 deletions app/Http/Controllers/RssFeedController.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ public function create(Campaign $campaign): View
public function store(Request $request, Campaign $campaign): RedirectResponse
{
$validated = $this->validate($request, [
'active' => 'required|bool',
'url' => ['required', 'url', 'max:250', new ValidRssFeedRule()],
'active' => 'required|bool',
'url' => ['required', 'url', 'max:250', new ValidRssFeedRule()],
'template_send_id' => 'required|exists:sends,id',
'send_frequency' => 'required|integer|min:1|max:366',
'target_hour' => 'required|integer|min:0|max:23',
'send_frequency' => 'required|integer|min:1|max:366',
'target_hour' => 'required|integer|min:0|max:23',
]);

$feed = new RssFeed($validated);
Expand All @@ -60,11 +60,11 @@ public function edit(Campaign $campaign, RssFeed $feed): View
public function update(Request $request, Campaign $campaign, RssFeed $feed): RedirectResponse
{
$validated = $this->validate($request, [
'active' => 'required|bool',
'url' => ['required', 'url', 'max:250', new ValidRssFeedRule()],
'active' => 'required|bool',
'url' => ['required', 'url', 'max:250', new ValidRssFeedRule()],
'template_send_id' => 'required|exists:sends,id',
'send_frequency' => 'required|integer|min:1|max:366',
'target_hour' => 'required|integer|min:0|max:23',
'send_frequency' => 'required|integer|min:1|max:366',
'target_hour' => 'required|integer|min:0|max:23',
]);

$feed->fill($validated);
Expand Down
18 changes: 9 additions & 9 deletions app/Http/Controllers/SendController.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function create(Request $request): View
}

return view('sends.create', [
'send' => $default,
'send' => $default,
'campaign' => $campaign,
]);
}
Expand All @@ -46,11 +46,11 @@ public function create(Request $request): View
public function store(Request $request): RedirectResponse
{
$validated = $this->validate($request, [
'name' => 'required|max:250',
'content' => 'required|max:25000',
'subject' => 'required|max:250',
'name' => 'required|max:250',
'content' => 'required|max:25000',
'subject' => 'required|max:250',
'mail_list_id' => 'required|exists:mail_lists,id',
'campaign_id' => 'required|exists:campaigns,id',
'campaign_id' => 'required|exists:campaigns,id',
]);

$send = new Send($validated);
Expand All @@ -75,11 +75,11 @@ public function edit(Send $send): View
public function update(Request $request, Send $send): RedirectResponse
{
$validated = $this->validate($request, [
'name' => 'required|max:250',
'content' => 'required|max:25000',
'subject' => 'required|max:250',
'name' => 'required|max:250',
'content' => 'required|max:25000',
'subject' => 'required|max:250',
'mail_list_id' => 'exists:mail_lists,id',
'campaign_id' => 'exists:campaigns,id',
'campaign_id' => 'exists:campaigns,id',
]);

$send->update($validated);
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/UnsubscribeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function show(string $sendRecordKey)
{
/** @var ?SendRecord $sendRecord */
$sendRecord = SendRecord::query()->where('key', '=', $sendRecordKey)->first();
if (! $sendRecord || $sendRecord->hasExpired()) {
if (!$sendRecord || $sendRecord->hasExpired()) {
return response()->view('unsubscribe.not-found', [], 404);
}

Expand Down
18 changes: 9 additions & 9 deletions app/Http/Controllers/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ public function index(Request $request): View
$query = User::query()->orderBy('name');
$search = $request->get('search');
if ($search) {
$query->where('name', 'like', '%'.$search.'%')
->orWhere('email', 'like', '%'.$search.'%');
$query->where('name', 'like', '%' . $search . '%')
->orWhere('email', 'like', '%' . $search . '%');
}

$users = $query->paginate(100)->withQueryString();
Expand All @@ -43,14 +43,14 @@ public function create(): View
public function store(Request $request): RedirectResponse
{
$this->validate($request, [
'email' => 'required|email|unique:users,email',
'name' => 'required|string|max:250',
'email' => 'required|email|unique:users,email',
'name' => 'required|string|max:250',
'password' => 'required|string|min:8|max:250',
]);

$user = new User([
'email' => $request->get('email'),
'name' => $request->get('name'),
'email' => $request->get('email'),
'name' => $request->get('name'),
'password' => Hash::make($request->get('password')),
]);
$user->save();
Expand All @@ -74,14 +74,14 @@ public function edit(User $user): View
public function update(Request $request, User $user): RedirectResponse
{
$this->validate($request, [
'email' => 'required|email|unique:users,email,'.$user->id,
'name' => 'required|string|max:250',
'email' => 'required|email|unique:users,email,' . $user->id,
'name' => 'required|string|max:250',
'password' => 'nullable|string|min:8|max:250',
]);

$user->fill($request->only(['email', 'name']));

if ($request->has('password') && ! empty($request->get('password'))) {
if ($request->has('password') && !empty($request->get('password'))) {
$user->password = Hash::make($request->get('password'));
}

Expand Down
20 changes: 10 additions & 10 deletions app/Http/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class Kernel extends HttpKernel
],

'api' => [
\Illuminate\Routing\Middleware\ThrottleRequests::class.':api',
\Illuminate\Routing\Middleware\ThrottleRequests::class . ':api',
\Illuminate\Routing\Middleware\SubstituteBindings::class,
],
];
Expand All @@ -52,15 +52,15 @@ class Kernel extends HttpKernel
* @var array<string, string>
*/
protected $middlewareAliases = [
'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' => \Illuminate\Routing\Middleware\ValidateSignature::class,
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class,
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
];
}
Loading

0 comments on commit 05a98f7

Please sign in to comment.