From e2cd47be9260f2ff7df11d9ecf7d160c3dde59b3 Mon Sep 17 00:00:00 2001 From: Shift Date: Wed, 15 May 2024 19:25:27 +0000 Subject: [PATCH 01/17] Apply Laravel coding style Shift automatically applies the Laravel coding style - which uses the PSR-12 coding style as a base with some minor additions. You may customize the code style applied by configuring [Pint](https://laravel.com/docs/pint), [PHP CS Fixer](https://github.com/FriendsOfPHP/PHP-CS-Fixer), or [PHP CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer) for your project root. For more information on customizing the code style applied by Shift, [watch this short video](https://laravelshift.com/videos/shift-code-style). --- app/Console/Commands/AddUserCommand.php | 8 +- app/Console/Kernel.php | 2 +- .../Auth/ConfirmablePasswordController.php | 4 +- .../Auth/NewPasswordController.php | 8 +- .../Auth/PasswordResetLinkController.php | 2 +- app/Http/Controllers/CampaignController.php | 4 +- app/Http/Controllers/ContactController.php | 12 +-- .../Controllers/ContactListController.php | 4 +- app/Http/Controllers/DashboardController.php | 12 +-- app/Http/Controllers/ListController.php | 16 ++-- app/Http/Controllers/RssFeedController.php | 16 ++-- app/Http/Controllers/SendController.php | 18 ++-- .../Controllers/UnsubscribeController.php | 2 +- app/Http/Controllers/UserController.php | 18 ++-- app/Http/Kernel.php | 20 ++--- app/Http/Requests/Auth/LoginRequest.php | 8 +- app/Jobs/FindRssFeedsToReviewJob.php | 2 +- app/Jobs/ReviewRssFeedJob.php | 4 +- app/Jobs/SendActivationJob.php | 2 +- app/Mail/SignupConfirmationMail.php | 6 +- app/Models/Campaign.php | 6 +- app/Models/MailList.php | 2 +- app/Models/RssFeed.php | 24 ++--- app/Models/Send.php | 14 +-- app/Models/SendRecord.php | 2 +- app/Models/Signup.php | 2 +- app/Rules/ValidHCaptchaResult.php | 8 +- app/Rules/ValidRssFeedRule.php | 4 +- app/Services/EmailListImporter.php | 9 +- app/Services/MailContentParser.php | 16 ++-- app/Services/Rss/RssParser.php | 2 +- config/auth.php | 14 +-- config/broadcasting.php | 20 ++--- config/cache.php | 34 +++---- config/database.php | 90 +++++++++---------- config/filesystems.php | 28 +++--- config/hashing.php | 4 +- config/logging.php | 62 ++++++------- config/mail.php | 22 ++--- config/queue.php | 46 +++++----- config/services.php | 12 +-- config/session.php | 2 +- database/factories/CampaignFactory.php | 2 +- database/factories/ContactFactory.php | 2 +- database/factories/MailListFactory.php | 10 +-- database/factories/RssFeedFactory.php | 12 +-- database/factories/SendFactory.php | 8 +- database/factories/SendRecordFactory.php | 6 +- database/factories/SignupFactory.php | 6 +- database/factories/UserFactory.php | 8 +- .../2014_10_12_000000_create_users_table.php | 3 +- ...12_100000_create_password_resets_table.php | 3 +- ..._08_19_000000_create_failed_jobs_table.php | 3 +- ...020_12_19_160241_create_contacts_table.php | 3 +- ...0_12_19_210220_create_mail_lists_table.php | 3 +- ..._232646_create_contact_mail_list_table.php | 3 +- ...0_021342_add_description_to_mail_lists.php | 3 +- ...2020_12_20_173002_create_signups_table.php | 3 +- ...20_12_21_133705_create_campaigns_table.php | 3 +- .../2020_12_21_154723_create_sends_table.php | 3 +- .../2020_12_21_172757_create_jobs_table.php | 3 +- ...12_21_200457_create_send_records_table.php | 3 +- ...20_12_22_223257_create_rss_feeds_table.php | 3 +- ...05_000000_rename_password_resets_table.php | 3 +- public/index.php | 6 +- routes/auth.php | 32 +++---- routes/web.php | 2 +- tests/CreatesApplication.php | 2 +- tests/Feature/AddUserCommandTest.php | 10 +-- tests/Feature/AuthenticationTest.php | 4 +- tests/Feature/CampaignTest.php | 4 +- tests/Feature/ContactTest.php | 10 +-- tests/Feature/LaunchSendTest.php | 2 +- tests/Feature/MailListTest.php | 16 ++-- tests/Feature/PasswordResetTest.php | 8 +- tests/Feature/RssFeedReviewTest.php | 38 ++++---- tests/Feature/RssFeedTest.php | 20 ++--- tests/Feature/SendTest.php | 10 +-- tests/Feature/SignupTest.php | 8 +- tests/Feature/UserTest.php | 14 +-- tests/Unit/MailContentParserTest.php | 2 +- 81 files changed, 444 insertions(+), 431 deletions(-) diff --git a/app/Console/Commands/AddUserCommand.php b/app/Console/Commands/AddUserCommand.php index 3e643e3..a9c2f03 100644 --- a/app/Console/Commands/AddUserCommand.php +++ b/app/Console/Commands/AddUserCommand.php @@ -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; @@ -62,8 +62,8 @@ public function handle(): int } $user->fill([ - 'name' => $name, - 'email' => $email, + 'name' => $name, + 'email' => $email, 'password' => Hash::make($password), ]); $user->save(); diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index 878c946..022c8bc 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -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'); } diff --git a/app/Http/Controllers/Auth/ConfirmablePasswordController.php b/app/Http/Controllers/Auth/ConfirmablePasswordController.php index 22a024e..58a94bb 100644 --- a/app/Http/Controllers/Auth/ConfirmablePasswordController.php +++ b/app/Http/Controllers/Auth/ConfirmablePasswordController.php @@ -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([ diff --git a/app/Http/Controllers/Auth/NewPasswordController.php b/app/Http/Controllers/Auth/NewPasswordController.php index 1a7d6c0..6519ca2 100644 --- a/app/Http/Controllers/Auth/NewPasswordController.php +++ b/app/Http/Controllers/Auth/NewPasswordController.php @@ -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', ]); @@ -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(); @@ -57,6 +57,6 @@ function ($user) use ($request) { return $status == Password::PASSWORD_RESET ? redirect()->route('login')->with('status', __($status)) : back()->withInput($request->only('email')) - ->withErrors(['email' => __($status)]); + ->withErrors(['email' => __($status)]); } } diff --git a/app/Http/Controllers/Auth/PasswordResetLinkController.php b/app/Http/Controllers/Auth/PasswordResetLinkController.php index 1a4f6c7..3125ed3 100644 --- a/app/Http/Controllers/Auth/PasswordResetLinkController.php +++ b/app/Http/Controllers/Auth/PasswordResetLinkController.php @@ -41,6 +41,6 @@ public function store(Request $request): RedirectResponse return $status == Password::RESET_LINK_SENT ? back()->with('status', __($status)) : back()->withInput($request->only('email')) - ->withErrors(['email' => __($status)]); + ->withErrors(['email' => __($status)]); } } diff --git a/app/Http/Controllers/CampaignController.php b/app/Http/Controllers/CampaignController.php index 541c9dc..2031374 100644 --- a/app/Http/Controllers/CampaignController.php +++ b/app/Http/Controllers/CampaignController.php @@ -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(); @@ -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(); diff --git a/app/Http/Controllers/ContactController.php b/app/Http/Controllers/ContactController.php index 8f5a458..5978283 100644 --- a/app/Http/Controllers/ContactController.php +++ b/app/Http/Controllers/ContactController.php @@ -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(); @@ -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(); @@ -72,7 +72,7 @@ public function edit(Contact $contact): View })->toArray(); return view('contacts.edit', [ - 'contact' => $contact, + 'contact' => $contact, 'listOptions' => $allListOptions, ]); } @@ -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', ]); diff --git a/app/Http/Controllers/ContactListController.php b/app/Http/Controllers/ContactListController.php index 9d11606..d3f60ca 100644 --- a/app/Http/Controllers/ContactListController.php +++ b/app/Http/Controllers/ContactListController.php @@ -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', ]); @@ -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', ]); diff --git a/app/Http/Controllers/DashboardController.php b/app/Http/Controllers/DashboardController.php index 52d6ea9..0345340 100644 --- a/app/Http/Controllers/DashboardController.php +++ b/app/Http/Controllers/DashboardController.php @@ -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(), ]); } @@ -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(), ]; } diff --git a/app/Http/Controllers/ListController.php b/app/Http/Controllers/ListController.php index ed624cc..543c551 100644 --- a/app/Http/Controllers/ListController.php +++ b/app/Http/Controllers/ListController.php @@ -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(); @@ -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, ]); } @@ -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()); @@ -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()); diff --git a/app/Http/Controllers/RssFeedController.php b/app/Http/Controllers/RssFeedController.php index 9957102..c496c5a 100644 --- a/app/Http/Controllers/RssFeedController.php +++ b/app/Http/Controllers/RssFeedController.php @@ -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); @@ -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); diff --git a/app/Http/Controllers/SendController.php b/app/Http/Controllers/SendController.php index f3a6bcb..da3e208 100644 --- a/app/Http/Controllers/SendController.php +++ b/app/Http/Controllers/SendController.php @@ -35,7 +35,7 @@ public function create(Request $request): View } return view('sends.create', [ - 'send' => $default, + 'send' => $default, 'campaign' => $campaign, ]); } @@ -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); @@ -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); diff --git a/app/Http/Controllers/UnsubscribeController.php b/app/Http/Controllers/UnsubscribeController.php index 23e8491..fa65da0 100644 --- a/app/Http/Controllers/UnsubscribeController.php +++ b/app/Http/Controllers/UnsubscribeController.php @@ -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); } diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php index d86b2f8..2fda62c 100644 --- a/app/Http/Controllers/UserController.php +++ b/app/Http/Controllers/UserController.php @@ -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(); @@ -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(); @@ -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')); } diff --git a/app/Http/Kernel.php b/app/Http/Kernel.php index 9b050c5..21d42a5 100644 --- a/app/Http/Kernel.php +++ b/app/Http/Kernel.php @@ -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, ], ]; @@ -52,15 +52,15 @@ class Kernel extends HttpKernel * @var array */ 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, ]; } diff --git a/app/Http/Requests/Auth/LoginRequest.php b/app/Http/Requests/Auth/LoginRequest.php index edac377..e203ccf 100644 --- a/app/Http/Requests/Auth/LoginRequest.php +++ b/app/Http/Requests/Auth/LoginRequest.php @@ -27,7 +27,7 @@ public function authorize(): bool public function rules(): array { return [ - 'email' => ['required', 'string', 'email'], + 'email' => ['required', 'string', 'email'], 'password' => ['required', 'string'], ]; } @@ -42,7 +42,7 @@ public function authenticate(): void { $this->ensureIsNotRateLimited(); - if (!Auth::attempt($this->only('email', 'password'), $this->filled('remember'))) { + if (! Auth::attempt($this->only('email', 'password'), $this->filled('remember'))) { RateLimiter::hit($this->throttleKey()); throw ValidationException::withMessages([ @@ -61,7 +61,7 @@ public function authenticate(): void */ public function ensureIsNotRateLimited(): void { - if (!RateLimiter::tooManyAttempts($this->throttleKey(), 5)) { + if (! RateLimiter::tooManyAttempts($this->throttleKey(), 5)) { return; } @@ -82,6 +82,6 @@ public function ensureIsNotRateLimited(): void */ public function throttleKey(): string { - return Str::lower($this->input('email')) . '|' . $this->ip(); + return Str::lower($this->input('email')).'|'.$this->ip(); } } diff --git a/app/Jobs/FindRssFeedsToReviewJob.php b/app/Jobs/FindRssFeedsToReviewJob.php index 8bc0684..26ea2fe 100644 --- a/app/Jobs/FindRssFeedsToReviewJob.php +++ b/app/Jobs/FindRssFeedsToReviewJob.php @@ -14,7 +14,7 @@ * Finds pending RSS feeds to process and creates new * jobs for each that needs to be processed. */ -class FindRssFeedsToReviewJob implements ShouldQueue, ShouldBeUnique +class FindRssFeedsToReviewJob implements ShouldBeUnique, ShouldQueue { use Dispatchable; use InteractsWithQueue; diff --git a/app/Jobs/ReviewRssFeedJob.php b/app/Jobs/ReviewRssFeedJob.php index f4025e6..917721e 100644 --- a/app/Jobs/ReviewRssFeedJob.php +++ b/app/Jobs/ReviewRssFeedJob.php @@ -14,7 +14,7 @@ use Illuminate\Queue\InteractsWithQueue; use Illuminate\Queue\SerializesModels; -class ReviewRssFeedJob implements ShouldQueue, ShouldBeUnique +class ReviewRssFeedJob implements ShouldBeUnique, ShouldQueue { use Dispatchable; use InteractsWithQueue; @@ -46,7 +46,7 @@ public function uniqueId(): string */ public function handle(RssParser $rssParser): void { - if (!$this->feed->isPending()) { + if (! $this->feed->isPending()) { return; } diff --git a/app/Jobs/SendActivationJob.php b/app/Jobs/SendActivationJob.php index 0d83ffb..832e02c 100644 --- a/app/Jobs/SendActivationJob.php +++ b/app/Jobs/SendActivationJob.php @@ -44,7 +44,7 @@ public function handle(): void $sendRecords = $listMembers->map(function ($member) use ($sendKey, $recordKeys) { return new SendRecord([ 'contact_id' => $member->id, - 'key' => $sendKey . '-' . $recordKeys->pop(), + 'key' => $sendKey.'-'.$recordKeys->pop(), ]); }); diff --git a/app/Mail/SignupConfirmationMail.php b/app/Mail/SignupConfirmationMail.php index 22730ba..d03f882 100644 --- a/app/Mail/SignupConfirmationMail.php +++ b/app/Mail/SignupConfirmationMail.php @@ -31,8 +31,8 @@ public function __construct(Signup $signup) public function build(): static { return $this->subject("Confirm your subscription to {$this->signup->maillist->display_name}") - ->text('signups.confirmation-email', [ - 'signup' => $this->signup, - ]); + ->text('signups.confirmation-email', [ + 'signup' => $this->signup, + ]); } } diff --git a/app/Models/Campaign.php b/app/Models/Campaign.php index 06cb993..8c0956c 100644 --- a/app/Models/Campaign.php +++ b/app/Models/Campaign.php @@ -8,9 +8,9 @@ use Illuminate\Database\Eloquent\Relations\HasMany; /** - * @property int $id - * @property string $name - * @property Collection $sends + * @property int $id + * @property string $name + * @property Collection $sends * @property Collection $rssFeeds */ class Campaign extends Model diff --git a/app/Models/MailList.php b/app/Models/MailList.php index bd18e1b..b73a1c7 100644 --- a/app/Models/MailList.php +++ b/app/Models/MailList.php @@ -7,7 +7,7 @@ use Illuminate\Database\Eloquent\Relations\BelongsToMany; /** - * @property int $id + * @property int $id * @property string $name * @property string $slug * @property string $description diff --git a/app/Models/RssFeed.php b/app/Models/RssFeed.php index 5c190b2..0292f18 100644 --- a/app/Models/RssFeed.php +++ b/app/Models/RssFeed.php @@ -9,17 +9,17 @@ use Illuminate\Support\Carbon; /** - * @property int $id - * @property bool $active - * @property string $url - * @property Campaign $campaign - * @property Send $templateSend - * @property int $send_frequency - * @property int $target_hour + * @property int $id + * @property bool $active + * @property string $url + * @property Campaign $campaign + * @property Send $templateSend + * @property int $send_frequency + * @property int $target_hour * @property CarbonImmutable $last_reviewed_at * @property CarbonImmutable $next_review_at - * @property Carbon $updated_at - * @property Carbon $created_at + * @property Carbon $updated_at + * @property Carbon $created_at */ class RssFeed extends Model { @@ -35,7 +35,7 @@ class RssFeed extends Model */ protected $casts = [ 'last_reviewed_at' => 'immutable_datetime', - 'next_review_at' => 'immutable_datetime', + 'next_review_at' => 'immutable_datetime', ]; /** @@ -80,7 +80,7 @@ public function updateNextReviewDate(): void protected function getNextReviewDate(): CarbonImmutable { return $this->last_reviewed_at->clone() - ->addDays($this->send_frequency) - ->setHour($this->target_hour)->setMinutes(0); + ->addDays($this->send_frequency) + ->setHour($this->target_hour)->setMinutes(0); } } diff --git a/app/Models/Send.php b/app/Models/Send.php index 12b6e61..413b961 100644 --- a/app/Models/Send.php +++ b/app/Models/Send.php @@ -9,12 +9,12 @@ use Illuminate\Support\Carbon; /** - * @property int $id - * @property string $name - * @property string $content - * @property string $subject - * @property bool $activated - * @property ?Carbon $activated_at + * @property int $id + * @property string $name + * @property string $content + * @property string $subject + * @property bool $activated + * @property ?Carbon $activated_at * @property MailList $maillist * @property Campaign $campaign */ @@ -79,6 +79,6 @@ public function feeds(): HasMany */ public function getActivatedAttribute(): bool { - return !is_null($this->activated_at); + return ! is_null($this->activated_at); } } diff --git a/app/Models/SendRecord.php b/app/Models/SendRecord.php index 398008d..dc8b261 100644 --- a/app/Models/SendRecord.php +++ b/app/Models/SendRecord.php @@ -9,7 +9,7 @@ use Illuminate\Support\Str; /** - * @property Send $send + * @property Send $send * @property Contact $contact */ class SendRecord extends Model diff --git a/app/Models/Signup.php b/app/Models/Signup.php index 0806d75..a50d436 100644 --- a/app/Models/Signup.php +++ b/app/Models/Signup.php @@ -9,7 +9,7 @@ use Illuminate\Support\Str; /** - * @property string $email + * @property string $email * @property MailList $maillist */ class Signup extends Model diff --git a/app/Rules/ValidHCaptchaResult.php b/app/Rules/ValidHCaptchaResult.php index 8a94896..6f4d2ee 100644 --- a/app/Rules/ValidHCaptchaResult.php +++ b/app/Rules/ValidHCaptchaResult.php @@ -13,18 +13,18 @@ class ValidHCaptchaResult implements ValidationRule */ public function validate(string $attribute, mixed $value, Closure $fail): void { - if (!config('services.hcaptcha.active')) { + if (! config('services.hcaptcha.active')) { return; } $response = Http::asForm()->post('https://hcaptcha.com/siteverify', [ 'response' => $value, - 'secret' => config('services.hcaptcha.secretkey'), - 'sitekey' => config('services.hcaptcha.sitekey'), + 'secret' => config('services.hcaptcha.secretkey'), + 'sitekey' => config('services.hcaptcha.sitekey'), ]); $isValid = $response->json('success', false); - if (!$isValid) { + if (! $isValid) { $fail('The captcha result did not verify'); } } diff --git a/app/Rules/ValidRssFeedRule.php b/app/Rules/ValidRssFeedRule.php index c198452..e4ae245 100644 --- a/app/Rules/ValidRssFeedRule.php +++ b/app/Rules/ValidRssFeedRule.php @@ -18,9 +18,9 @@ public function validate(string $attribute, mixed $value, Closure $fail): void } $articles = (new RssParser())->getArticles($value); - $isValid = !is_null($articles) && $articles->count() > 0; + $isValid = ! is_null($articles) && $articles->count() > 0; - if (!$isValid) { + if (! $isValid) { $fail('This provided feed URL does not point to a valid RSS feed.'); } } diff --git a/app/Services/EmailListImporter.php b/app/Services/EmailListImporter.php index cb60f46..4d5d806 100644 --- a/app/Services/EmailListImporter.php +++ b/app/Services/EmailListImporter.php @@ -40,8 +40,7 @@ public function import(string $listOfEmails): array * and returning the counts of those added, separated by * whether they already existed in the database or not. * - * @param Collection $emailChunk - * + * @param Collection $emailChunk * @return array{new: int, existing: int} */ protected function importChunkOfEmails(Collection $emailChunk): array @@ -72,9 +71,9 @@ protected function importChunkOfEmails(Collection $emailChunk): array protected function newContactDataForEmail(string $email): array { return [ - 'email' => $email, - 'created_at' => now(), - 'updated_at' => now(), + 'email' => $email, + 'created_at' => now(), + 'updated_at' => now(), 'unsubscribed' => false, ]; } diff --git a/app/Services/MailContentParser.php b/app/Services/MailContentParser.php index f920ffe..a6f8d5b 100644 --- a/app/Services/MailContentParser.php +++ b/app/Services/MailContentParser.php @@ -29,12 +29,12 @@ public function parseForSend(SendRecord $record): string * Parse the content and insert the given RSS articles * where tagged in the content. * - * @param Collection $articles + * @param Collection $articles */ public function parseForRss(Collection $articles): string { - $rssSectionRegex = '/' . $this->tagRegex('rss_loop') - . '(.*?)' . $this->tagRegex('end_rss_loop') . '/s'; + $rssSectionRegex = '/'.$this->tagRegex('rss_loop') + .'(.*?)'.$this->tagRegex('end_rss_loop').'/s'; $matches = []; preg_match_all($rssSectionRegex, $this->content, $matches); @@ -67,8 +67,8 @@ protected function replaceArticleTags(string $content, RssArticle $article): str */ protected function addOrReplaceUnsubscribe(SendRecord $record): void { - if (!$this->hasTag($this->content, 'unsubscribe_link')) { - $this->content .= "\n\n" . 'Unsubscribe: {{unsubscribe_link}}'; + if (! $this->hasTag($this->content, 'unsubscribe_link')) { + $this->content .= "\n\n".'Unsubscribe: {{unsubscribe_link}}'; } $unsubLink = route('unsubscribe.show', ['sendRecord' => $record]); @@ -80,7 +80,7 @@ protected function addOrReplaceUnsubscribe(SendRecord $record): void */ protected function hasTag(string $content, string $tagName): bool { - return preg_match('/' . $this->tagRegex($tagName) . '/', $content); + return preg_match('/'.$this->tagRegex($tagName).'/', $content); } /** @@ -88,7 +88,7 @@ protected function hasTag(string $content, string $tagName): bool */ protected function replaceTag(string $content, string $tagName, string $replacement): string { - return preg_replace('/' . $this->tagRegex($tagName) . '/', $replacement, $content); + return preg_replace('/'.$this->tagRegex($tagName).'/', $replacement, $content); } /** @@ -96,6 +96,6 @@ protected function replaceTag(string $content, string $tagName, string $replacem */ protected function tagRegex(string $tagName): string { - return '{{\s*?' . $tagName . '\s*?}}'; + return '{{\s*?'.$tagName.'\s*?}}'; } } diff --git a/app/Services/Rss/RssParser.php b/app/Services/Rss/RssParser.php index 79e6bf7..687088c 100644 --- a/app/Services/Rss/RssParser.php +++ b/app/Services/Rss/RssParser.php @@ -19,7 +19,7 @@ class RssParser public function getArticles(string $url): ?Collection { $response = Http::get($url); - if (!$response->ok()) { + if (! $response->ok()) { return null; } diff --git a/config/auth.php b/config/auth.php index 850a5d9..7a4d5bc 100644 --- a/config/auth.php +++ b/config/auth.php @@ -14,7 +14,7 @@ */ 'defaults' => [ - 'guard' => 'web', + 'guard' => 'web', 'passwords' => 'users', ], @@ -37,14 +37,14 @@ 'guards' => [ 'web' => [ - 'driver' => 'session', + 'driver' => 'session', 'provider' => 'users', ], 'api' => [ - 'driver' => 'token', + 'driver' => 'token', 'provider' => 'users', - 'hash' => false, + 'hash' => false, ], ], @@ -68,7 +68,7 @@ 'providers' => [ 'users' => [ 'driver' => 'eloquent', - 'model' => App\Models\User::class, + 'model' => App\Models\User::class, ], // 'users' => [ @@ -99,8 +99,8 @@ 'passwords' => [ 'users' => [ 'provider' => 'users', - 'table' => 'password_reset_tokens', - 'expire' => 60, + 'table' => 'password_reset_tokens', + 'expire' => 60, 'throttle' => 60, ], ], diff --git a/config/broadcasting.php b/config/broadcasting.php index 27c0d01..9e4d4aa 100644 --- a/config/broadcasting.php +++ b/config/broadcasting.php @@ -31,16 +31,16 @@ 'connections' => [ 'pusher' => [ - 'driver' => 'pusher', - 'key' => env('PUSHER_APP_KEY'), - 'secret' => env('PUSHER_APP_SECRET'), - 'app_id' => env('PUSHER_APP_ID'), + 'driver' => 'pusher', + 'key' => env('PUSHER_APP_KEY'), + 'secret' => env('PUSHER_APP_SECRET'), + 'app_id' => env('PUSHER_APP_ID'), 'options' => [ - 'host' => env('PUSHER_HOST') ?: 'api-' . env('PUSHER_APP_CLUSTER', 'mt1') . '.pusher.com', - 'port' => env('PUSHER_PORT', 443), - 'scheme' => env('PUSHER_SCHEME', 'https'), + 'host' => env('PUSHER_HOST') ?: 'api-'.env('PUSHER_APP_CLUSTER', 'mt1').'.pusher.com', + 'port' => env('PUSHER_PORT', 443), + 'scheme' => env('PUSHER_SCHEME', 'https'), 'encrypted' => true, - 'useTLS' => env('PUSHER_SCHEME', 'https') === 'https', + 'useTLS' => env('PUSHER_SCHEME', 'https') === 'https', ], 'client_options' => [ // Guzzle client options: https://docs.guzzlephp.org/en/stable/request-options.html @@ -49,11 +49,11 @@ 'ably' => [ 'driver' => 'ably', - 'key' => env('ABLY_KEY'), + 'key' => env('ABLY_KEY'), ], 'redis' => [ - 'driver' => 'redis', + 'driver' => 'redis', 'connection' => 'default', ], diff --git a/config/cache.php b/config/cache.php index 79d3d5f..33bb295 100644 --- a/config/cache.php +++ b/config/cache.php @@ -38,26 +38,26 @@ ], 'array' => [ - 'driver' => 'array', + 'driver' => 'array', 'serialize' => false, ], 'database' => [ - 'driver' => 'database', - 'table' => 'cache', - 'connection' => null, + 'driver' => 'database', + 'table' => 'cache', + 'connection' => null, 'lock_connection' => null, ], 'file' => [ 'driver' => 'file', - 'path' => storage_path('framework/cache/data'), + 'path' => storage_path('framework/cache/data'), ], 'memcached' => [ - 'driver' => 'memcached', + 'driver' => 'memcached', 'persistent_id' => env('MEMCACHED_PERSISTENT_ID'), - 'sasl' => [ + 'sasl' => [ env('MEMCACHED_USERNAME'), env('MEMCACHED_PASSWORD'), ], @@ -66,25 +66,25 @@ ], 'servers' => [ [ - 'host' => env('MEMCACHED_HOST', '127.0.0.1'), - 'port' => env('MEMCACHED_PORT', 11211), + 'host' => env('MEMCACHED_HOST', '127.0.0.1'), + 'port' => env('MEMCACHED_PORT', 11211), 'weight' => 100, ], ], ], 'redis' => [ - 'driver' => 'redis', - 'connection' => 'cache', + 'driver' => 'redis', + 'connection' => 'cache', 'lock_connection' => 'default', ], 'dynamodb' => [ - 'driver' => 'dynamodb', - 'key' => env('AWS_ACCESS_KEY_ID'), - 'secret' => env('AWS_SECRET_ACCESS_KEY'), - 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), - 'table' => env('DYNAMODB_CACHE_TABLE', 'cache'), + 'driver' => 'dynamodb', + 'key' => env('AWS_ACCESS_KEY_ID'), + 'secret' => env('AWS_SECRET_ACCESS_KEY'), + 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), + 'table' => env('DYNAMODB_CACHE_TABLE', 'cache'), 'endpoint' => env('DYNAMODB_ENDPOINT'), ], @@ -105,6 +105,6 @@ | */ - 'prefix' => env('CACHE_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_') . '_cache_'), + 'prefix' => env('CACHE_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_cache_'), ]; diff --git a/config/database.php b/config/database.php index 684b50c..828f890 100644 --- a/config/database.php +++ b/config/database.php @@ -36,58 +36,58 @@ 'connections' => [ 'sqlite' => [ - 'driver' => 'sqlite', - 'url' => env('DATABASE_URL'), - 'database' => env('DB_DATABASE', storage_path('database/database.sqlite')), - 'prefix' => '', + 'driver' => 'sqlite', + 'url' => env('DATABASE_URL'), + 'database' => env('DB_DATABASE', storage_path('database/database.sqlite')), + 'prefix' => '', 'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true), ], 'mysql' => [ - 'driver' => 'mysql', - 'url' => env('DATABASE_URL'), - 'host' => env('DB_HOST', '127.0.0.1'), - 'port' => env('DB_PORT', '3306'), - 'database' => env('DB_DATABASE', 'forge'), - 'username' => env('DB_USERNAME', 'forge'), - 'password' => env('DB_PASSWORD', ''), - 'unix_socket' => env('DB_SOCKET', ''), - 'charset' => 'utf8mb4', - 'collation' => 'utf8mb4_unicode_ci', - 'prefix' => '', + 'driver' => 'mysql', + 'url' => env('DATABASE_URL'), + 'host' => env('DB_HOST', '127.0.0.1'), + 'port' => env('DB_PORT', '3306'), + 'database' => env('DB_DATABASE', 'forge'), + 'username' => env('DB_USERNAME', 'forge'), + 'password' => env('DB_PASSWORD', ''), + 'unix_socket' => env('DB_SOCKET', ''), + 'charset' => 'utf8mb4', + 'collation' => 'utf8mb4_unicode_ci', + 'prefix' => '', 'prefix_indexes' => true, - 'strict' => true, - 'engine' => null, - 'options' => extension_loaded('pdo_mysql') ? array_filter([ + 'strict' => true, + 'engine' => null, + 'options' => extension_loaded('pdo_mysql') ? array_filter([ PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'), ]) : [], ], 'pgsql' => [ - 'driver' => 'pgsql', - 'url' => env('DATABASE_URL'), - 'host' => env('DB_HOST', '127.0.0.1'), - 'port' => env('DB_PORT', '5432'), - 'database' => env('DB_DATABASE', 'forge'), - 'username' => env('DB_USERNAME', 'forge'), - 'password' => env('DB_PASSWORD', ''), - 'charset' => 'utf8', - 'prefix' => '', + 'driver' => 'pgsql', + 'url' => env('DATABASE_URL'), + 'host' => env('DB_HOST', '127.0.0.1'), + 'port' => env('DB_PORT', '5432'), + 'database' => env('DB_DATABASE', 'forge'), + 'username' => env('DB_USERNAME', 'forge'), + 'password' => env('DB_PASSWORD', ''), + 'charset' => 'utf8', + 'prefix' => '', 'prefix_indexes' => true, - 'search_path' => 'public', - 'sslmode' => 'prefer', + 'search_path' => 'public', + 'sslmode' => 'prefer', ], 'sqlsrv' => [ - 'driver' => 'sqlsrv', - 'url' => env('DATABASE_URL'), - 'host' => env('DB_HOST', 'localhost'), - 'port' => env('DB_PORT', '1433'), - 'database' => env('DB_DATABASE', 'forge'), - 'username' => env('DB_USERNAME', 'forge'), - 'password' => env('DB_PASSWORD', ''), - 'charset' => 'utf8', - 'prefix' => '', + 'driver' => 'sqlsrv', + 'url' => env('DATABASE_URL'), + 'host' => env('DB_HOST', 'localhost'), + 'port' => env('DB_PORT', '1433'), + 'database' => env('DB_DATABASE', 'forge'), + 'username' => env('DB_USERNAME', 'forge'), + 'password' => env('DB_PASSWORD', ''), + 'charset' => 'utf8', + 'prefix' => '', 'prefix_indexes' => true, // 'encrypt' => env('DB_ENCRYPT', 'yes'), // 'trust_server_certificate' => env('DB_TRUST_SERVER_CERTIFICATE', 'false'), @@ -125,24 +125,24 @@ 'options' => [ 'cluster' => env('REDIS_CLUSTER', 'redis'), - 'prefix' => env('REDIS_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_') . '_database_'), + 'prefix' => env('REDIS_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_database_'), ], 'default' => [ - 'url' => env('REDIS_URL'), - 'host' => env('REDIS_HOST', '127.0.0.1'), + 'url' => env('REDIS_URL'), + 'host' => env('REDIS_HOST', '127.0.0.1'), 'username' => env('REDIS_USERNAME'), 'password' => env('REDIS_PASSWORD'), - 'port' => env('REDIS_PORT', '6379'), + 'port' => env('REDIS_PORT', '6379'), 'database' => env('REDIS_DB', '0'), ], 'cache' => [ - 'url' => env('REDIS_URL'), - 'host' => env('REDIS_HOST', '127.0.0.1'), + 'url' => env('REDIS_URL'), + 'host' => env('REDIS_HOST', '127.0.0.1'), 'username' => env('REDIS_USERNAME'), 'password' => env('REDIS_PASSWORD'), - 'port' => env('REDIS_PORT', '6379'), + 'port' => env('REDIS_PORT', '6379'), 'database' => env('REDIS_CACHE_DB', '1'), ], diff --git a/config/filesystems.php b/config/filesystems.php index 63baccc..e9d9dbd 100644 --- a/config/filesystems.php +++ b/config/filesystems.php @@ -32,28 +32,28 @@ 'local' => [ 'driver' => 'local', - 'root' => storage_path('app'), - 'throw' => false, + 'root' => storage_path('app'), + 'throw' => false, ], 'public' => [ - 'driver' => 'local', - 'root' => storage_path('app/public'), - 'url' => env('APP_URL') . '/storage', + 'driver' => 'local', + 'root' => storage_path('app/public'), + 'url' => env('APP_URL').'/storage', 'visibility' => 'public', - 'throw' => false, + 'throw' => false, ], 's3' => [ - 'driver' => 's3', - 'key' => env('AWS_ACCESS_KEY_ID'), - 'secret' => env('AWS_SECRET_ACCESS_KEY'), - 'region' => env('AWS_DEFAULT_REGION'), - 'bucket' => env('AWS_BUCKET'), - 'url' => env('AWS_URL'), - 'endpoint' => env('AWS_ENDPOINT'), + 'driver' => 's3', + 'key' => env('AWS_ACCESS_KEY_ID'), + 'secret' => env('AWS_SECRET_ACCESS_KEY'), + 'region' => env('AWS_DEFAULT_REGION'), + 'bucket' => env('AWS_BUCKET'), + 'url' => env('AWS_URL'), + 'endpoint' => env('AWS_ENDPOINT'), 'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false), - 'throw' => false, + 'throw' => false, ], ], diff --git a/config/hashing.php b/config/hashing.php index 6160594..bcd3be4 100644 --- a/config/hashing.php +++ b/config/hashing.php @@ -44,9 +44,9 @@ */ 'argon' => [ - 'memory' => 65536, + 'memory' => 65536, 'threads' => 1, - 'time' => 4, + 'time' => 4, ], ]; diff --git a/config/logging.php b/config/logging.php index 2573c85..c44d276 100644 --- a/config/logging.php +++ b/config/logging.php @@ -33,7 +33,7 @@ 'deprecations' => [ 'channel' => env('LOG_DEPRECATIONS_CHANNEL', 'null'), - 'trace' => false, + 'trace' => false, ], /* @@ -53,73 +53,73 @@ 'channels' => [ 'stack' => [ - 'driver' => 'stack', - 'channels' => ['single'], + 'driver' => 'stack', + 'channels' => ['single'], 'ignore_exceptions' => false, ], 'single' => [ - 'driver' => 'single', - 'path' => storage_path('logs/laravel.log'), - 'level' => env('LOG_LEVEL', 'debug'), + 'driver' => 'single', + 'path' => storage_path('logs/laravel.log'), + 'level' => env('LOG_LEVEL', 'debug'), 'replace_placeholders' => true, ], 'daily' => [ - 'driver' => 'daily', - 'path' => storage_path('logs/laravel.log'), - 'level' => env('LOG_LEVEL', 'debug'), - 'days' => 14, + 'driver' => 'daily', + 'path' => storage_path('logs/laravel.log'), + 'level' => env('LOG_LEVEL', 'debug'), + 'days' => 14, 'replace_placeholders' => true, ], 'slack' => [ - 'driver' => 'slack', - 'url' => env('LOG_SLACK_WEBHOOK_URL'), - 'username' => 'Laravel Log', - 'emoji' => ':boom:', - 'level' => env('LOG_LEVEL', 'critical'), + 'driver' => 'slack', + 'url' => env('LOG_SLACK_WEBHOOK_URL'), + 'username' => 'Laravel Log', + 'emoji' => ':boom:', + 'level' => env('LOG_LEVEL', 'critical'), 'replace_placeholders' => true, ], 'papertrail' => [ - 'driver' => 'monolog', - 'level' => env('LOG_LEVEL', 'debug'), - 'handler' => env('LOG_PAPERTRAIL_HANDLER', SyslogUdpHandler::class), + 'driver' => 'monolog', + 'level' => env('LOG_LEVEL', 'debug'), + 'handler' => env('LOG_PAPERTRAIL_HANDLER', SyslogUdpHandler::class), 'handler_with' => [ - 'host' => env('PAPERTRAIL_URL'), - 'port' => env('PAPERTRAIL_PORT'), - 'connectionString' => 'tls://' . env('PAPERTRAIL_URL') . ':' . env('PAPERTRAIL_PORT'), + 'host' => env('PAPERTRAIL_URL'), + 'port' => env('PAPERTRAIL_PORT'), + 'connectionString' => 'tls://'.env('PAPERTRAIL_URL').':'.env('PAPERTRAIL_PORT'), ], 'processors' => [PsrLogMessageProcessor::class], ], 'stderr' => [ - 'driver' => 'monolog', - 'level' => env('LOG_LEVEL', 'debug'), - 'handler' => StreamHandler::class, + 'driver' => 'monolog', + 'level' => env('LOG_LEVEL', 'debug'), + 'handler' => StreamHandler::class, 'formatter' => env('LOG_STDERR_FORMATTER'), - 'with' => [ + 'with' => [ 'stream' => 'php://stderr', ], 'processors' => [PsrLogMessageProcessor::class], ], 'syslog' => [ - 'driver' => 'syslog', - 'level' => env('LOG_LEVEL', 'debug'), - 'facility' => LOG_USER, + 'driver' => 'syslog', + 'level' => env('LOG_LEVEL', 'debug'), + 'facility' => LOG_USER, 'replace_placeholders' => true, ], 'errorlog' => [ - 'driver' => 'errorlog', - 'level' => env('LOG_LEVEL', 'debug'), + 'driver' => 'errorlog', + 'level' => env('LOG_LEVEL', 'debug'), 'replace_placeholders' => true, ], 'null' => [ - 'driver' => 'monolog', + 'driver' => 'monolog', 'handler' => NullHandler::class, ], diff --git a/config/mail.php b/config/mail.php index d457b83..542d98c 100644 --- a/config/mail.php +++ b/config/mail.php @@ -35,13 +35,13 @@ 'mailers' => [ 'smtp' => [ - 'transport' => 'smtp', - 'host' => env('MAIL_HOST', 'smtp.mailgun.org'), - 'port' => env('MAIL_PORT', 587), - 'encryption' => env('MAIL_ENCRYPTION', 'tls'), - 'username' => env('MAIL_USERNAME'), - 'password' => env('MAIL_PASSWORD'), - 'timeout' => null, + 'transport' => 'smtp', + 'host' => env('MAIL_HOST', 'smtp.mailgun.org'), + 'port' => env('MAIL_PORT', 587), + 'encryption' => env('MAIL_ENCRYPTION', 'tls'), + 'username' => env('MAIL_USERNAME'), + 'password' => env('MAIL_PASSWORD'), + 'timeout' => null, 'local_domain' => env('MAIL_EHLO_DOMAIN'), ], @@ -65,12 +65,12 @@ 'sendmail' => [ 'transport' => 'sendmail', - 'path' => env('MAIL_SENDMAIL_PATH', '/usr/sbin/sendmail -bs -i'), + 'path' => env('MAIL_SENDMAIL_PATH', '/usr/sbin/sendmail -bs -i'), ], 'log' => [ 'transport' => 'log', - 'channel' => env('MAIL_LOG_CHANNEL'), + 'channel' => env('MAIL_LOG_CHANNEL'), ], 'array' => [ @@ -79,7 +79,7 @@ 'failover' => [ 'transport' => 'failover', - 'mailers' => [ + 'mailers' => [ 'smtp', 'log', ], @@ -99,7 +99,7 @@ 'from' => [ 'address' => env('MAIL_FROM_ADDRESS', 'hello@example.com'), - 'name' => env('MAIL_FROM_NAME', 'Example'), + 'name' => env('MAIL_FROM_NAME', 'Example'), ], /* diff --git a/config/queue.php b/config/queue.php index 84f7438..25ea5a8 100644 --- a/config/queue.php +++ b/config/queue.php @@ -35,39 +35,39 @@ ], 'database' => [ - 'driver' => 'database', - 'table' => 'jobs', - 'queue' => 'default', - 'retry_after' => 90, + 'driver' => 'database', + 'table' => 'jobs', + 'queue' => 'default', + 'retry_after' => 90, 'after_commit' => false, ], 'beanstalkd' => [ - 'driver' => 'beanstalkd', - 'host' => 'localhost', - 'queue' => 'default', - 'retry_after' => 90, - 'block_for' => 0, + 'driver' => 'beanstalkd', + 'host' => 'localhost', + 'queue' => 'default', + 'retry_after' => 90, + 'block_for' => 0, 'after_commit' => false, ], 'sqs' => [ - 'driver' => 'sqs', - 'key' => env('AWS_ACCESS_KEY_ID'), - 'secret' => env('AWS_SECRET_ACCESS_KEY'), - 'prefix' => env('SQS_PREFIX', 'https://sqs.us-east-1.amazonaws.com/your-account-id'), - 'queue' => env('SQS_QUEUE', 'default'), - 'suffix' => env('SQS_SUFFIX'), - 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), + 'driver' => 'sqs', + 'key' => env('AWS_ACCESS_KEY_ID'), + 'secret' => env('AWS_SECRET_ACCESS_KEY'), + 'prefix' => env('SQS_PREFIX', 'https://sqs.us-east-1.amazonaws.com/your-account-id'), + 'queue' => env('SQS_QUEUE', 'default'), + 'suffix' => env('SQS_SUFFIX'), + 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), 'after_commit' => false, ], 'redis' => [ - 'driver' => 'redis', - 'connection' => 'default', - 'queue' => env('REDIS_QUEUE', 'default'), - 'retry_after' => 90, - 'block_for' => null, + 'driver' => 'redis', + 'connection' => 'default', + 'queue' => env('REDIS_QUEUE', 'default'), + 'retry_after' => 90, + 'block_for' => null, 'after_commit' => false, ], @@ -85,9 +85,9 @@ */ 'failed' => [ - 'driver' => env('QUEUE_FAILED_DRIVER', 'database-uuids'), + 'driver' => env('QUEUE_FAILED_DRIVER', 'database-uuids'), 'database' => env('DB_CONNECTION', 'mysql'), - 'table' => 'failed_jobs', + 'table' => 'failed_jobs', ], ]; diff --git a/config/services.php b/config/services.php index 34b5763..82202e2 100644 --- a/config/services.php +++ b/config/services.php @@ -3,8 +3,8 @@ return [ 'hcaptcha' => [ - 'active' => !empty(env('HCAPTCHA_SITEKEY', null)), - 'sitekey' => env('HCAPTCHA_SITEKEY', null), + 'active' => ! empty(env('HCAPTCHA_SITEKEY', null)), + 'sitekey' => env('HCAPTCHA_SITEKEY', null), 'secretkey' => env('HCAPTCHA_SECRETKEY', null), ], @@ -21,10 +21,10 @@ */ 'mailgun' => [ - 'domain' => env('MAILGUN_DOMAIN'), - 'secret' => env('MAILGUN_SECRET'), + 'domain' => env('MAILGUN_DOMAIN'), + 'secret' => env('MAILGUN_SECRET'), 'endpoint' => env('MAILGUN_ENDPOINT', 'api.mailgun.net'), - 'scheme' => 'https', + 'scheme' => 'https', ], 'postmark' => [ @@ -32,7 +32,7 @@ ], 'ses' => [ - 'key' => env('AWS_ACCESS_KEY_ID'), + 'key' => env('AWS_ACCESS_KEY_ID'), 'secret' => env('AWS_SECRET_ACCESS_KEY'), 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), ], diff --git a/config/session.php b/config/session.php index 1b99f22..8fed97c 100644 --- a/config/session.php +++ b/config/session.php @@ -128,7 +128,7 @@ 'cookie' => env( 'SESSION_COOKIE', - Str::slug(env('APP_NAME', 'laravel'), '_') . '_session' + Str::slug(env('APP_NAME', 'laravel'), '_').'_session' ), /* diff --git a/database/factories/CampaignFactory.php b/database/factories/CampaignFactory.php index ad65742..4f98aae 100644 --- a/database/factories/CampaignFactory.php +++ b/database/factories/CampaignFactory.php @@ -12,7 +12,7 @@ class CampaignFactory extends Factory public function definition(): array { return [ - 'name' => $this->faker->country() . ' Send ' . strval(rand(2000, 2040)), + 'name' => $this->faker->country().' Send '.strval(rand(2000, 2040)), ]; } } diff --git a/database/factories/ContactFactory.php b/database/factories/ContactFactory.php index 8c2cd1c..067e7ac 100644 --- a/database/factories/ContactFactory.php +++ b/database/factories/ContactFactory.php @@ -12,7 +12,7 @@ class ContactFactory extends Factory public function definition(): array { return [ - 'email' => $this->faker->unique()->email(), + 'email' => $this->faker->unique()->email(), 'unsubscribed' => rand(0, 1) === 0, ]; } diff --git a/database/factories/MailListFactory.php b/database/factories/MailListFactory.php index 33223e7..7059097 100644 --- a/database/factories/MailListFactory.php +++ b/database/factories/MailListFactory.php @@ -12,13 +12,13 @@ class MailListFactory extends Factory */ public function definition(): array { - $name = $this->faker->country() . ' ' . Str::random(5) . ' List'; + $name = $this->faker->country().' '.Str::random(5).' List'; return [ - 'name' => $name, - 'slug' => Str::slug($name), - 'display_name' => 'The great ' . $name, - 'description' => $this->faker->sentence(), + 'name' => $name, + 'slug' => Str::slug($name), + 'display_name' => 'The great '.$name, + 'description' => $this->faker->sentence(), ]; } } diff --git a/database/factories/RssFeedFactory.php b/database/factories/RssFeedFactory.php index 660786a..0b462c9 100644 --- a/database/factories/RssFeedFactory.php +++ b/database/factories/RssFeedFactory.php @@ -16,13 +16,13 @@ public function definition(): array $campaign = Campaign::factory()->create(); return [ - 'active' => true, - 'url' => $this->faker->url() . '.xml', - 'campaign_id' => $campaign->id, + 'active' => true, + 'url' => $this->faker->url().'.xml', + 'campaign_id' => $campaign->id, 'template_send_id' => Send::factory()->for($campaign), - 'send_frequency' => 7, - 'target_hour' => 12, - 'next_review_at' => now()->addDays(7), + 'send_frequency' => 7, + 'target_hour' => 12, + 'next_review_at' => now()->addDays(7), 'last_reviewed_at' => now(), ]; } diff --git a/database/factories/SendFactory.php b/database/factories/SendFactory.php index 1190ce6..7af44e6 100644 --- a/database/factories/SendFactory.php +++ b/database/factories/SendFactory.php @@ -14,11 +14,11 @@ class SendFactory extends Factory public function definition(): array { return [ - 'name' => 'Send ' . $this->faker->state() . ' ' . $this->faker->month(), - 'content' => implode("\n\n", $this->faker->paragraphs(3)), - 'subject' => $this->faker->company() . ' ' . $this->faker->sentence(), + 'name' => 'Send '.$this->faker->state().' '.$this->faker->month(), + 'content' => implode("\n\n", $this->faker->paragraphs(3)), + 'subject' => $this->faker->company().' '.$this->faker->sentence(), 'mail_list_id' => MailList::factory(), - 'campaign_id' => Campaign::factory(), + 'campaign_id' => Campaign::factory(), 'activated_at' => null, ]; } diff --git a/database/factories/SendRecordFactory.php b/database/factories/SendRecordFactory.php index 6f8beeb..e30852c 100644 --- a/database/factories/SendRecordFactory.php +++ b/database/factories/SendRecordFactory.php @@ -16,9 +16,9 @@ public function definition(): array { return [ 'contact_id' => Contact::factory()->subscribed(), - 'send_id' => Send::factory(), - 'sent_at' => rand(0, 1) === 1 ? null : $this->faker->dateTimeThisDecade(), - 'key' => Str::random(16) . '-' . Str::random(16), + 'send_id' => Send::factory(), + 'sent_at' => rand(0, 1) === 1 ? null : $this->faker->dateTimeThisDecade(), + 'key' => Str::random(16).'-'.Str::random(16), ]; } } diff --git a/database/factories/SignupFactory.php b/database/factories/SignupFactory.php index 480bb64..052de3e 100644 --- a/database/factories/SignupFactory.php +++ b/database/factories/SignupFactory.php @@ -14,10 +14,10 @@ class SignupFactory extends Factory public function definition(): array { return [ - 'email' => $this->faker->email(), + 'email' => $this->faker->email(), 'mail_list_id' => MailList::factory(), - 'key' => Str::random(32), - 'attempts' => 0, + 'key' => Str::random(32), + 'attempts' => 0, ]; } } diff --git a/database/factories/UserFactory.php b/database/factories/UserFactory.php index c4378cb..a6ecc0a 100644 --- a/database/factories/UserFactory.php +++ b/database/factories/UserFactory.php @@ -18,11 +18,11 @@ class UserFactory extends Factory public function definition(): array { return [ - 'name' => fake()->name(), - 'email' => fake()->unique()->safeEmail(), + 'name' => fake()->name(), + 'email' => fake()->unique()->safeEmail(), 'email_verified_at' => now(), - 'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // password - 'remember_token' => Str::random(10), + 'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // password + 'remember_token' => Str::random(10), ]; } diff --git a/database/migrations/2014_10_12_000000_create_users_table.php b/database/migrations/2014_10_12_000000_create_users_table.php index 2fb647b..1f97419 100644 --- a/database/migrations/2014_10_12_000000_create_users_table.php +++ b/database/migrations/2014_10_12_000000_create_users_table.php @@ -4,7 +4,8 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; -return new class() extends Migration { +return new class() extends Migration +{ /** * Run the migrations. */ diff --git a/database/migrations/2014_10_12_100000_create_password_resets_table.php b/database/migrations/2014_10_12_100000_create_password_resets_table.php index 1695705..a194bbd 100644 --- a/database/migrations/2014_10_12_100000_create_password_resets_table.php +++ b/database/migrations/2014_10_12_100000_create_password_resets_table.php @@ -4,7 +4,8 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; -return new class() extends Migration { +return new class() extends Migration +{ /** * Run the migrations. */ diff --git a/database/migrations/2019_08_19_000000_create_failed_jobs_table.php b/database/migrations/2019_08_19_000000_create_failed_jobs_table.php index 6876828..3eec77b 100644 --- a/database/migrations/2019_08_19_000000_create_failed_jobs_table.php +++ b/database/migrations/2019_08_19_000000_create_failed_jobs_table.php @@ -4,7 +4,8 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; -return new class() extends Migration { +return new class() extends Migration +{ /** * Run the migrations. */ diff --git a/database/migrations/2020_12_19_160241_create_contacts_table.php b/database/migrations/2020_12_19_160241_create_contacts_table.php index b6d9c13..b15f5f7 100644 --- a/database/migrations/2020_12_19_160241_create_contacts_table.php +++ b/database/migrations/2020_12_19_160241_create_contacts_table.php @@ -4,7 +4,8 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; -return new class() extends Migration { +return new class() extends Migration +{ /** * Run the migrations. */ diff --git a/database/migrations/2020_12_19_210220_create_mail_lists_table.php b/database/migrations/2020_12_19_210220_create_mail_lists_table.php index 4d5941d..b5e6fb2 100644 --- a/database/migrations/2020_12_19_210220_create_mail_lists_table.php +++ b/database/migrations/2020_12_19_210220_create_mail_lists_table.php @@ -4,7 +4,8 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; -return new class() extends Migration { +return new class() extends Migration +{ /** * Run the migrations. */ diff --git a/database/migrations/2020_12_19_232646_create_contact_mail_list_table.php b/database/migrations/2020_12_19_232646_create_contact_mail_list_table.php index ef6e7b6..9f4c5e0 100644 --- a/database/migrations/2020_12_19_232646_create_contact_mail_list_table.php +++ b/database/migrations/2020_12_19_232646_create_contact_mail_list_table.php @@ -4,7 +4,8 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; -return new class() extends Migration { +return new class() extends Migration +{ /** * Run the migrations. */ diff --git a/database/migrations/2020_12_20_021342_add_description_to_mail_lists.php b/database/migrations/2020_12_20_021342_add_description_to_mail_lists.php index 5d1e858..afc848a 100644 --- a/database/migrations/2020_12_20_021342_add_description_to_mail_lists.php +++ b/database/migrations/2020_12_20_021342_add_description_to_mail_lists.php @@ -4,7 +4,8 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; -return new class() extends Migration { +return new class() extends Migration +{ /** * Run the migrations. */ diff --git a/database/migrations/2020_12_20_173002_create_signups_table.php b/database/migrations/2020_12_20_173002_create_signups_table.php index bb54700..74b0481 100644 --- a/database/migrations/2020_12_20_173002_create_signups_table.php +++ b/database/migrations/2020_12_20_173002_create_signups_table.php @@ -4,7 +4,8 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; -return new class() extends Migration { +return new class() extends Migration +{ /** * Run the migrations. */ diff --git a/database/migrations/2020_12_21_133705_create_campaigns_table.php b/database/migrations/2020_12_21_133705_create_campaigns_table.php index e822259..741ad38 100644 --- a/database/migrations/2020_12_21_133705_create_campaigns_table.php +++ b/database/migrations/2020_12_21_133705_create_campaigns_table.php @@ -4,7 +4,8 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; -return new class() extends Migration { +return new class() extends Migration +{ /** * Run the migrations. */ diff --git a/database/migrations/2020_12_21_154723_create_sends_table.php b/database/migrations/2020_12_21_154723_create_sends_table.php index 147e489..e448896 100644 --- a/database/migrations/2020_12_21_154723_create_sends_table.php +++ b/database/migrations/2020_12_21_154723_create_sends_table.php @@ -4,7 +4,8 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; -return new class() extends Migration { +return new class() extends Migration +{ /** * Run the migrations. */ diff --git a/database/migrations/2020_12_21_172757_create_jobs_table.php b/database/migrations/2020_12_21_172757_create_jobs_table.php index a10216e..6536dba 100644 --- a/database/migrations/2020_12_21_172757_create_jobs_table.php +++ b/database/migrations/2020_12_21_172757_create_jobs_table.php @@ -4,7 +4,8 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; -return new class() extends Migration { +return new class() extends Migration +{ /** * Run the migrations. */ diff --git a/database/migrations/2020_12_21_200457_create_send_records_table.php b/database/migrations/2020_12_21_200457_create_send_records_table.php index 1105edd..cbba900 100644 --- a/database/migrations/2020_12_21_200457_create_send_records_table.php +++ b/database/migrations/2020_12_21_200457_create_send_records_table.php @@ -4,7 +4,8 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; -return new class() extends Migration { +return new class() extends Migration +{ /** * Run the migrations. */ diff --git a/database/migrations/2020_12_22_223257_create_rss_feeds_table.php b/database/migrations/2020_12_22_223257_create_rss_feeds_table.php index dbc47be..3d83dae 100644 --- a/database/migrations/2020_12_22_223257_create_rss_feeds_table.php +++ b/database/migrations/2020_12_22_223257_create_rss_feeds_table.php @@ -4,7 +4,8 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; -return new class() extends Migration { +return new class() extends Migration +{ /** * Run the migrations. */ diff --git a/database/migrations/2023_05_05_000000_rename_password_resets_table.php b/database/migrations/2023_05_05_000000_rename_password_resets_table.php index 16e0351..acbc335 100644 --- a/database/migrations/2023_05_05_000000_rename_password_resets_table.php +++ b/database/migrations/2023_05_05_000000_rename_password_resets_table.php @@ -3,7 +3,8 @@ use Illuminate\Database\Migrations\Migration; use Illuminate\Support\Facades\Schema; -return new class() extends Migration { +return new class() extends Migration +{ /** * Run the migrations. */ diff --git a/public/index.php b/public/index.php index f3c2ebc..1d69f3a 100644 --- a/public/index.php +++ b/public/index.php @@ -16,7 +16,7 @@ | */ -if (file_exists($maintenance = __DIR__ . '/../storage/framework/maintenance.php')) { +if (file_exists($maintenance = __DIR__.'/../storage/framework/maintenance.php')) { require $maintenance; } @@ -31,7 +31,7 @@ | */ -require __DIR__ . '/../vendor/autoload.php'; +require __DIR__.'/../vendor/autoload.php'; /* |-------------------------------------------------------------------------- @@ -44,7 +44,7 @@ | */ -$app = require_once __DIR__ . '/../bootstrap/app.php'; +$app = require_once __DIR__.'/../bootstrap/app.php'; $kernel = $app->make(Kernel::class); diff --git a/routes/auth.php b/routes/auth.php index 27b25c7..b47af81 100644 --- a/routes/auth.php +++ b/routes/auth.php @@ -7,35 +7,35 @@ use Illuminate\Support\Facades\Route; Route::get('/login', [AuthenticatedSessionController::class, 'create']) - ->middleware('guest') - ->name('login'); + ->middleware('guest') + ->name('login'); Route::post('/login', [AuthenticatedSessionController::class, 'store']) - ->middleware('guest'); + ->middleware('guest'); Route::get('/forgot-password', [PasswordResetLinkController::class, 'create']) - ->middleware('guest') - ->name('password.request'); + ->middleware('guest') + ->name('password.request'); Route::post('/forgot-password', [PasswordResetLinkController::class, 'store']) - ->middleware('guest') - ->name('password.email'); + ->middleware('guest') + ->name('password.email'); Route::get('/reset-password/{token}', [NewPasswordController::class, 'create']) - ->middleware('guest') - ->name('password.reset'); + ->middleware('guest') + ->name('password.reset'); Route::post('/reset-password', [NewPasswordController::class, 'store']) - ->middleware('guest') - ->name('password.update'); + ->middleware('guest') + ->name('password.update'); Route::get('/confirm-password', [ConfirmablePasswordController::class, 'show']) - ->middleware('auth') - ->name('password.confirm'); + ->middleware('auth') + ->name('password.confirm'); Route::post('/confirm-password', [ConfirmablePasswordController::class, 'store']) - ->middleware('auth'); + ->middleware('auth'); Route::post('/logout', [AuthenticatedSessionController::class, 'destroy']) - ->middleware('auth') - ->name('logout'); + ->middleware('auth') + ->name('logout'); diff --git a/routes/web.php b/routes/web.php index f7d4d71..a310990 100644 --- a/routes/web.php +++ b/routes/web.php @@ -99,4 +99,4 @@ Route::delete('/users/{user}', [UserController::class, 'destroy'])->name('users.destroy'); }); -require __DIR__ . '/auth.php'; +require __DIR__.'/auth.php'; diff --git a/tests/CreatesApplication.php b/tests/CreatesApplication.php index e3ad27e..cc68301 100644 --- a/tests/CreatesApplication.php +++ b/tests/CreatesApplication.php @@ -12,7 +12,7 @@ trait CreatesApplication */ public function createApplication(): Application { - $app = require __DIR__ . '/../bootstrap/app.php'; + $app = require __DIR__.'/../bootstrap/app.php'; $app->make(Kernel::class)->bootstrap(); diff --git a/tests/Feature/AddUserCommandTest.php b/tests/Feature/AddUserCommandTest.php index e977b86..5671b56 100644 --- a/tests/Feature/AddUserCommandTest.php +++ b/tests/Feature/AddUserCommandTest.php @@ -17,7 +17,7 @@ public function test_create_new_user(): void ->expectsOutput('User created, You can now login with the email barry@example.com and your provided password.'); $this->assertDatabaseHas('users', [ - 'name' => 'Barry', + 'name' => 'Barry', 'email' => 'barry@example.com', ]); @@ -45,8 +45,8 @@ public function test_command_when_email_used(): void ->expectsOutput('User created, You can now login with the email barry@example.com and your provided password.'); $this->assertDatabaseHas('users', [ - 'id' => $user->id, - 'name' => 'Barry 123', + 'id' => $user->id, + 'name' => 'Barry 123', 'email' => 'barry@example.com', ]); } @@ -63,8 +63,8 @@ public function test_command_when_email_used_but_reject_update(): void ->assertExitCode(1); $this->assertDatabaseMissing('users', [ - 'id' => $user->id, - 'name' => 'Barry 123', + 'id' => $user->id, + 'name' => 'Barry 123', 'email' => 'barry@example.com', ]); } diff --git a/tests/Feature/AuthenticationTest.php b/tests/Feature/AuthenticationTest.php index 12d9341..6b8fe0f 100644 --- a/tests/Feature/AuthenticationTest.php +++ b/tests/Feature/AuthenticationTest.php @@ -23,7 +23,7 @@ public function test_users_can_authenticate_using_the_login_screen(): void $user = User::factory()->create(); $response = $this->post('/login', [ - 'email' => $user->email, + 'email' => $user->email, 'password' => 'password', ]); @@ -36,7 +36,7 @@ public function test_users_can_not_authenticate_with_invalid_password(): void $user = User::factory()->create(); $this->post('/login', [ - 'email' => $user->email, + 'email' => $user->email, 'password' => 'wrong-password', ]); diff --git a/tests/Feature/CampaignTest.php b/tests/Feature/CampaignTest.php index 8686931..28129e6 100644 --- a/tests/Feature/CampaignTest.php +++ b/tests/Feature/CampaignTest.php @@ -35,9 +35,9 @@ public function test_campaigns_index_can_be_searched(): void $response = $this->whileLoggedIn()->get('/campaigns'); $response->assertDontSee($campaigns[105]->name); - $response = $this->get('/campaigns?search=' . $campaigns[105]->name); + $response = $this->get('/campaigns?search='.$campaigns[105]->name); $response->assertSee("/campaigns/{$campaigns[105]->id}"); - $response->assertSee('value="' . e($campaigns[105]->name) . '"', false); + $response->assertSee('value="'.e($campaigns[105]->name).'"', false); } public function test_campaign_can_be_viewed(): void diff --git a/tests/Feature/ContactTest.php b/tests/Feature/ContactTest.php index 3c5907e..f9ad949 100644 --- a/tests/Feature/ContactTest.php +++ b/tests/Feature/ContactTest.php @@ -35,7 +35,7 @@ public function test_contacts_index_can_be_searched(): void $response = $this->whileLoggedIn()->get('/contacts'); $response->assertDontSee($contacts[105]->email); - $response = $this->get('/contacts?search=' . $contacts[105]->email); + $response = $this->get('/contacts?search='.$contacts[105]->email); $response->assertSee("/contacts/{$contacts[105]->id}"); $response->assertSee("value=\"{$contacts[105]->email}\"", false); } @@ -54,14 +54,14 @@ public function test_contact_can_be_saved(): void $contact = Contact::factory()->create(); $response = $this->whileLoggedIn()->followingRedirects()->put("/contacts/{$contact->id}", [ - 'email' => 'updated@example.com', + 'email' => 'updated@example.com', 'unsubscribed' => '1', ]); $response->assertSee('updated@example.com'); $response->assertSee('Contact updated!'); $this->assertDatabaseHas('contacts', [ - 'id' => $contact->id, - 'email' => 'updated@example.com', + 'id' => $contact->id, + 'email' => 'updated@example.com', 'unsubscribed' => true, ]); } @@ -95,7 +95,7 @@ public function test_contact_create_request(): void $response->assertSee('barry@example.com'); $response->assertSee('Contact created'); $this->assertDatabaseHas('contacts', [ - 'email' => 'barry@example.com', + 'email' => 'barry@example.com', 'unsubscribed' => false, ]); } diff --git a/tests/Feature/LaunchSendTest.php b/tests/Feature/LaunchSendTest.php index a565735..f817b0e 100644 --- a/tests/Feature/LaunchSendTest.php +++ b/tests/Feature/LaunchSendTest.php @@ -57,7 +57,7 @@ public function test_send_activation_job_creates_send_records_and_jobs_for_each_ $this->assertEquals(100, SendRecord::query()->where('send_id', '=', $send->id)->count()); $this->assertDatabaseHas('send_records', [ - 'send_id' => $send->id, + 'send_id' => $send->id, 'contact_id' => $contacts->first()->id, ]); $this->assertNotNull($send->records()->first()->key); diff --git a/tests/Feature/MailListTest.php b/tests/Feature/MailListTest.php index 11f1a71..4255a16 100644 --- a/tests/Feature/MailListTest.php +++ b/tests/Feature/MailListTest.php @@ -36,9 +36,9 @@ public function test_lists_index_can_be_searched(): void $response = $this->whileLoggedIn()->get('/lists'); $response->assertDontSee($lists[105]->name); - $response = $this->get('/lists?search=' . $lists[105]->name); + $response = $this->get('/lists?search='.$lists[105]->name); $response->assertSee("/lists/{$lists[105]->id}"); - $response->assertSee('value="' . e($lists[105]->name) . '"', false); + $response->assertSee('value="'.e($lists[105]->name).'"', false); } public function test_can_see_contacts_on_list_show_page(): void @@ -56,10 +56,10 @@ public function test_can_see_list_details_on_show_page(): void { /** @var MailList $list */ $list = MailList::factory()->create([ - 'name' => 'My test list', - 'description' => 'A test list', + 'name' => 'My test list', + 'description' => 'A test list', 'display_name' => 'List display name', - 'slug' => 'a-list-slug', + 'slug' => 'a-list-slug', ]); $response = $this->whileLoggedIn()->get("/lists/{$list->id}"); @@ -83,9 +83,9 @@ public function test_list_can_be_saved(): void $list = MailList::factory()->create(); $details = [ - 'name' => 'My new internal list', + 'name' => 'My new internal list', 'display_name' => 'My cool list', - 'slug' => 'my_list', + 'slug' => 'my_list', ]; $response = $this->whileLoggedIn()->followingRedirects()->put("/lists/{$list->id}", $details); @@ -117,7 +117,7 @@ public function test_new_list_view(): void public function test_list_create_request(): void { $details = [ - 'name' => 'My new internal list', + 'name' => 'My new internal list', 'display_name' => 'My cool list', ]; $response = $this->whileLoggedIn()->followingRedirects()->post('/lists', $details); diff --git a/tests/Feature/PasswordResetTest.php b/tests/Feature/PasswordResetTest.php index bc574fd..d2c7e27 100644 --- a/tests/Feature/PasswordResetTest.php +++ b/tests/Feature/PasswordResetTest.php @@ -39,7 +39,7 @@ public function test_reset_password_screen_can_be_rendered(): void $this->post('/forgot-password', ['email' => $user->email]); Notification::assertSentTo($user, ResetPassword::class, function ($notification) { - $response = $this->get('/reset-password/' . $notification->token); + $response = $this->get('/reset-password/'.$notification->token); $response->assertStatus(200); @@ -57,9 +57,9 @@ public function test_password_can_be_reset_with_valid_token(): void Notification::assertSentTo($user, ResetPassword::class, function ($notification) use ($user) { $response = $this->post('/reset-password', [ - 'token' => $notification->token, - 'email' => $user->email, - 'password' => 'password', + 'token' => $notification->token, + 'email' => $user->email, + 'password' => 'password', 'password_confirmation' => 'password', ]); diff --git a/tests/Feature/RssFeedReviewTest.php b/tests/Feature/RssFeedReviewTest.php index 213a53f..1bf53c3 100644 --- a/tests/Feature/RssFeedReviewTest.php +++ b/tests/Feature/RssFeedReviewTest.php @@ -17,15 +17,15 @@ public function test_find_rss_feeds_to_review_jobs_correctly_creates_review_jobs { $pendingFeed = RssFeed::factory()->create([ 'last_reviewed_at' => now()->subMonth(), - 'send_frequency' => 7, - 'next_review_at' => now()->subDays(15), - 'active' => true, + 'send_frequency' => 7, + 'next_review_at' => now()->subDays(15), + 'active' => true, ]); $nonPendingFeed = RssFeed::factory()->create([ 'last_reviewed_at' => now()->subDay(), - 'send_frequency' => 7, - 'next_review_at' => now()->addHour(), - 'active' => true, + 'send_frequency' => 7, + 'next_review_at' => now()->addHour(), + 'active' => true, ]); Bus::fake(); @@ -37,9 +37,9 @@ public function test_find_rss_feeds_to_review_job_ignores_inactive_feeds(): void { $pendingFeed = RssFeed::factory()->create([ 'last_reviewed_at' => now()->subMonth(), - 'send_frequency' => 7, - 'next_review_at' => now()->subDays(15), - 'active' => false, + 'send_frequency' => 7, + 'next_review_at' => now()->subDays(15), + 'active' => false, ]); Bus::fake(); @@ -53,9 +53,9 @@ public function test_review_rss_feed_job_does_nothing_if_feed_inactive(): void /** @var RssFeed $pendingFeed */ $pendingFeed = RssFeed::factory()->create([ 'last_reviewed_at' => $lastReviewed, - 'send_frequency' => 7, - 'next_review_at' => now()->subDays(15), - 'active' => false, + 'send_frequency' => 7, + 'next_review_at' => now()->subDays(15), + 'active' => false, ]); Bus::fake(); @@ -71,9 +71,9 @@ public function test_review_rss_feed_job_does_nothing_if_feed_not_due(): void /** @var RssFeed $pendingFeed */ $pendingFeed = RssFeed::factory()->create([ 'last_reviewed_at' => $lastReviewed, - 'send_frequency' => 7, - 'next_review_at' => now()->subDays(15), - 'active' => true, + 'send_frequency' => 7, + 'next_review_at' => now()->subDays(15), + 'active' => true, ]); Bus::fake(); @@ -89,8 +89,8 @@ public function test_review_rss_feed_job_updates_feed_check_time_if_due(): void /** @var RssFeed $pendingFeed */ $pendingFeed = RssFeed::factory()->create([ 'last_reviewed_at' => $lastReviewed, - 'send_frequency' => 7, - 'active' => true, + 'send_frequency' => 7, + 'active' => true, ]); Bus::fake(); @@ -111,8 +111,8 @@ public function test_review_rss_feed_job_updates_creates_send_with_content_if_du /** @var RssFeed $pendingFeed */ $pendingFeed = RssFeed::factory()->create([ 'last_reviewed_at' => $lastReviewed, - 'send_frequency' => 7, - 'active' => true, + 'send_frequency' => 7, + 'active' => true, ]); $pendingFeed->templateSend->update([ 'content' => 'RSS Test {{rss_loop}}{{rss_article_title}}{{rss_article_link}}{{end_rss_loop}}', diff --git a/tests/Feature/RssFeedTest.php b/tests/Feature/RssFeedTest.php index c7ed9bc..1edebe8 100644 --- a/tests/Feature/RssFeedTest.php +++ b/tests/Feature/RssFeedTest.php @@ -34,12 +34,12 @@ public function test_feed_can_be_saved(): void $feed = RssFeed::factory()->create(); $details = [ - 'active' => '1', - 'url' => 'https://example.com/feed.xml', - 'campaign_id' => $feed->campaign->id, + 'active' => '1', + 'url' => 'https://example.com/feed.xml', + 'campaign_id' => $feed->campaign->id, 'template_send_id' => $feed->templateSend->id, - 'send_frequency' => 7, - 'target_hour' => 15, + 'send_frequency' => 7, + 'target_hour' => 15, ]; $response = $this->whileLoggedIn()->put("/campaigns/{$feed->campaign->id}/rss/{$feed->id}", $details); @@ -81,12 +81,12 @@ public function test_feed_create_request(): void $send = Send::factory()->create(['campaign_id' => $campaign->id]); $details = [ - 'active' => '1', - 'url' => 'https://example.com/feed.xml', - 'campaign_id' => $campaign->id, + 'active' => '1', + 'url' => 'https://example.com/feed.xml', + 'campaign_id' => $campaign->id, 'template_send_id' => $send->id, - 'send_frequency' => 7, - 'target_hour' => 13, + 'send_frequency' => 7, + 'target_hour' => 13, ]; $response = $this->whileLoggedIn()->followingRedirects()->post("/campaigns/{$campaign->id}/rss", $details); diff --git a/tests/Feature/SendTest.php b/tests/Feature/SendTest.php index 7528e36..a55ad28 100644 --- a/tests/Feature/SendTest.php +++ b/tests/Feature/SendTest.php @@ -69,7 +69,7 @@ public function test_send_can_be_saved(): void $send = Send::factory()->create(); $details = [ - 'name' => 'My new internal send', + 'name' => 'My new internal send', 'subject' => 'My new subject', 'content' => 'Custom content', ]; @@ -106,10 +106,10 @@ public function test_send_create_request(): void $campaign = Campaign::factory()->create(); $list = MailList::factory()->create(); $details = [ - 'name' => 'My new internal send', - 'subject' => 'My new subject', - 'content' => 'Custom content', - 'campaign_id' => $campaign->id, + 'name' => 'My new internal send', + 'subject' => 'My new subject', + 'content' => 'Custom content', + 'campaign_id' => $campaign->id, 'mail_list_id' => $list->id, ]; $response = $this->whileLoggedIn()->followingRedirects()->post('/sends', $details); diff --git a/tests/Feature/SignupTest.php b/tests/Feature/SignupTest.php index f38c66c..2ec34c6 100644 --- a/tests/Feature/SignupTest.php +++ b/tests/Feature/SignupTest.php @@ -36,9 +36,9 @@ public function test_user_can_sign_up_to_to_list(): void ]); $resp->assertRedirect("/signup/{$list->slug}/thanks"); $this->assertDatabaseHas('signups', [ - 'email' => 'tester@example.com', + 'email' => 'tester@example.com', 'mail_list_id' => $list->id, - 'attempts' => 1, + 'attempts' => 1, ]); $signup = Signup::query()->where('email', '=', 'tester@example.com')->first(); @@ -93,7 +93,7 @@ public function test_confirming_a_signup(): void ]); $contact = Contact::query()->where('email', '=', 'tester@example.com')->first(); $this->assertDatabaseHas('contact_mail_list', [ - 'contact_id' => $contact->id, + 'contact_id' => $contact->id, 'mail_list_id' => $list->id, ]); $this->assertDatabaseMissing('signups', [ @@ -165,7 +165,7 @@ public function test_signup_with_hcaptcha_configured_makes_verification_call(): ]); $this->post("/signup/{$list->slug}", [ - 'email' => 'test@example.com', + 'email' => 'test@example.com', 'h-captcha-response' => 'def456', ]); diff --git a/tests/Feature/UserTest.php b/tests/Feature/UserTest.php index 7eff35b..7651a58 100644 --- a/tests/Feature/UserTest.php +++ b/tests/Feature/UserTest.php @@ -35,7 +35,7 @@ public function test_users_index_can_be_searched(): void $response = $this->whileLoggedIn()->get('/users'); $response->assertDontSee($users[105]->email); - $response = $this->get('/users?search=' . $users[105]->email); + $response = $this->get('/users?search='.$users[105]->email); $response->assertSee("/users/{$users[105]->id}"); $response->assertSee("value=\"{$users[105]->email}\"", false); } @@ -56,14 +56,14 @@ public function test_user_can_be_saved(): void $response = $this->whileLoggedIn()->followingRedirects()->put("/users/{$user->id}", [ 'email' => 'updated@example.com', - 'name' => 'Barry Donald', + 'name' => 'Barry Donald', ]); $response->assertSee('updated@example.com'); $response->assertSee('User updated!'); $this->assertDatabaseHas('users', [ - 'id' => $user->id, + 'id' => $user->id, 'email' => 'updated@example.com', - 'name' => 'Barry Donald', + 'name' => 'Barry Donald', ]); } @@ -90,16 +90,16 @@ public function test_new_user_view(): void public function test_user_create_request(): void { $response = $this->whileLoggedIn()->followingRedirects()->post('/users', [ - 'email' => 'barry@example.com', + 'email' => 'barry@example.com', 'password' => 'password1234', - 'name' => 'Barry Donald', + 'name' => 'Barry Donald', ]); $response->assertSee('barry@example.com'); $response->assertSee('User created'); $this->assertDatabaseHas('users', [ 'email' => 'barry@example.com', - 'name' => 'Barry Donald', + 'name' => 'Barry Donald', ]); } } diff --git a/tests/Unit/MailContentParserTest.php b/tests/Unit/MailContentParserTest.php index 5791549..b871d5e 100644 --- a/tests/Unit/MailContentParserTest.php +++ b/tests/Unit/MailContentParserTest.php @@ -29,7 +29,7 @@ public function test_parse_for_send_adds_unsub_link_at_end_if_no_tag(): void $parser = new MailContentParser($content); $output = $parser->parseForSend($record); - $this->assertEquals("ABC DEF\n\n" . "Unsubscribe: http://localhost/unsubscribe/{$record->key}", $output); + $this->assertEquals("ABC DEF\n\n"."Unsubscribe: http://localhost/unsubscribe/{$record->key}", $output); } public function test_parse_for_rss_repeats_block_for_each_article(): void From 225d61d61a64127feb831862a64334c44c8244f5 Mon Sep 17 00:00:00 2001 From: Shift Date: Wed, 15 May 2024 19:25:45 +0000 Subject: [PATCH 02/17] Remove default `app` files --- app/Http/Middleware/Authenticate.php | 17 --------- app/Http/Middleware/EncryptCookies.php | 17 --------- .../PreventRequestsDuringMaintenance.php | 17 --------- .../Middleware/RedirectIfAuthenticated.php | 28 -------------- app/Http/Middleware/TrimStrings.php | 18 --------- app/Http/Middleware/TrustProxies.php | 23 ----------- app/Http/Middleware/ValidateSignature.php | 22 ----------- app/Http/Middleware/VerifyCsrfToken.php | 17 --------- app/Providers/AuthServiceProvider.php | 25 ------------ app/Providers/BroadcastServiceProvider.php | 19 ---------- app/Providers/EventServiceProvider.php | 38 ------------------- 11 files changed, 241 deletions(-) delete mode 100644 app/Http/Middleware/Authenticate.php delete mode 100644 app/Http/Middleware/EncryptCookies.php delete mode 100644 app/Http/Middleware/PreventRequestsDuringMaintenance.php delete mode 100644 app/Http/Middleware/RedirectIfAuthenticated.php delete mode 100644 app/Http/Middleware/TrimStrings.php delete mode 100644 app/Http/Middleware/TrustProxies.php delete mode 100644 app/Http/Middleware/ValidateSignature.php delete mode 100644 app/Http/Middleware/VerifyCsrfToken.php delete mode 100644 app/Providers/AuthServiceProvider.php delete mode 100644 app/Providers/BroadcastServiceProvider.php delete mode 100644 app/Providers/EventServiceProvider.php diff --git a/app/Http/Middleware/Authenticate.php b/app/Http/Middleware/Authenticate.php deleted file mode 100644 index d4ef644..0000000 --- a/app/Http/Middleware/Authenticate.php +++ /dev/null @@ -1,17 +0,0 @@ -expectsJson() ? null : route('login'); - } -} diff --git a/app/Http/Middleware/EncryptCookies.php b/app/Http/Middleware/EncryptCookies.php deleted file mode 100644 index 867695b..0000000 --- a/app/Http/Middleware/EncryptCookies.php +++ /dev/null @@ -1,17 +0,0 @@ - - */ - protected $except = [ - // - ]; -} diff --git a/app/Http/Middleware/PreventRequestsDuringMaintenance.php b/app/Http/Middleware/PreventRequestsDuringMaintenance.php deleted file mode 100644 index 74cbd9a..0000000 --- a/app/Http/Middleware/PreventRequestsDuringMaintenance.php +++ /dev/null @@ -1,17 +0,0 @@ - - */ - protected $except = [ - // - ]; -} diff --git a/app/Http/Middleware/RedirectIfAuthenticated.php b/app/Http/Middleware/RedirectIfAuthenticated.php deleted file mode 100644 index e9eaad1..0000000 --- a/app/Http/Middleware/RedirectIfAuthenticated.php +++ /dev/null @@ -1,28 +0,0 @@ -check()) { - return redirect(RouteServiceProvider::HOME); - } - } - - return $next($request); - } -} diff --git a/app/Http/Middleware/TrimStrings.php b/app/Http/Middleware/TrimStrings.php deleted file mode 100644 index e763dfb..0000000 --- a/app/Http/Middleware/TrimStrings.php +++ /dev/null @@ -1,18 +0,0 @@ - - */ - protected $except = [ - 'password', - 'password_confirmation', - ]; -} diff --git a/app/Http/Middleware/TrustProxies.php b/app/Http/Middleware/TrustProxies.php deleted file mode 100644 index e3cbc05..0000000 --- a/app/Http/Middleware/TrustProxies.php +++ /dev/null @@ -1,23 +0,0 @@ -|string|null - */ - protected $proxies; - - /** - * The headers that should be used to detect proxies. - * - * @var int - */ - protected $headers = Request::HEADER_X_FORWARDED_FOR | Request::HEADER_X_FORWARDED_HOST | Request::HEADER_X_FORWARDED_PORT | Request::HEADER_X_FORWARDED_PROTO | Request::HEADER_X_FORWARDED_AWS_ELB; -} diff --git a/app/Http/Middleware/ValidateSignature.php b/app/Http/Middleware/ValidateSignature.php deleted file mode 100644 index 093bf64..0000000 --- a/app/Http/Middleware/ValidateSignature.php +++ /dev/null @@ -1,22 +0,0 @@ - - */ - protected $except = [ - // 'fbclid', - // 'utm_campaign', - // 'utm_content', - // 'utm_medium', - // 'utm_source', - // 'utm_term', - ]; -} diff --git a/app/Http/Middleware/VerifyCsrfToken.php b/app/Http/Middleware/VerifyCsrfToken.php deleted file mode 100644 index 9e86521..0000000 --- a/app/Http/Middleware/VerifyCsrfToken.php +++ /dev/null @@ -1,17 +0,0 @@ - - */ - protected $except = [ - // - ]; -} diff --git a/app/Providers/AuthServiceProvider.php b/app/Providers/AuthServiceProvider.php deleted file mode 100644 index f4607be..0000000 --- a/app/Providers/AuthServiceProvider.php +++ /dev/null @@ -1,25 +0,0 @@ - - */ - protected $policies = [ - // 'App\Models\Model' => 'App\Policies\ModelPolicy', - ]; - - /** - * Register any authentication / authorization services. - */ - public function boot(): void - { - // - } -} diff --git a/app/Providers/BroadcastServiceProvider.php b/app/Providers/BroadcastServiceProvider.php deleted file mode 100644 index 2be04f5..0000000 --- a/app/Providers/BroadcastServiceProvider.php +++ /dev/null @@ -1,19 +0,0 @@ -> - */ - protected $listen = [ - Registered::class => [ - SendEmailVerificationNotification::class, - ], - ]; - - /** - * Register any events for your application. - */ - public function boot(): void - { - // - } - - /** - * Determine if events and listeners should be automatically discovered. - */ - public function shouldDiscoverEvents(): bool - { - return false; - } -} From 9aa8b05d981247984c32e4a2a7a305e904b7488f Mon Sep 17 00:00:00 2001 From: Shift Date: Wed, 15 May 2024 19:25:46 +0000 Subject: [PATCH 03/17] Shift core files --- app/Http/Kernel.php | 1 + artisan | 50 ++++++--------------------------------------- public/index.php | 48 +++++-------------------------------------- 3 files changed, 12 insertions(+), 87 deletions(-) diff --git a/app/Http/Kernel.php b/app/Http/Kernel.php index 21d42a5..83e1ed9 100644 --- a/app/Http/Kernel.php +++ b/app/Http/Kernel.php @@ -59,6 +59,7 @@ class Kernel extends HttpKernel 'can' => \Illuminate\Auth\Middleware\Authorize::class, 'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class, 'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class, + 'precognitive' => \Illuminate\Foundation\Http\Middleware\HandlePrecognitiveRequests::class, 'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class, 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class, 'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class, diff --git a/artisan b/artisan index 5c23e2e..8e04b42 100755 --- a/artisan +++ b/artisan @@ -1,53 +1,15 @@ #!/usr/bin/env php make(Illuminate\Contracts\Console\Kernel::class); - -$status = $kernel->handle( - $input = new Symfony\Component\Console\Input\ArgvInput, - new Symfony\Component\Console\Output\ConsoleOutput -); - -/* -|-------------------------------------------------------------------------- -| Shutdown The Application -|-------------------------------------------------------------------------- -| -| Once Artisan has finished running, we will fire off the shutdown events -| so that any final work may be done by the application before we shut -| down the process. This is the last thing to happen to the request. -| -*/ - -$kernel->terminate($input, $status); +// Bootstrap Laravel and handle the command... +$status = (require_once __DIR__.'/bootstrap/app.php') + ->handleCommand(new ArgvInput); exit($status); diff --git a/public/index.php b/public/index.php index 1d69f3a..947d989 100644 --- a/public/index.php +++ b/public/index.php @@ -1,55 +1,17 @@ make(Kernel::class); - -$response = $kernel->handle( - $request = Request::capture() -)->send(); - -$kernel->terminate($request, $response); +// Bootstrap Laravel and handle the request... +(require_once __DIR__.'/../bootstrap/app.php') + ->handleRequest(Request::capture()); From fa02c21f556879c875b9e337b6190f9c686ee91c Mon Sep 17 00:00:00 2001 From: Shift Date: Wed, 15 May 2024 19:25:54 +0000 Subject: [PATCH 04/17] Streamline config files --- config/.gitkeep | 0 config/app.php | 165 --------------------------------- config/auth.php | 108 --------------------- config/broadcasting.php | 70 -------------- config/cache.php | 110 ---------------------- config/cors.php | 34 ------- config/database.php | 147 +---------------------------- config/filesystems.php | 76 --------------- config/hashing.php | 52 ----------- config/logging.php | 131 -------------------------- config/mail.php | 110 ---------------------- config/queue.php | 93 ------------------- config/services.php | 22 ----- config/session.php | 201 ---------------------------------------- config/view.php | 36 ------- 15 files changed, 3 insertions(+), 1352 deletions(-) create mode 100644 config/.gitkeep delete mode 100644 config/broadcasting.php delete mode 100644 config/cache.php delete mode 100644 config/cors.php delete mode 100644 config/filesystems.php delete mode 100644 config/hashing.php delete mode 100644 config/logging.php delete mode 100644 config/queue.php delete mode 100644 config/session.php delete mode 100644 config/view.php diff --git a/config/.gitkeep b/config/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/config/app.php b/config/app.php index a25f3f3..1db2d42 100644 --- a/config/app.php +++ b/config/app.php @@ -5,160 +5,10 @@ return [ - /* - |-------------------------------------------------------------------------- - | Application Name - |-------------------------------------------------------------------------- - | - | This value is the name of your application. This value is used when the - | framework needs to place the application's name in a notification or - | any other location as required by the application or its packages. - | - */ - - 'name' => env('APP_NAME', 'Laravel'), - 'company_name' => env('APP_COMPANY_NAME', 'MailBag'), - /* - |-------------------------------------------------------------------------- - | Application Environment - |-------------------------------------------------------------------------- - | - | This value determines the "environment" your application is currently - | running in. This may determine how you prefer to configure various - | services the application utilizes. Set this in your ".env" file. - | - */ - - 'env' => env('APP_ENV', 'production'), - - /* - |-------------------------------------------------------------------------- - | Application Debug Mode - |-------------------------------------------------------------------------- - | - | When your application is in debug mode, detailed error messages with - | stack traces will be shown on every error that occurs within your - | application. If disabled, a simple generic error page is shown. - | - */ - - 'debug' => (bool) env('APP_DEBUG', false), - - /* - |-------------------------------------------------------------------------- - | Application URL - |-------------------------------------------------------------------------- - | - | This URL is used by the console to properly generate URLs when using - | the Artisan command line tool. You should set this to the root of - | your application so that it is used when running Artisan tasks. - | - */ - - 'url' => env('APP_URL', 'http://localhost'), - - 'asset_url' => env('ASSET_URL', null), - 'home_redirect_url' => env('HOME_REDIRECT_URL', null), - /* - |-------------------------------------------------------------------------- - | Application Timezone - |-------------------------------------------------------------------------- - | - | Here you may specify the default timezone for your application, which - | will be used by the PHP date and date-time functions. We have gone - | ahead and set this to a sensible default for you out of the box. - | - */ - - 'timezone' => 'UTC', - - /* - |-------------------------------------------------------------------------- - | Application Locale Configuration - |-------------------------------------------------------------------------- - | - | The application locale determines the default locale that will be used - | by the translation service provider. You are free to set this value - | to any of the locales which will be supported by the application. - | - */ - - 'locale' => 'en', - - /* - |-------------------------------------------------------------------------- - | Application Fallback Locale - |-------------------------------------------------------------------------- - | - | The fallback locale determines the locale to use when the current one - | is not available. You may change the value to correspond to any of - | the language folders that are provided through your application. - | - */ - - 'fallback_locale' => 'en', - - /* - |-------------------------------------------------------------------------- - | Faker Locale - |-------------------------------------------------------------------------- - | - | This locale will be used by the Faker PHP library when generating fake - | data for your database seeds. For example, this will be used to get - | localized telephone numbers, street address information and more. - | - */ - - 'faker_locale' => 'en_US', - - /* - |-------------------------------------------------------------------------- - | Encryption Key - |-------------------------------------------------------------------------- - | - | This key is used by the Illuminate encrypter service and should be set - | to a random, 32 character string, otherwise these encrypted strings - | will not be safe. Please do this before deploying an application! - | - */ - - 'key' => env('APP_KEY'), - - 'cipher' => 'AES-256-CBC', - - /* - |-------------------------------------------------------------------------- - | Maintenance Mode Driver - |-------------------------------------------------------------------------- - | - | These configuration options determine the driver used to determine and - | manage Laravel's "maintenance mode" status. The "cache" driver will - | allow maintenance mode to be controlled across multiple machines. - | - | Supported drivers: "file", "cache" - | - */ - - 'maintenance' => [ - 'driver' => 'file', - // 'store' => 'redis', - ], - - /* - |-------------------------------------------------------------------------- - | Autoloaded Service Providers - |-------------------------------------------------------------------------- - | - | The service providers listed here will be automatically loaded on the - | request to your application. Feel free to add your own services to - | this array to grant expanded functionality to your applications. - | - */ - 'providers' => ServiceProvider::defaultProviders()->merge([ /* * Package Service Providers... @@ -174,19 +24,4 @@ App\Providers\RouteServiceProvider::class, ])->toArray(), - /* - |-------------------------------------------------------------------------- - | Class Aliases - |-------------------------------------------------------------------------- - | - | This array of class aliases will be registered when this application - | is started. However, feel free to register as many as you wish as - | the aliases are "lazy" loaded so they don't hinder performance. - | - */ - - 'aliases' => Facade::defaultAliases()->merge([ - // ... - ])->toArray(), - ]; diff --git a/config/auth.php b/config/auth.php index 7a4d5bc..1642fb2 100644 --- a/config/auth.php +++ b/config/auth.php @@ -2,45 +2,7 @@ return [ - /* - |-------------------------------------------------------------------------- - | Authentication Defaults - |-------------------------------------------------------------------------- - | - | This option controls the default authentication "guard" and password - | reset options for your application. You may change these defaults - | as required, but they're a perfect start for most applications. - | - */ - - 'defaults' => [ - 'guard' => 'web', - 'passwords' => 'users', - ], - - /* - |-------------------------------------------------------------------------- - | Authentication Guards - |-------------------------------------------------------------------------- - | - | Next, you may define every authentication guard for your application. - | Of course, a great default configuration has been defined for you - | here which uses session storage and the Eloquent user provider. - | - | All authentication drivers have a user provider. This defines how the - | users are actually retrieved out of your database or other storage - | mechanisms used by this application to persist your user's data. - | - | Supported: "session" - | - */ - 'guards' => [ - 'web' => [ - 'driver' => 'session', - 'provider' => 'users', - ], - 'api' => [ 'driver' => 'token', 'provider' => 'users', @@ -48,74 +10,4 @@ ], ], - /* - |-------------------------------------------------------------------------- - | User Providers - |-------------------------------------------------------------------------- - | - | All authentication drivers have a user provider. This defines how the - | users are actually retrieved out of your database or other storage - | mechanisms used by this application to persist your user's data. - | - | If you have multiple user tables or models you may configure multiple - | sources which represent each model / table. These sources may then - | be assigned to any extra authentication guards you have defined. - | - | Supported: "database", "eloquent" - | - */ - - 'providers' => [ - 'users' => [ - 'driver' => 'eloquent', - 'model' => App\Models\User::class, - ], - - // 'users' => [ - // 'driver' => 'database', - // 'table' => 'users', - // ], - ], - - /* - |-------------------------------------------------------------------------- - | Resetting Passwords - |-------------------------------------------------------------------------- - | - | You may specify multiple password reset configurations if you have more - | than one user table or model in the application and you want to have - | separate password reset settings based on the specific user types. - | - | The expiry time is the number of minutes that each reset token will be - | considered valid. This security feature keeps tokens short-lived so - | they have less time to be guessed. You may change this as needed. - | - | The throttle setting is the number of seconds a user must wait before - | generating more password reset tokens. This prevents the user from - | quickly generating a very large amount of password reset tokens. - | - */ - - 'passwords' => [ - 'users' => [ - 'provider' => 'users', - 'table' => 'password_reset_tokens', - 'expire' => 60, - 'throttle' => 60, - ], - ], - - /* - |-------------------------------------------------------------------------- - | Password Confirmation Timeout - |-------------------------------------------------------------------------- - | - | Here you may define the amount of seconds before a password confirmation - | times out and the user is prompted to re-enter their password via the - | confirmation screen. By default, the timeout lasts for three hours. - | - */ - - 'password_timeout' => 10800, - ]; diff --git a/config/broadcasting.php b/config/broadcasting.php deleted file mode 100644 index 9e4d4aa..0000000 --- a/config/broadcasting.php +++ /dev/null @@ -1,70 +0,0 @@ - env('BROADCAST_DRIVER', 'null'), - - /* - |-------------------------------------------------------------------------- - | Broadcast Connections - |-------------------------------------------------------------------------- - | - | Here you may define all of the broadcast connections that will be used - | to broadcast events to other systems or over websockets. Samples of - | each available type of connection are provided inside this array. - | - */ - - 'connections' => [ - - 'pusher' => [ - 'driver' => 'pusher', - 'key' => env('PUSHER_APP_KEY'), - 'secret' => env('PUSHER_APP_SECRET'), - 'app_id' => env('PUSHER_APP_ID'), - 'options' => [ - 'host' => env('PUSHER_HOST') ?: 'api-'.env('PUSHER_APP_CLUSTER', 'mt1').'.pusher.com', - 'port' => env('PUSHER_PORT', 443), - 'scheme' => env('PUSHER_SCHEME', 'https'), - 'encrypted' => true, - 'useTLS' => env('PUSHER_SCHEME', 'https') === 'https', - ], - 'client_options' => [ - // Guzzle client options: https://docs.guzzlephp.org/en/stable/request-options.html - ], - ], - - 'ably' => [ - 'driver' => 'ably', - 'key' => env('ABLY_KEY'), - ], - - 'redis' => [ - 'driver' => 'redis', - 'connection' => 'default', - ], - - 'log' => [ - 'driver' => 'log', - ], - - 'null' => [ - 'driver' => 'null', - ], - - ], - -]; diff --git a/config/cache.php b/config/cache.php deleted file mode 100644 index 33bb295..0000000 --- a/config/cache.php +++ /dev/null @@ -1,110 +0,0 @@ - env('CACHE_DRIVER', 'file'), - - /* - |-------------------------------------------------------------------------- - | Cache Stores - |-------------------------------------------------------------------------- - | - | Here you may define all of the cache "stores" for your application as - | well as their drivers. You may even define multiple stores for the - | same cache driver to group types of items stored in your caches. - | - | Supported drivers: "apc", "array", "database", "file", - | "memcached", "redis", "dynamodb", "octane", "null" - | - */ - - 'stores' => [ - - 'apc' => [ - 'driver' => 'apc', - ], - - 'array' => [ - 'driver' => 'array', - 'serialize' => false, - ], - - 'database' => [ - 'driver' => 'database', - 'table' => 'cache', - 'connection' => null, - 'lock_connection' => null, - ], - - 'file' => [ - 'driver' => 'file', - 'path' => storage_path('framework/cache/data'), - ], - - 'memcached' => [ - 'driver' => 'memcached', - 'persistent_id' => env('MEMCACHED_PERSISTENT_ID'), - 'sasl' => [ - env('MEMCACHED_USERNAME'), - env('MEMCACHED_PASSWORD'), - ], - 'options' => [ - // Memcached::OPT_CONNECT_TIMEOUT => 2000, - ], - 'servers' => [ - [ - 'host' => env('MEMCACHED_HOST', '127.0.0.1'), - 'port' => env('MEMCACHED_PORT', 11211), - 'weight' => 100, - ], - ], - ], - - 'redis' => [ - 'driver' => 'redis', - 'connection' => 'cache', - 'lock_connection' => 'default', - ], - - 'dynamodb' => [ - 'driver' => 'dynamodb', - 'key' => env('AWS_ACCESS_KEY_ID'), - 'secret' => env('AWS_SECRET_ACCESS_KEY'), - 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), - 'table' => env('DYNAMODB_CACHE_TABLE', 'cache'), - 'endpoint' => env('DYNAMODB_ENDPOINT'), - ], - - 'octane' => [ - 'driver' => 'octane', - ], - - ], - - /* - |-------------------------------------------------------------------------- - | Cache Key Prefix - |-------------------------------------------------------------------------- - | - | When utilizing the APC, database, memcached, Redis, or DynamoDB cache - | stores there might be other applications using the same cache. For - | that reason, you may prefix every cache key to avoid collisions. - | - */ - - 'prefix' => env('CACHE_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_cache_'), - -]; diff --git a/config/cors.php b/config/cors.php deleted file mode 100644 index 8a39e6d..0000000 --- a/config/cors.php +++ /dev/null @@ -1,34 +0,0 @@ - ['api/*', 'sanctum/csrf-cookie'], - - 'allowed_methods' => ['*'], - - 'allowed_origins' => ['*'], - - 'allowed_origins_patterns' => [], - - 'allowed_headers' => ['*'], - - 'exposed_headers' => [], - - 'max_age' => 0, - - 'supports_credentials' => false, - -]; diff --git a/config/database.php b/config/database.php index 828f890..1fc8066 100644 --- a/config/database.php +++ b/config/database.php @@ -1,151 +1,10 @@ env('DB_CONNECTION', 'sqlite'), - - /* - |-------------------------------------------------------------------------- - | Database Connections - |-------------------------------------------------------------------------- - | - | Here are each of the database connections setup for your application. - | Of course, examples of configuring each database platform that is - | supported by Laravel is shown below to make development simple. - | - | - | All database work in Laravel is done through the PHP PDO facilities - | so make sure you have the driver for your particular database of - | choice installed on your machine before you begin development. - | - */ - - 'connections' => [ - - 'sqlite' => [ - 'driver' => 'sqlite', - 'url' => env('DATABASE_URL'), - 'database' => env('DB_DATABASE', storage_path('database/database.sqlite')), - 'prefix' => '', - 'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true), - ], - - 'mysql' => [ - 'driver' => 'mysql', - 'url' => env('DATABASE_URL'), - 'host' => env('DB_HOST', '127.0.0.1'), - 'port' => env('DB_PORT', '3306'), - 'database' => env('DB_DATABASE', 'forge'), - 'username' => env('DB_USERNAME', 'forge'), - 'password' => env('DB_PASSWORD', ''), - 'unix_socket' => env('DB_SOCKET', ''), - 'charset' => 'utf8mb4', - 'collation' => 'utf8mb4_unicode_ci', - 'prefix' => '', - 'prefix_indexes' => true, - 'strict' => true, - 'engine' => null, - 'options' => extension_loaded('pdo_mysql') ? array_filter([ - PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'), - ]) : [], - ], - - 'pgsql' => [ - 'driver' => 'pgsql', - 'url' => env('DATABASE_URL'), - 'host' => env('DB_HOST', '127.0.0.1'), - 'port' => env('DB_PORT', '5432'), - 'database' => env('DB_DATABASE', 'forge'), - 'username' => env('DB_USERNAME', 'forge'), - 'password' => env('DB_PASSWORD', ''), - 'charset' => 'utf8', - 'prefix' => '', - 'prefix_indexes' => true, - 'search_path' => 'public', - 'sslmode' => 'prefer', - ], - - 'sqlsrv' => [ - 'driver' => 'sqlsrv', - 'url' => env('DATABASE_URL'), - 'host' => env('DB_HOST', 'localhost'), - 'port' => env('DB_PORT', '1433'), - 'database' => env('DB_DATABASE', 'forge'), - 'username' => env('DB_USERNAME', 'forge'), - 'password' => env('DB_PASSWORD', ''), - 'charset' => 'utf8', - 'prefix' => '', - 'prefix_indexes' => true, - // 'encrypt' => env('DB_ENCRYPT', 'yes'), - // 'trust_server_certificate' => env('DB_TRUST_SERVER_CERTIFICATE', 'false'), - ], - - ], - - /* - |-------------------------------------------------------------------------- - | Migration Repository Table - |-------------------------------------------------------------------------- - | - | This table keeps track of all the migrations that have already run for - | your application. Using this information, we can determine which of - | the migrations on disk haven't actually been run in the database. - | - */ - - 'migrations' => 'migrations', - - /* - |-------------------------------------------------------------------------- - | Redis Databases - |-------------------------------------------------------------------------- - | - | Redis is an open source, fast, and advanced key-value store that also - | provides a richer body of commands than a typical key-value system - | such as APC or Memcached. Laravel makes it easy to dig right in. - | - */ - - 'redis' => [ - - 'client' => env('REDIS_CLIENT', 'phpredis'), - - 'options' => [ - 'cluster' => env('REDIS_CLUSTER', 'redis'), - 'prefix' => env('REDIS_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_database_'), - ], - - 'default' => [ - 'url' => env('REDIS_URL'), - 'host' => env('REDIS_HOST', '127.0.0.1'), - 'username' => env('REDIS_USERNAME'), - 'password' => env('REDIS_PASSWORD'), - 'port' => env('REDIS_PORT', '6379'), - 'database' => env('REDIS_DB', '0'), - ], - - 'cache' => [ - 'url' => env('REDIS_URL'), - 'host' => env('REDIS_HOST', '127.0.0.1'), - 'username' => env('REDIS_USERNAME'), - 'password' => env('REDIS_PASSWORD'), - 'port' => env('REDIS_PORT', '6379'), - 'database' => env('REDIS_CACHE_DB', '1'), - ], - + 'migrations' => [ + 'table' => 'migrations', + 'update_date_on_publish' => false, // disable to preserve original behavior for existing applications ], ]; diff --git a/config/filesystems.php b/config/filesystems.php deleted file mode 100644 index e9d9dbd..0000000 --- a/config/filesystems.php +++ /dev/null @@ -1,76 +0,0 @@ - env('FILESYSTEM_DISK', 'local'), - - /* - |-------------------------------------------------------------------------- - | Filesystem Disks - |-------------------------------------------------------------------------- - | - | Here you may configure as many filesystem "disks" as you wish, and you - | may even configure multiple disks of the same driver. Defaults have - | been set up for each driver as an example of the required values. - | - | Supported Drivers: "local", "ftp", "sftp", "s3" - | - */ - - 'disks' => [ - - 'local' => [ - 'driver' => 'local', - 'root' => storage_path('app'), - 'throw' => false, - ], - - 'public' => [ - 'driver' => 'local', - 'root' => storage_path('app/public'), - 'url' => env('APP_URL').'/storage', - 'visibility' => 'public', - 'throw' => false, - ], - - 's3' => [ - 'driver' => 's3', - 'key' => env('AWS_ACCESS_KEY_ID'), - 'secret' => env('AWS_SECRET_ACCESS_KEY'), - 'region' => env('AWS_DEFAULT_REGION'), - 'bucket' => env('AWS_BUCKET'), - 'url' => env('AWS_URL'), - 'endpoint' => env('AWS_ENDPOINT'), - 'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false), - 'throw' => false, - ], - - ], - - /* - |-------------------------------------------------------------------------- - | Symbolic Links - |-------------------------------------------------------------------------- - | - | Here you may configure the symbolic links that will be created when the - | `storage:link` Artisan command is executed. The array keys should be - | the locations of the links and the values should be their targets. - | - */ - - 'links' => [ - public_path('storage') => storage_path('app/public'), - ], - -]; diff --git a/config/hashing.php b/config/hashing.php deleted file mode 100644 index bcd3be4..0000000 --- a/config/hashing.php +++ /dev/null @@ -1,52 +0,0 @@ - 'bcrypt', - - /* - |-------------------------------------------------------------------------- - | Bcrypt Options - |-------------------------------------------------------------------------- - | - | Here you may specify the configuration options that should be used when - | passwords are hashed using the Bcrypt algorithm. This will allow you - | to control the amount of time it takes to hash the given password. - | - */ - - 'bcrypt' => [ - 'rounds' => env('BCRYPT_ROUNDS', 10), - ], - - /* - |-------------------------------------------------------------------------- - | Argon Options - |-------------------------------------------------------------------------- - | - | Here you may specify the configuration options that should be used when - | passwords are hashed using the Argon algorithm. These will allow you - | to control the amount of time it takes to hash the given password. - | - */ - - 'argon' => [ - 'memory' => 65536, - 'threads' => 1, - 'time' => 4, - ], - -]; diff --git a/config/logging.php b/config/logging.php deleted file mode 100644 index c44d276..0000000 --- a/config/logging.php +++ /dev/null @@ -1,131 +0,0 @@ - env('LOG_CHANNEL', 'stack'), - - /* - |-------------------------------------------------------------------------- - | Deprecations Log Channel - |-------------------------------------------------------------------------- - | - | This option controls the log channel that should be used to log warnings - | regarding deprecated PHP and library features. This allows you to get - | your application ready for upcoming major versions of dependencies. - | - */ - - 'deprecations' => [ - 'channel' => env('LOG_DEPRECATIONS_CHANNEL', 'null'), - 'trace' => false, - ], - - /* - |-------------------------------------------------------------------------- - | Log Channels - |-------------------------------------------------------------------------- - | - | Here you may configure the log channels for your application. Out of - | the box, Laravel uses the Monolog PHP logging library. This gives - | you a variety of powerful log handlers / formatters to utilize. - | - | Available Drivers: "single", "daily", "slack", "syslog", - | "errorlog", "monolog", - | "custom", "stack" - | - */ - - 'channels' => [ - 'stack' => [ - 'driver' => 'stack', - 'channels' => ['single'], - 'ignore_exceptions' => false, - ], - - 'single' => [ - 'driver' => 'single', - 'path' => storage_path('logs/laravel.log'), - 'level' => env('LOG_LEVEL', 'debug'), - 'replace_placeholders' => true, - ], - - 'daily' => [ - 'driver' => 'daily', - 'path' => storage_path('logs/laravel.log'), - 'level' => env('LOG_LEVEL', 'debug'), - 'days' => 14, - 'replace_placeholders' => true, - ], - - 'slack' => [ - 'driver' => 'slack', - 'url' => env('LOG_SLACK_WEBHOOK_URL'), - 'username' => 'Laravel Log', - 'emoji' => ':boom:', - 'level' => env('LOG_LEVEL', 'critical'), - 'replace_placeholders' => true, - ], - - 'papertrail' => [ - 'driver' => 'monolog', - 'level' => env('LOG_LEVEL', 'debug'), - 'handler' => env('LOG_PAPERTRAIL_HANDLER', SyslogUdpHandler::class), - 'handler_with' => [ - 'host' => env('PAPERTRAIL_URL'), - 'port' => env('PAPERTRAIL_PORT'), - 'connectionString' => 'tls://'.env('PAPERTRAIL_URL').':'.env('PAPERTRAIL_PORT'), - ], - 'processors' => [PsrLogMessageProcessor::class], - ], - - 'stderr' => [ - 'driver' => 'monolog', - 'level' => env('LOG_LEVEL', 'debug'), - 'handler' => StreamHandler::class, - 'formatter' => env('LOG_STDERR_FORMATTER'), - 'with' => [ - 'stream' => 'php://stderr', - ], - 'processors' => [PsrLogMessageProcessor::class], - ], - - 'syslog' => [ - 'driver' => 'syslog', - 'level' => env('LOG_LEVEL', 'debug'), - 'facility' => LOG_USER, - 'replace_placeholders' => true, - ], - - 'errorlog' => [ - 'driver' => 'errorlog', - 'level' => env('LOG_LEVEL', 'debug'), - 'replace_placeholders' => true, - ], - - 'null' => [ - 'driver' => 'monolog', - 'handler' => NullHandler::class, - ], - - 'emergency' => [ - 'path' => storage_path('logs/laravel.log'), - ], - ], - -]; diff --git a/config/mail.php b/config/mail.php index 542d98c..77815a6 100644 --- a/config/mail.php +++ b/config/mail.php @@ -2,123 +2,13 @@ return [ - /* - |-------------------------------------------------------------------------- - | Default Mailer - |-------------------------------------------------------------------------- - | - | This option controls the default mailer that is used to send any email - | messages sent by your application. Alternative mailers may be setup - | and used as needed; however, this mailer will be used by default. - | - */ - - 'default' => env('MAIL_MAILER', 'smtp'), - - /* - |-------------------------------------------------------------------------- - | Mailer Configurations - |-------------------------------------------------------------------------- - | - | Here you may configure all of the mailers used by your application plus - | their respective settings. Several examples have been configured for - | you and you are free to add your own as your application requires. - | - | Laravel supports a variety of mail "transport" drivers to be used while - | sending an e-mail. You will specify which one you are using for your - | mailers below. You are free to add additional mailers as required. - | - | Supported: "smtp", "sendmail", "mailgun", "ses", "ses-v2", - | "postmark", "log", "array", "failover" - | - */ - 'mailers' => [ - 'smtp' => [ - 'transport' => 'smtp', - 'host' => env('MAIL_HOST', 'smtp.mailgun.org'), - 'port' => env('MAIL_PORT', 587), - 'encryption' => env('MAIL_ENCRYPTION', 'tls'), - 'username' => env('MAIL_USERNAME'), - 'password' => env('MAIL_PASSWORD'), - 'timeout' => null, - 'local_domain' => env('MAIL_EHLO_DOMAIN'), - ], - - 'ses' => [ - 'transport' => 'ses', - ], - 'mailgun' => [ 'transport' => 'mailgun', // 'client' => [ // 'timeout' => 5, // ], ], - - 'postmark' => [ - 'transport' => 'postmark', - // 'client' => [ - // 'timeout' => 5, - // ], - ], - - 'sendmail' => [ - 'transport' => 'sendmail', - 'path' => env('MAIL_SENDMAIL_PATH', '/usr/sbin/sendmail -bs -i'), - ], - - 'log' => [ - 'transport' => 'log', - 'channel' => env('MAIL_LOG_CHANNEL'), - ], - - 'array' => [ - 'transport' => 'array', - ], - - 'failover' => [ - 'transport' => 'failover', - 'mailers' => [ - 'smtp', - 'log', - ], - ], - ], - - /* - |-------------------------------------------------------------------------- - | Global "From" Address - |-------------------------------------------------------------------------- - | - | You may wish for all e-mails sent by your application to be sent from - | the same address. Here, you may specify a name and address that is - | used globally for all e-mails that are sent by your application. - | - */ - - 'from' => [ - 'address' => env('MAIL_FROM_ADDRESS', 'hello@example.com'), - 'name' => env('MAIL_FROM_NAME', 'Example'), - ], - - /* - |-------------------------------------------------------------------------- - | Markdown Mail Settings - |-------------------------------------------------------------------------- - | - | If you are using Markdown based email rendering, you may configure your - | theme and component paths here, allowing you to customize the design - | of the emails. Or, you may simply stick with the Laravel defaults! - | - */ - - 'markdown' => [ - 'theme' => 'default', - - 'paths' => [ - resource_path('views/vendor/mail'), - ], ], ]; diff --git a/config/queue.php b/config/queue.php deleted file mode 100644 index 25ea5a8..0000000 --- a/config/queue.php +++ /dev/null @@ -1,93 +0,0 @@ - env('QUEUE_CONNECTION', 'sync'), - - /* - |-------------------------------------------------------------------------- - | Queue Connections - |-------------------------------------------------------------------------- - | - | Here you may configure the connection information for each server that - | is used by your application. A default configuration has been added - | for each back-end shipped with Laravel. You are free to add more. - | - | Drivers: "sync", "database", "beanstalkd", "sqs", "redis", "null" - | - */ - - 'connections' => [ - - 'sync' => [ - 'driver' => 'sync', - ], - - 'database' => [ - 'driver' => 'database', - 'table' => 'jobs', - 'queue' => 'default', - 'retry_after' => 90, - 'after_commit' => false, - ], - - 'beanstalkd' => [ - 'driver' => 'beanstalkd', - 'host' => 'localhost', - 'queue' => 'default', - 'retry_after' => 90, - 'block_for' => 0, - 'after_commit' => false, - ], - - 'sqs' => [ - 'driver' => 'sqs', - 'key' => env('AWS_ACCESS_KEY_ID'), - 'secret' => env('AWS_SECRET_ACCESS_KEY'), - 'prefix' => env('SQS_PREFIX', 'https://sqs.us-east-1.amazonaws.com/your-account-id'), - 'queue' => env('SQS_QUEUE', 'default'), - 'suffix' => env('SQS_SUFFIX'), - 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), - 'after_commit' => false, - ], - - 'redis' => [ - 'driver' => 'redis', - 'connection' => 'default', - 'queue' => env('REDIS_QUEUE', 'default'), - 'retry_after' => 90, - 'block_for' => null, - 'after_commit' => false, - ], - - ], - - /* - |-------------------------------------------------------------------------- - | Failed Queue Jobs - |-------------------------------------------------------------------------- - | - | These options configure the behavior of failed queue job logging so you - | can control which database and table are used to store the jobs that - | have failed. You may change them to any database / table you wish. - | - */ - - 'failed' => [ - 'driver' => env('QUEUE_FAILED_DRIVER', 'database-uuids'), - 'database' => env('DB_CONNECTION', 'mysql'), - 'table' => 'failed_jobs', - ], - -]; diff --git a/config/services.php b/config/services.php index 82202e2..d669590 100644 --- a/config/services.php +++ b/config/services.php @@ -8,18 +8,6 @@ 'secretkey' => env('HCAPTCHA_SECRETKEY', null), ], - /* - |-------------------------------------------------------------------------- - | Third Party Services - |-------------------------------------------------------------------------- - | - | This file is for storing the credentials for third party services such - | as Mailgun, Postmark, AWS and more. This file provides the de facto - | location for this type of information, allowing packages to have - | a conventional file to locate the various service credentials. - | - */ - 'mailgun' => [ 'domain' => env('MAILGUN_DOMAIN'), 'secret' => env('MAILGUN_SECRET'), @@ -27,14 +15,4 @@ 'scheme' => 'https', ], - 'postmark' => [ - 'token' => env('POSTMARK_TOKEN'), - ], - - 'ses' => [ - 'key' => env('AWS_ACCESS_KEY_ID'), - 'secret' => env('AWS_SECRET_ACCESS_KEY'), - 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), - ], - ]; diff --git a/config/session.php b/config/session.php deleted file mode 100644 index 8fed97c..0000000 --- a/config/session.php +++ /dev/null @@ -1,201 +0,0 @@ - env('SESSION_DRIVER', 'file'), - - /* - |-------------------------------------------------------------------------- - | Session Lifetime - |-------------------------------------------------------------------------- - | - | Here you may specify the number of minutes that you wish the session - | to be allowed to remain idle before it expires. If you want them - | to immediately expire on the browser closing, set that option. - | - */ - - 'lifetime' => env('SESSION_LIFETIME', 120), - - 'expire_on_close' => false, - - /* - |-------------------------------------------------------------------------- - | Session Encryption - |-------------------------------------------------------------------------- - | - | This option allows you to easily specify that all of your session data - | should be encrypted before it is stored. All encryption will be run - | automatically by Laravel and you can use the Session like normal. - | - */ - - 'encrypt' => false, - - /* - |-------------------------------------------------------------------------- - | Session File Location - |-------------------------------------------------------------------------- - | - | When using the native session driver, we need a location where session - | files may be stored. A default has been set for you but a different - | location may be specified. This is only needed for file sessions. - | - */ - - 'files' => storage_path('framework/sessions'), - - /* - |-------------------------------------------------------------------------- - | Session Database Connection - |-------------------------------------------------------------------------- - | - | When using the "database" or "redis" session drivers, you may specify a - | connection that should be used to manage these sessions. This should - | correspond to a connection in your database configuration options. - | - */ - - 'connection' => env('SESSION_CONNECTION'), - - /* - |-------------------------------------------------------------------------- - | Session Database Table - |-------------------------------------------------------------------------- - | - | When using the "database" session driver, you may specify the table we - | should use to manage the sessions. Of course, a sensible default is - | provided for you; however, you are free to change this as needed. - | - */ - - 'table' => 'sessions', - - /* - |-------------------------------------------------------------------------- - | Session Cache Store - |-------------------------------------------------------------------------- - | - | While using one of the framework's cache driven session backends you may - | list a cache store that should be used for these sessions. This value - | must match with one of the application's configured cache "stores". - | - | Affects: "apc", "dynamodb", "memcached", "redis" - | - */ - - 'store' => env('SESSION_STORE'), - - /* - |-------------------------------------------------------------------------- - | Session Sweeping Lottery - |-------------------------------------------------------------------------- - | - | Some session drivers must manually sweep their storage location to get - | rid of old sessions from storage. Here are the chances that it will - | happen on a given request. By default, the odds are 2 out of 100. - | - */ - - 'lottery' => [2, 100], - - /* - |-------------------------------------------------------------------------- - | Session Cookie Name - |-------------------------------------------------------------------------- - | - | Here you may change the name of the cookie used to identify a session - | instance by ID. The name specified here will get used every time a - | new session cookie is created by the framework for every driver. - | - */ - - 'cookie' => env( - 'SESSION_COOKIE', - Str::slug(env('APP_NAME', 'laravel'), '_').'_session' - ), - - /* - |-------------------------------------------------------------------------- - | Session Cookie Path - |-------------------------------------------------------------------------- - | - | The session cookie path determines the path for which the cookie will - | be regarded as available. Typically, this will be the root path of - | your application but you are free to change this when necessary. - | - */ - - 'path' => '/', - - /* - |-------------------------------------------------------------------------- - | Session Cookie Domain - |-------------------------------------------------------------------------- - | - | Here you may change the domain of the cookie used to identify a session - | in your application. This will determine which domains the cookie is - | available to in your application. A sensible default has been set. - | - */ - - 'domain' => env('SESSION_DOMAIN'), - - /* - |-------------------------------------------------------------------------- - | HTTPS Only Cookies - |-------------------------------------------------------------------------- - | - | By setting this option to true, session cookies will only be sent back - | to the server if the browser has a HTTPS connection. This will keep - | the cookie from being sent to you when it can't be done securely. - | - */ - - 'secure' => env('SESSION_SECURE_COOKIE'), - - /* - |-------------------------------------------------------------------------- - | HTTP Access Only - |-------------------------------------------------------------------------- - | - | Setting this value to true will prevent JavaScript from accessing the - | value of the cookie and the cookie will only be accessible through - | the HTTP protocol. You are free to modify this option if needed. - | - */ - - 'http_only' => true, - - /* - |-------------------------------------------------------------------------- - | Same-Site Cookies - |-------------------------------------------------------------------------- - | - | This option determines how your cookies behave when cross-site requests - | take place, and can be used to mitigate CSRF attacks. By default, we - | will set this value to "lax" since this is a secure default value. - | - | Supported: "lax", "strict", "none", null - | - */ - - 'same_site' => 'lax', - -]; diff --git a/config/view.php b/config/view.php deleted file mode 100644 index 22b8a18..0000000 --- a/config/view.php +++ /dev/null @@ -1,36 +0,0 @@ - [ - resource_path('views'), - ], - - /* - |-------------------------------------------------------------------------- - | Compiled View Path - |-------------------------------------------------------------------------- - | - | This option determines where all the compiled Blade templates will be - | stored for your application. Typically, this is within the storage - | directory. However, as usual, you are free to change this value. - | - */ - - 'compiled' => env( - 'VIEW_COMPILED_PATH', - realpath(storage_path('framework/views')) - ), - -]; From 3974e43cb5b23123dcb5203d476aa32af107e8a8 Mon Sep 17 00:00:00 2001 From: Shift Date: Wed, 15 May 2024 19:25:54 +0000 Subject: [PATCH 05/17] Set new `ENV` variables --- .env.example | 14 +++++++++++++- phpunit.xml | 2 +- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/.env.example b/.env.example index 8ded987..9b532d5 100644 --- a/.env.example +++ b/.env.example @@ -7,6 +7,14 @@ APP_COMPANY_NAME="Example Company Limited" # Set this to be the URL you'll be hosting the app on APP_URL=http://localhost +APP_TIMEZONE=UTC +APP_LOCALE=en +APP_FALLBACK_LOCALE=en +APP_FAKER_LOCALE=en_US +APP_MAINTENANCE_DRIVER=file +APP_MAINTENANCE_STORE=database +BCRYPT_ROUNDS=12 + # Set this to be the URL you want to redirect to when # someone accesses the root/homepage of the app HOME_REDIRECT_URL=https://example.com @@ -33,6 +41,7 @@ MAIL_ENCRYPTION=null # Logging details, don't need to change these to start with LOG_CHANNEL=stack +LOG_STACK=single LOG_LEVEL=debug # Database connection @@ -41,10 +50,13 @@ DB_CONNECTION=sqlite # Queue, Cache and Session Details # Should not need to change these -CACHE_DRIVER=file +CACHE_STORE=file QUEUE_CONNECTION=database SESSION_DRIVER=file SESSION_LIFETIME=120 +SESSION_ENCRYPT=false +SESSION_PATH=/ +SESSION_DOMAIN=null # Do not change these unless you know what you're doing APP_ENV=production diff --git a/phpunit.xml b/phpunit.xml index 87cbc89..ecd485e 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -18,7 +18,7 @@ - + From dfae6e7e2272c7de98e70c4bd4f098c5b89e489f Mon Sep 17 00:00:00 2001 From: Shift Date: Wed, 15 May 2024 19:25:54 +0000 Subject: [PATCH 06/17] Default new `bootstrap/app.php` --- bootstrap/app.php | 72 +++++++++++------------------------------ bootstrap/providers.php | 5 +++ 2 files changed, 24 insertions(+), 53 deletions(-) create mode 100644 bootstrap/providers.php diff --git a/bootstrap/app.php b/bootstrap/app.php index 037e17d..d5d7e70 100644 --- a/bootstrap/app.php +++ b/bootstrap/app.php @@ -1,55 +1,21 @@ singleton( - Illuminate\Contracts\Http\Kernel::class, - App\Http\Kernel::class -); - -$app->singleton( - Illuminate\Contracts\Console\Kernel::class, - App\Console\Kernel::class -); - -$app->singleton( - Illuminate\Contracts\Debug\ExceptionHandler::class, - App\Exceptions\Handler::class -); - -/* -|-------------------------------------------------------------------------- -| Return The Application -|-------------------------------------------------------------------------- -| -| This script returns the application instance. The instance is given to -| the calling script so we can separate the building of the instances -| from the actual running of the application and sending responses. -| -*/ - -return $app; +use Illuminate\Foundation\Application; +use Illuminate\Foundation\Configuration\Exceptions; +use Illuminate\Foundation\Configuration\Middleware; + +return Application::configure(basePath: dirname(__DIR__)) + ->withProviders() + ->withRouting( + web: __DIR__.'/../routes/web.php', + // api: __DIR__.'/../routes/api.php', + commands: __DIR__.'/../routes/console.php', + // channels: __DIR__.'/../routes/channels.php', + health: '/up', + ) + ->withMiddleware(function (Middleware $middleware) { + // + }) + ->withExceptions(function (Exceptions $exceptions) { + // + })->create(); diff --git a/bootstrap/providers.php b/bootstrap/providers.php new file mode 100644 index 0000000..38b258d --- /dev/null +++ b/bootstrap/providers.php @@ -0,0 +1,5 @@ + Date: Wed, 15 May 2024 19:25:55 +0000 Subject: [PATCH 07/17] Re-register HTTP middleware --- app/Http/Kernel.php | 67 --------------------------------------------- bootstrap/app.php | 7 ++++- 2 files changed, 6 insertions(+), 68 deletions(-) delete mode 100644 app/Http/Kernel.php diff --git a/app/Http/Kernel.php b/app/Http/Kernel.php deleted file mode 100644 index 83e1ed9..0000000 --- a/app/Http/Kernel.php +++ /dev/null @@ -1,67 +0,0 @@ - - */ - protected $middleware = [ - // \App\Http\Middleware\TrustHosts::class, - \App\Http\Middleware\TrustProxies::class, - \Illuminate\Http\Middleware\HandleCors::class, - \App\Http\Middleware\PreventRequestsDuringMaintenance::class, - \Illuminate\Foundation\Http\Middleware\ValidatePostSize::class, - \App\Http\Middleware\TrimStrings::class, - \Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class, - ]; - - /** - * The application's route middleware groups. - * - * @var array> - */ - protected $middlewareGroups = [ - 'web' => [ - \App\Http\Middleware\EncryptCookies::class, - \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class, - \Illuminate\Session\Middleware\StartSession::class, - \Illuminate\View\Middleware\ShareErrorsFromSession::class, - \App\Http\Middleware\VerifyCsrfToken::class, - \Illuminate\Routing\Middleware\SubstituteBindings::class, - ], - - 'api' => [ - \Illuminate\Routing\Middleware\ThrottleRequests::class.':api', - \Illuminate\Routing\Middleware\SubstituteBindings::class, - ], - ]; - - /** - * The application's middleware aliases. - * - * Aliases may be used to conveniently assign middleware to routes and groups. - * - * @var array - */ - 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, - 'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class, - 'precognitive' => \Illuminate\Foundation\Http\Middleware\HandlePrecognitiveRequests::class, - 'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class, - 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class, - 'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class, - ]; -} diff --git a/bootstrap/app.php b/bootstrap/app.php index d5d7e70..e4a9b47 100644 --- a/bootstrap/app.php +++ b/bootstrap/app.php @@ -14,7 +14,12 @@ health: '/up', ) ->withMiddleware(function (Middleware $middleware) { - // + $middleware->redirectGuestsTo(fn () => route('login')); + $middleware->redirectUsersTo(RouteServiceProvider::HOME); + + $middleware->throttleApi(); + + $middleware->replace(\Illuminate\Http\Middleware\TrustHosts::class, \App\Http\Middleware\TrustHosts::class); }) ->withExceptions(function (Exceptions $exceptions) { // From 433785a2864b283c7a96fa4a504c79f79a4a107a Mon Sep 17 00:00:00 2001 From: Shift Date: Wed, 15 May 2024 19:25:55 +0000 Subject: [PATCH 08/17] Consolidate service providers --- .../Auth/AuthenticatedSessionController.php | 3 +- .../Auth/ConfirmablePasswordController.php | 3 +- app/Providers/AppServiceProvider.php | 28 ++++++++++++ app/Providers/RouteServiceProvider.php | 44 ------------------- bootstrap/app.php | 3 +- tests/Feature/AuthenticationTest.php | 3 +- 6 files changed, 36 insertions(+), 48 deletions(-) delete mode 100644 app/Providers/RouteServiceProvider.php diff --git a/app/Http/Controllers/Auth/AuthenticatedSessionController.php b/app/Http/Controllers/Auth/AuthenticatedSessionController.php index ee51394..53e99d8 100644 --- a/app/Http/Controllers/Auth/AuthenticatedSessionController.php +++ b/app/Http/Controllers/Auth/AuthenticatedSessionController.php @@ -2,6 +2,7 @@ namespace App\Http\Controllers\Auth; +use App\Providers\AppServiceProvider; use App\Http\Controllers\Controller; use App\Http\Requests\Auth\LoginRequest; use App\Providers\RouteServiceProvider; @@ -29,7 +30,7 @@ public function store(LoginRequest $request): RedirectResponse $request->session()->regenerate(); - return redirect(RouteServiceProvider::HOME); + return redirect(AppServiceProvider::HOME); } /** diff --git a/app/Http/Controllers/Auth/ConfirmablePasswordController.php b/app/Http/Controllers/Auth/ConfirmablePasswordController.php index 58a94bb..8444cbe 100644 --- a/app/Http/Controllers/Auth/ConfirmablePasswordController.php +++ b/app/Http/Controllers/Auth/ConfirmablePasswordController.php @@ -2,6 +2,7 @@ namespace App\Http\Controllers\Auth; +use App\Providers\AppServiceProvider; use App\Http\Controllers\Controller; use App\Providers\RouteServiceProvider; use Illuminate\Http\RedirectResponse; @@ -35,6 +36,6 @@ public function store(Request $request): RedirectResponse $request->session()->put('auth.password_confirmed_at', time()); - return redirect()->intended(RouteServiceProvider::HOME); + return redirect()->intended(AppServiceProvider::HOME); } } diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 452e6b6..16edf11 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -2,10 +2,23 @@ namespace App\Providers; +use Illuminate\Cache\RateLimiting\Limit; +use Illuminate\Http\Request; +use Illuminate\Support\Facades\RateLimiter; +use Illuminate\Support\Facades\Route; use Illuminate\Support\ServiceProvider; class AppServiceProvider extends ServiceProvider { + /** + * The path to the "home" route for your application. + * + * This is used by Laravel authentication to redirect users after login. + * + * @var string + */ + public const HOME = '/dashboard'; + /** * Register any application services. */ @@ -20,5 +33,20 @@ public function register(): void public function boot(): void { // + + $this->bootRoute(); + } + + public function bootRoute(): void + { + RateLimiter::for('api', function (Request $request) { + return Limit::perMinute(60)->by($request->user()?->id ?: $request->ip()); + }); + + RateLimiter::for('signups', function (Request $request) { + return Limit::perHour(20)->by($request->ip()); + }); + + } } diff --git a/app/Providers/RouteServiceProvider.php b/app/Providers/RouteServiceProvider.php deleted file mode 100644 index aacf4f7..0000000 --- a/app/Providers/RouteServiceProvider.php +++ /dev/null @@ -1,44 +0,0 @@ -by($request->user()?->id ?: $request->ip()); - }); - - RateLimiter::for('signups', function (Request $request) { - return Limit::perHour(20)->by($request->ip()); - }); - - $this->routes(function () { - Route::prefix('api') - ->middleware('api') - ->group(base_path('routes/api.php')); - - Route::middleware('web') - ->group(base_path('routes/web.php')); - }); - } -} diff --git a/bootstrap/app.php b/bootstrap/app.php index e4a9b47..0eff71b 100644 --- a/bootstrap/app.php +++ b/bootstrap/app.php @@ -1,5 +1,6 @@ withMiddleware(function (Middleware $middleware) { $middleware->redirectGuestsTo(fn () => route('login')); - $middleware->redirectUsersTo(RouteServiceProvider::HOME); + $middleware->redirectUsersTo(AppServiceProvider::HOME); $middleware->throttleApi(); diff --git a/tests/Feature/AuthenticationTest.php b/tests/Feature/AuthenticationTest.php index 6b8fe0f..b99d48d 100644 --- a/tests/Feature/AuthenticationTest.php +++ b/tests/Feature/AuthenticationTest.php @@ -2,6 +2,7 @@ namespace Tests\Feature; +use App\Providers\AppServiceProvider; use App\Models\User; use App\Providers\RouteServiceProvider; use Illuminate\Foundation\Testing\RefreshDatabase; @@ -28,7 +29,7 @@ public function test_users_can_authenticate_using_the_login_screen(): void ]); $this->assertAuthenticated(); - $response->assertRedirect(RouteServiceProvider::HOME); + $response->assertRedirect(AppServiceProvider::HOME); } public function test_users_can_not_authenticate_with_invalid_password(): void From 7ea83867d0aa07aae97dd250f9d8418a1fc11689 Mon Sep 17 00:00:00 2001 From: Shift Date: Wed, 15 May 2024 19:25:55 +0000 Subject: [PATCH 09/17] Re-register service providers --- config/app.php | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/config/app.php b/config/app.php index 1db2d42..e68645d 100644 --- a/config/app.php +++ b/config/app.php @@ -9,19 +9,5 @@ 'home_redirect_url' => env('HOME_REDIRECT_URL', null), - 'providers' => ServiceProvider::defaultProviders()->merge([ - /* - * Package Service Providers... - */ - - /* - * Application Service Providers... - */ - App\Providers\AppServiceProvider::class, - App\Providers\AuthServiceProvider::class, - // App\Providers\BroadcastServiceProvider::class, - App\Providers\EventServiceProvider::class, - App\Providers\RouteServiceProvider::class, - ])->toArray(), ]; From 97859eaccd216e5a1e50892a6f33b346322c276b Mon Sep 17 00:00:00 2001 From: Shift Date: Wed, 15 May 2024 19:25:55 +0000 Subject: [PATCH 10/17] Re-register exception handling --- app/Exceptions/Handler.php | 29 ----------------------------- 1 file changed, 29 deletions(-) delete mode 100644 app/Exceptions/Handler.php diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php deleted file mode 100644 index 4aec3c4..0000000 --- a/app/Exceptions/Handler.php +++ /dev/null @@ -1,29 +0,0 @@ - - */ - protected $dontFlash = [ - 'password', - 'password_confirmation', - ]; - - /** - * Register the exception handling callbacks for the application. - */ - public function register(): void - { - $this->reportable(function (Throwable $e) { - // - }); - } -} From b1f79d9209749a32c31783a589a16a56ea5ad28f Mon Sep 17 00:00:00 2001 From: Shift Date: Wed, 15 May 2024 19:25:57 +0000 Subject: [PATCH 11/17] Re-register routes --- routes/api.php | 19 ------------------- routes/channels.php | 18 ------------------ routes/console.php | 13 +------------ 3 files changed, 1 insertion(+), 49 deletions(-) delete mode 100644 routes/api.php delete mode 100644 routes/channels.php diff --git a/routes/api.php b/routes/api.php deleted file mode 100644 index bcb8b18..0000000 --- a/routes/api.php +++ /dev/null @@ -1,19 +0,0 @@ -get('/user', function (Request $request) { - return $request->user(); -}); diff --git a/routes/channels.php b/routes/channels.php deleted file mode 100644 index 5d451e1..0000000 --- a/routes/channels.php +++ /dev/null @@ -1,18 +0,0 @@ -id === (int) $id; -}); diff --git a/routes/console.php b/routes/console.php index e05f4c9..eff2ed2 100644 --- a/routes/console.php +++ b/routes/console.php @@ -3,17 +3,6 @@ use Illuminate\Foundation\Inspiring; use Illuminate\Support\Facades\Artisan; -/* -|-------------------------------------------------------------------------- -| Console Routes -|-------------------------------------------------------------------------- -| -| This file is where you may define all of your Closure based console -| commands. Each Closure is bound to a command instance allowing a -| simple approach to interacting with each command's IO methods. -| -*/ - Artisan::command('inspire', function () { $this->comment(Inspiring::quote()); -})->purpose('Display an inspiring quote'); +})->purpose('Display an inspiring quote')->hourly(); From 13e8b9655e901e53cf7731a64fed5b9a69202380 Mon Sep 17 00:00:00 2001 From: Shift Date: Wed, 15 May 2024 19:25:58 +0000 Subject: [PATCH 12/17] Re-register scheduled commands --- app/Console/Kernel.php | 32 -------------------------------- routes/console.php | 9 +++++++++ 2 files changed, 9 insertions(+), 32 deletions(-) delete mode 100644 app/Console/Kernel.php diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php deleted file mode 100644 index 022c8bc..0000000 --- a/app/Console/Kernel.php +++ /dev/null @@ -1,32 +0,0 @@ -job(new FindRssFeedsToReviewJob())->everyFifteenMinutes(); - $schedule->job(new ScrubSignupsJob())->daily(); - $schedule->job(new ScrubUnsubscribesJob())->daily(); - } - - /** - * Register the commands for the application. - */ - protected function commands(): void - { - $this->load(__DIR__.'/Commands'); - - require base_path('routes/console.php'); - } -} diff --git a/routes/console.php b/routes/console.php index eff2ed2..d8774ee 100644 --- a/routes/console.php +++ b/routes/console.php @@ -1,8 +1,17 @@ comment(Inspiring::quote()); })->purpose('Display an inspiring quote')->hourly(); + + +Schedule::job(new FindRssFeedsToReviewJob())->everyFifteenMinutes(); +Schedule::job(new ScrubSignupsJob())->daily(); +Schedule::job(new ScrubUnsubscribesJob())->daily(); From 8a88cdaeeb978492ecd45d68ee02db11f0c48f85 Mon Sep 17 00:00:00 2001 From: Shift Date: Wed, 15 May 2024 19:25:58 +0000 Subject: [PATCH 13/17] Bump Composer dependencies --- composer.json | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/composer.json b/composer.json index 38c3038..96cd0bd 100644 --- a/composer.json +++ b/composer.json @@ -4,24 +4,24 @@ "description": "A simple plaintext email send app based on Laravel", "license": "MIT", "require": { - "php": "^8.1", + "php": "^8.2", "ext-libxml": "*", "ext-simplexml": "*", "ext-sqlite3": "*", "ext-mbstring": "*", "doctrine/dbal": "^3.5", "guzzlehttp/guzzle": "^7.2", - "laravel/framework": "^10.9", - "laravel/tinker": "^2.8" + "laravel/framework": "^11.7", + "laravel/tinker": "^2.9" }, "require-dev": { - "fakerphp/faker": "^1.9.1", - "laravel/breeze": "^1.18", - "mockery/mockery": "^1.4.4", - "nunomaduro/collision": "^7.0", - "nunomaduro/larastan": "^2.4", - "phpunit/phpunit": "^10.0", - "spatie/laravel-ignition": "^2.0" + "fakerphp/faker": "^1.23", + "laravel/breeze": "^2.0", + "mockery/mockery": "^1.6", + "nunomaduro/collision": "^8.0", + "nunomaduro/larastan": "^2.8", + "phpunit/phpunit": "^10.5", + "spatie/laravel-ignition": "^2.4" }, "config": { "optimize-autoloader": true, From 32b4fb343bdda488166b1c741e83d0a66ef5796b Mon Sep 17 00:00:00 2001 From: Shift Date: Wed, 15 May 2024 19:25:59 +0000 Subject: [PATCH 14/17] Convert `$casts` property to method --- app/Models/RssFeed.php | 15 ++++++++++----- app/Models/Send.php | 13 +++++++++---- app/Models/User.php | 13 ++++++++----- 3 files changed, 27 insertions(+), 14 deletions(-) diff --git a/app/Models/RssFeed.php b/app/Models/RssFeed.php index 0292f18..0bc2933 100644 --- a/app/Models/RssFeed.php +++ b/app/Models/RssFeed.php @@ -31,12 +31,17 @@ class RssFeed extends Model protected $fillable = ['url', 'active', 'template_send_id', 'send_frequency', 'target_hour']; /** - * @var array + * Get the attributes that should be cast. + * + * @return array */ - protected $casts = [ - 'last_reviewed_at' => 'immutable_datetime', - 'next_review_at' => 'immutable_datetime', - ]; + protected function casts(): array + { + return [ + 'last_reviewed_at' => 'immutable_datetime', + 'next_review_at' => 'immutable_datetime', + ]; + } /** * Get the campaign that this rss feed sits in. diff --git a/app/Models/Send.php b/app/Models/Send.php index 413b961..01aed26 100644 --- a/app/Models/Send.php +++ b/app/Models/Send.php @@ -28,11 +28,16 @@ class Send extends Model protected $fillable = ['name', 'content', 'subject', 'mail_list_id', 'campaign_id']; /** - * @var array + * Get the attributes that should be cast. + * + * @return array */ - protected $casts = [ - 'activated_at' => 'immutable_datetime', - ]; + protected function casts(): array + { + return [ + 'activated_at' => 'immutable_datetime', + ]; + } /** * Get the campaign that this send is in. diff --git a/app/Models/User.php b/app/Models/User.php index 2d3d209..0e1c724 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -33,11 +33,14 @@ class User extends Authenticatable ]; /** - * The attributes that should be cast to native types. + * Get the attributes that should be cast. * - * @var array + * @return array */ - protected $casts = [ - 'email_verified_at' => 'datetime', - ]; + protected function casts(): array + { + return [ + 'email_verified_at' => 'datetime', + ]; + } } From 0a22aa64d0911f8e907a4122fc7627a78b0ceec1 Mon Sep 17 00:00:00 2001 From: Shift Date: Wed, 15 May 2024 19:26:02 +0000 Subject: [PATCH 15/17] Mark base controller as `abstract` --- app/Http/Controllers/Controller.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Controllers/Controller.php b/app/Http/Controllers/Controller.php index 6f3b644..e63741f 100644 --- a/app/Http/Controllers/Controller.php +++ b/app/Http/Controllers/Controller.php @@ -6,7 +6,7 @@ use Illuminate\Foundation\Validation\ValidatesRequests; use Illuminate\Routing\Controller as BaseController; -class Controller extends BaseController +abstract class Controller extends BaseController { use AuthorizesRequests; use ValidatesRequests; From cd64c00ddf42a93384e3c44bea81f8559c767a65 Mon Sep 17 00:00:00 2001 From: Shift Date: Wed, 15 May 2024 19:26:03 +0000 Subject: [PATCH 16/17] Remove `CreatesApplication` testing trait --- tests/CreatesApplication.php | 21 --------------------- tests/TestCase.php | 1 - 2 files changed, 22 deletions(-) delete mode 100644 tests/CreatesApplication.php diff --git a/tests/CreatesApplication.php b/tests/CreatesApplication.php deleted file mode 100644 index cc68301..0000000 --- a/tests/CreatesApplication.php +++ /dev/null @@ -1,21 +0,0 @@ -make(Kernel::class)->bootstrap(); - - return $app; - } -} diff --git a/tests/TestCase.php b/tests/TestCase.php index 7c17c57..d3bb1f4 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -8,7 +8,6 @@ abstract class TestCase extends BaseTestCase { - use CreatesApplication; use DatabaseMigrations; protected function whileLoggedIn(): self From 4970ea6333d7f2abb5158a15880f6d450a13f386 Mon Sep 17 00:00:00 2001 From: Shift Date: Wed, 15 May 2024 19:26:04 +0000 Subject: [PATCH 17/17] Shift cleanup --- app/Http/Controllers/Auth/AuthenticatedSessionController.php | 3 +-- app/Http/Controllers/Auth/ConfirmablePasswordController.php | 3 +-- app/Providers/AppServiceProvider.php | 1 - config/app.php | 4 ---- routes/console.php | 1 - tests/Feature/AuthenticationTest.php | 3 +-- 6 files changed, 3 insertions(+), 12 deletions(-) diff --git a/app/Http/Controllers/Auth/AuthenticatedSessionController.php b/app/Http/Controllers/Auth/AuthenticatedSessionController.php index 53e99d8..672139e 100644 --- a/app/Http/Controllers/Auth/AuthenticatedSessionController.php +++ b/app/Http/Controllers/Auth/AuthenticatedSessionController.php @@ -2,10 +2,9 @@ namespace App\Http\Controllers\Auth; -use App\Providers\AppServiceProvider; use App\Http\Controllers\Controller; use App\Http\Requests\Auth\LoginRequest; -use App\Providers\RouteServiceProvider; +use App\Providers\AppServiceProvider; use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; use Illuminate\Support\Facades\Auth; diff --git a/app/Http/Controllers/Auth/ConfirmablePasswordController.php b/app/Http/Controllers/Auth/ConfirmablePasswordController.php index 8444cbe..7564c83 100644 --- a/app/Http/Controllers/Auth/ConfirmablePasswordController.php +++ b/app/Http/Controllers/Auth/ConfirmablePasswordController.php @@ -2,9 +2,8 @@ namespace App\Http\Controllers\Auth; -use App\Providers\AppServiceProvider; use App\Http\Controllers\Controller; -use App\Providers\RouteServiceProvider; +use App\Providers\AppServiceProvider; use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; use Illuminate\Support\Facades\Auth; diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 16edf11..fa7f56c 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -47,6 +47,5 @@ public function bootRoute(): void return Limit::perHour(20)->by($request->ip()); }); - } } diff --git a/config/app.php b/config/app.php index e68645d..1677733 100644 --- a/config/app.php +++ b/config/app.php @@ -1,13 +1,9 @@ env('APP_COMPANY_NAME', 'MailBag'), 'home_redirect_url' => env('HOME_REDIRECT_URL', null), - ]; diff --git a/routes/console.php b/routes/console.php index d8774ee..4bd8f27 100644 --- a/routes/console.php +++ b/routes/console.php @@ -11,7 +11,6 @@ $this->comment(Inspiring::quote()); })->purpose('Display an inspiring quote')->hourly(); - Schedule::job(new FindRssFeedsToReviewJob())->everyFifteenMinutes(); Schedule::job(new ScrubSignupsJob())->daily(); Schedule::job(new ScrubUnsubscribesJob())->daily(); diff --git a/tests/Feature/AuthenticationTest.php b/tests/Feature/AuthenticationTest.php index b99d48d..2cf54be 100644 --- a/tests/Feature/AuthenticationTest.php +++ b/tests/Feature/AuthenticationTest.php @@ -2,9 +2,8 @@ namespace Tests\Feature; -use App\Providers\AppServiceProvider; use App\Models\User; -use App\Providers\RouteServiceProvider; +use App\Providers\AppServiceProvider; use Illuminate\Foundation\Testing\RefreshDatabase; use Tests\TestCase;