From 0efb8536dd167d5fafdd346f637cef7abeb870d8 Mon Sep 17 00:00:00 2001 From: Anatoliy Poloz Date: Thu, 28 Dec 2023 16:30:19 +0300 Subject: [PATCH] rector code refactoring --- app/Http/Kernel.php | 2 +- app/Listeners/ProcessDietSelectedNotification.php | 9 --------- app/Livewire/BlogPost/Create.php | 2 +- app/Livewire/BlogPost/Edit.php | 2 +- app/Livewire/Diet/Create.php | 6 +++--- app/Livewire/Diet/Edit.php | 6 +++--- app/Livewire/Plan/Create.php | 2 +- app/Livewire/Plan/Edit.php | 2 +- app/Livewire/ProductNutritional/Create.php | 4 ++-- app/Livewire/ProductNutritional/Edit.php | 4 ++-- app/Livewire/Registration/Step1.php | 11 ++++++----- app/Livewire/TagsComponent.php | 2 +- app/Models/Recipe.php | 3 ++- app/Services/FeedService.php | 1 - lang/ru/recipe.php | 1 + public/css/app.css | 5 ++++- resources/views/livewire/plan/create.blade.php | 3 +-- .../views/livewire/recipe/comment/show.blade.php | 4 ++-- resources/views/recipe/edit_form.blade.php | 3 +++ resources/views/user/show.blade.php | 4 ++++ tests/Feature/DeleteAccountTest.php | 2 +- tests/Feature/PasswordResetTest.php | 2 +- 22 files changed, 41 insertions(+), 39 deletions(-) diff --git a/app/Http/Kernel.php b/app/Http/Kernel.php index bbbb073..d714ca7 100644 --- a/app/Http/Kernel.php +++ b/app/Http/Kernel.php @@ -53,7 +53,7 @@ class Kernel extends HttpKernel * * @var array */ - protected $routeMiddleware = [ + protected $middlewareAliases = [ 'auth' => \App\Http\Middleware\Authenticate::class, 'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class, 'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class, diff --git a/app/Listeners/ProcessDietSelectedNotification.php b/app/Listeners/ProcessDietSelectedNotification.php index c09fc4c..daf5418 100644 --- a/app/Listeners/ProcessDietSelectedNotification.php +++ b/app/Listeners/ProcessDietSelectedNotification.php @@ -14,15 +14,6 @@ class ProcessDietSelectedNotification implements ShouldQueue public $afterCommit = true; - /** - * Create the event listener. - * - * @return void - */ - public function __construct() - { - } - /** * Handle the event. * diff --git a/app/Livewire/BlogPost/Create.php b/app/Livewire/BlogPost/Create.php index c6920ac..6a87956 100644 --- a/app/Livewire/BlogPost/Create.php +++ b/app/Livewire/BlogPost/Create.php @@ -12,7 +12,7 @@ class Create extends Component { use WithFileUploads; - public $image = null; + public $image; public $state = 'archived'; diff --git a/app/Livewire/BlogPost/Edit.php b/app/Livewire/BlogPost/Edit.php index 5357862..a95081c 100644 --- a/app/Livewire/BlogPost/Edit.php +++ b/app/Livewire/BlogPost/Edit.php @@ -14,7 +14,7 @@ class Edit extends Component public BlogPost $blogPost; - public $image = null; + public $image; public $state = 'archived'; diff --git a/app/Livewire/Diet/Create.php b/app/Livewire/Diet/Create.php index 8861c85..4ff25be 100644 --- a/app/Livewire/Diet/Create.php +++ b/app/Livewire/Diet/Create.php @@ -13,7 +13,7 @@ class Create extends Component public $name = ''; - public $image = null; + public $image; public $duration = '7'; @@ -25,9 +25,9 @@ class Create extends Component public $days = []; - public $copyedDay = null; + public $copyedDay; - public $copyedDayData = null; + public $copyedDayData; protected $listeners = ['dayUpdated', 'makeCopy', 'makePaste']; diff --git a/app/Livewire/Diet/Edit.php b/app/Livewire/Diet/Edit.php index 3439fd0..46df9b2 100644 --- a/app/Livewire/Diet/Edit.php +++ b/app/Livewire/Diet/Edit.php @@ -11,7 +11,7 @@ class Edit extends Component public $name = ''; - public $image = null; + public $image; public $duration = '7'; @@ -23,9 +23,9 @@ class Edit extends Component public $days = []; - public $copyedDay = null; + public $copyedDay; - public $copyedDayData = null; + public $copyedDayData; protected $listeners = ['dayUpdated', 'makeCopy', 'makePaste']; diff --git a/app/Livewire/Plan/Create.php b/app/Livewire/Plan/Create.php index 5e9fa64..e77c696 100644 --- a/app/Livewire/Plan/Create.php +++ b/app/Livewire/Plan/Create.php @@ -14,7 +14,7 @@ class Create extends Component public $name = ''; - public $image = null; + public $image; public $duration = '7'; diff --git a/app/Livewire/Plan/Edit.php b/app/Livewire/Plan/Edit.php index 1a1918e..e4a3dd7 100644 --- a/app/Livewire/Plan/Edit.php +++ b/app/Livewire/Plan/Edit.php @@ -14,7 +14,7 @@ class Edit extends Component public $name = ''; - public $image = null; + public $image; public $duration = '7'; diff --git a/app/Livewire/ProductNutritional/Create.php b/app/Livewire/ProductNutritional/Create.php index 7a66d7f..c34d157 100644 --- a/app/Livewire/ProductNutritional/Create.php +++ b/app/Livewire/ProductNutritional/Create.php @@ -83,7 +83,7 @@ class Create extends Component foreach ($productKeys as [$key100, $keyPortion]) { if ($this->{$keyPortion}) { - $newVal = (float) ($k * (float) $this->{$keyPortion}); + $newVal = $k * (float) $this->{$keyPortion}; $this->fill([$key100 => $newVal]); } } @@ -101,7 +101,7 @@ class Create extends Component $k = $mass / 100; foreach ($productKeys as [$key100, $keyPortion]) { if ($this->{$key100}) { - $newVal = (float) ($k * (float) $this->{$key100}); + $newVal = $k * (float) $this->{$key100}; $this->fill([$keyPortion => $newVal]); } } diff --git a/app/Livewire/ProductNutritional/Edit.php b/app/Livewire/ProductNutritional/Edit.php index 9c1df3f..239b8bb 100644 --- a/app/Livewire/ProductNutritional/Edit.php +++ b/app/Livewire/ProductNutritional/Edit.php @@ -104,7 +104,7 @@ class Edit extends Component foreach ($productKeys as [$key100, $keyPortion]) { if ($this->{$keyPortion}) { - $newVal = (float) ($k * (float) $this->{$keyPortion}); + $newVal = $k * (float) $this->{$keyPortion}; $this->fill([$key100 => $newVal]); } } @@ -122,7 +122,7 @@ class Edit extends Component $k = $mass / 100; foreach ($productKeys as [$key100, $keyPortion]) { if ($this->{$key100}) { - $newVal = (float) ($k * (float) $this->{$key100}); + $newVal = $k * (float) $this->{$key100}; $this->fill([$keyPortion => $newVal]); } } diff --git a/app/Livewire/Registration/Step1.php b/app/Livewire/Registration/Step1.php index f530e27..686f38b 100644 --- a/app/Livewire/Registration/Step1.php +++ b/app/Livewire/Registration/Step1.php @@ -108,6 +108,12 @@ class Step1 extends Component public function skipStep() { + $validatedData = $this->getValidateData($this->step); + $registrationdata = session()->get('registrationdata', []); + $mergetdRegistrationData = array_merge($validatedData, $registrationdata); + + session()->put('registrationdata', $mergetdRegistrationData); + return redirect() ->route( 'register.step1', @@ -240,9 +246,4 @@ class Step1 extends Component { return 'step'.(int) Str::replaceFirst('step', '', $this->step) + 1; } - - private function getValidateMessages() - { - return ['required' => 'The :attribute field is required']; - } } diff --git a/app/Livewire/TagsComponent.php b/app/Livewire/TagsComponent.php index a56fe23..012b94d 100644 --- a/app/Livewire/TagsComponent.php +++ b/app/Livewire/TagsComponent.php @@ -11,7 +11,7 @@ class TagsComponent extends Component { public $tags; - public $parentComponent = null; + public $parentComponent; // protected $listeners = ['tagAdded', 'tagRemoved']; diff --git a/app/Models/Recipe.php b/app/Models/Recipe.php index b7250ff..66ff1f2 100755 --- a/app/Models/Recipe.php +++ b/app/Models/Recipe.php @@ -8,6 +8,7 @@ use Illuminate\Database\Eloquent\Casts\AsCollection; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\HasMany; +use Illuminate\Database\Eloquent\Relations\HasOneThrough; use Illuminate\Contracts\Database\Eloquent\Builder; use Spatie\Sluggable\HasSlug; use Spatie\Sluggable\SlugOptions; @@ -59,7 +60,7 @@ class Recipe extends Model implements Viewable /* return $this->belongsToMany(User::class, 'recipe_author', 'recipe_id', 'user_id'); */ /* } */ - public function author() + public function author(): HasOneThrough { return $this ->hasOneThrough(User::class, RecipeAuthor::class, 'recipe_id', 'id', 'id', 'user_id') diff --git a/app/Services/FeedService.php b/app/Services/FeedService.php index 13a322c..11ee3e9 100644 --- a/app/Services/FeedService.php +++ b/app/Services/FeedService.php @@ -12,7 +12,6 @@ class FeedService { public static function showActualFeed() { - $days = 5; $dateMax = Recipe::max('created_at'); $dateMin = Carbon::parse($dateMax)->subDays(10); diff --git a/lang/ru/recipe.php b/lang/ru/recipe.php index c4fc380..c39386e 100644 --- a/lang/ru/recipe.php +++ b/lang/ru/recipe.php @@ -15,6 +15,7 @@ return [ 't10m' => '10 минут', 't20m' => '20 минут', 't30m' => '30 минут', + 't45m' => '45 минут', 't60m' => '1 час', 't120m' => '2 час', 't14400m' => '10 дней', diff --git a/public/css/app.css b/public/css/app.css index 89d015b..cb66aa5 100644 --- a/public/css/app.css +++ b/public/css/app.css @@ -13709,7 +13709,10 @@ video { color: #fff; }.active-icon-heart{ color: #2f80ed; -}/* Recipe-show like */.text-blue-400 { color: #2f80ed; }.text-blue-500 { color: #2f80ed;}.text-gray-400 { color: #cbd5e0; }.text-gray-500 { color: #a0aec0; }@media (prefers-color-scheme: dark) {.dark\:prose-invert { +}/* Recipe-show like */.text-blue-400 { color: #2f80ed; }.text-blue-500 { color: #2f80ed;}.text-gray-400 { color: #cbd5e0; }.text-gray-500 { color: #a0aec0; }.review__info { + min-width: 120px; + width: 120px; +}@media (prefers-color-scheme: dark) {.dark\:prose-invert { --tw-prose-body: var(--tw-prose-invert-body); --tw-prose-headings: var(--tw-prose-invert-headings); --tw-prose-lead: var(--tw-prose-invert-lead); diff --git a/resources/views/livewire/plan/create.blade.php b/resources/views/livewire/plan/create.blade.php index bcc67ef..dfa0c1f 100644 --- a/resources/views/livewire/plan/create.blade.php +++ b/resources/views/livewire/plan/create.blade.php @@ -25,8 +25,7 @@ Изображение