diff --git a/app/Livewire/BlogPost/ListView.php b/app/Livewire/BlogPost/ListView.php index e17ca3f..0194498 100644 --- a/app/Livewire/BlogPost/ListView.php +++ b/app/Livewire/BlogPost/ListView.php @@ -2,7 +2,6 @@ namespace App\Livewire\BlogPost; -use App\Models\User; use App\Services\BlogPost\ListViewService; use Illuminate\View\View; use Livewire\Component; @@ -18,7 +17,7 @@ class ListView extends Component public string $tag = ''; - public User|null $author = null; + public ?int $author = null; protected array $queryString = [ 'search' => ['except' => ''], diff --git a/app/Livewire/Registration/Step1.php b/app/Livewire/Registration/Step1.php index f30851e..c41c8ee 100644 --- a/app/Livewire/Registration/Step1.php +++ b/app/Livewire/Registration/Step1.php @@ -38,41 +38,41 @@ class Step1 extends Component public string $lang = 'ru'; - public int|string $weight = ''; + public int|string|null $weight = ''; - public int|string $height = ''; + public int|string|null $height = ''; - public int|string $chest_circumference = ''; + public int|string|null $chest_circumference = ''; - public int|string $waist_circumference = ''; + public int|string|null $waist_circumference = ''; - public int|string $hip_circumference = ''; + public int|string|null $hip_circumference = ''; - public int|string $blood_pressure_up = ''; + public int|string|null $blood_pressure_up = ''; - public int|string $blood_pressure_down = ''; + public int|string|null $blood_pressure_down = ''; public int|string $has_hypo = 0; public int|string $has_hyper = 0; - public string $about_alergy = ''; + public ?string $about_alergy = ''; - public string $about_taking_pils = ''; + public ?string $about_taking_pils = ''; - public string $about_sport_hobbies = ''; + public ?string $about_sport_hobbies = ''; - public string $favorite_foods = ''; + public ?string $favorite_foods = ''; - public string $unfavorite_foods = ''; + public ?string $unfavorite_foods = ''; - public string $additional_info = ''; + public ?string $additional_info = ''; public function mount(string $step): void { $this->step = $step; collect(session()->get('registrationdata', [])) - ->each(fn ($item, $key) => $this->{$key} = $item); + ->each(fn ($item, $key): mixed => $this->{$key} = $item); } public function render(): View|ViewFactory diff --git a/app/Models/Plan.php b/app/Models/Plan.php index ecea57c..9ca065f 100644 --- a/app/Models/Plan.php +++ b/app/Models/Plan.php @@ -102,7 +102,7 @@ class Plan extends Model implements Viewable return 'slug'; } - public function author(): BelongsToMany + public function author(): ?BelongsToMany { return $this->belongsToMany(User::class, 'plan_author', 'plan_id', 'user_id'); } diff --git a/app/Policies/PlanPolicy.php b/app/Policies/PlanPolicy.php index 536b452..94dca0a 100755 --- a/app/Policies/PlanPolicy.php +++ b/app/Policies/PlanPolicy.php @@ -14,6 +14,6 @@ class PlanPolicy private function isAuthorPlan(User $user, Plan $plan): bool { - return $user->id === $plan->author()->first()->id; + return $user->id === optional($plan->author()->first())->id; } } diff --git a/app/Presenters/PlanPresenter.php b/app/Presenters/PlanPresenter.php index b414553..ffc5730 100644 --- a/app/Presenters/PlanPresenter.php +++ b/app/Presenters/PlanPresenter.php @@ -18,7 +18,7 @@ class PlanPresenter extends Presenter return Storage::url($author->profile_photo_path); } - public function getAuthor(): User + public function getAuthor(): ?User { return $this->author->first(); } diff --git a/app/Rules/MinWords.php b/app/Rules/MinWords.php index c04582d..cfb1c24 100644 --- a/app/Rules/MinWords.php +++ b/app/Rules/MinWords.php @@ -2,9 +2,10 @@ namespace App\Rules; -use Illuminate\Contracts\Validation\Rule; +use Closure; +use Illuminate\Contracts\Validation\ValidationRule; -class MinWords implements Rule +class MinWords implements ValidationRule { protected int $minWords; @@ -13,15 +14,15 @@ class MinWords implements Rule $this->minWords = $minWords; } - public function passes(mixed $attribute, mixed $value): bool|int + /** + * Run the validation rule. + */ + public function validate(string $attribute, mixed $value, Closure $fail): void { $wordCount = count(preg_split('/\W+/u', $value, -1, PREG_SPLIT_NO_EMPTY)); - return $wordCount >= $this->minWords; - } - - public function message(): string - { - return "The :attribute must have at least {$this->minWords} words."; + if ($wordCount <= $this->minWords) { + $fail('validation.min_words_count')->translate(['min' => $this->minWords]); + } } } diff --git a/app/Services/Recipe/ListViewService.php b/app/Services/Recipe/ListViewService.php index bb5f827..dcbd18d 100644 --- a/app/Services/Recipe/ListViewService.php +++ b/app/Services/Recipe/ListViewService.php @@ -5,12 +5,12 @@ namespace App\Services\Recipe; use App\Livewire\Recipe\ListView; use App\Models\Recipe; use App\Services\Strategy\Criteried\AuthorCriteriaStrategy; +use App\Services\Strategy\Criteried\CriteriaStrategy; use App\Services\Strategy\Criteried\DefaultCriteriaStrategy; use App\Services\Strategy\Criteried\SearchCriteriaStrategy; use App\Services\Strategy\Criteried\TagCriteriaStrategy; use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Relations\MorphToMany; -use App\Services\Strategy\Criteried\CriteriaStrategy; class ListViewService { @@ -28,12 +28,12 @@ class ListViewService return $this->getSecondaryCriteriedRecipes($recipes); } - public function getTagsCollection(): array + public function getTagsCollection(): ?array { return Recipe::all()->map( fn ($r) => [ $r->type, - $r->tags->map(fn ($t) => $t->id . '-' . $t->name)->all(), + $r->tags->map(fn ($t) => $t->id.'-'.$t->name)->all(), ] )->reduce(function ($acc, $item) { [$type, $tagNames] = $item; @@ -44,6 +44,7 @@ class ListViewService $acc[$type][$name] = 1; } } + return $acc; }); } @@ -51,6 +52,7 @@ class ListViewService private function getPrimaryCriteriedRecipes(): Builder|Recipe|MorphToMany|array { $criteria = $this->getCriteriaStrategy(); + return $criteria->getRecipes(); } diff --git a/app/Services/RegistrationRuleSet.php b/app/Services/RegistrationRuleSet.php index df33072..a5c8e7a 100644 --- a/app/Services/RegistrationRuleSet.php +++ b/app/Services/RegistrationRuleSet.php @@ -70,13 +70,13 @@ class RegistrationRuleSet 'height' => static::transform($obj->height), ], 'step3' => [ - 'chest_circumference' => $obj->chest_circumference, - 'waist_circumference' => $obj->waist_circumference, - 'hip_circumference' => $obj->hip_circumference, + 'chest_circumference' => static::transform($obj->chest_circumference), + 'waist_circumference' => static::transform($obj->waist_circumference), + 'hip_circumference' => static::transform($obj->hip_circumference), ], 'step4' => [ - 'blood_pressure_up' => $obj->blood_pressure_up, - 'blood_pressure_down' => $obj->blood_pressure_down, + 'blood_pressure_up' => static::transform($obj->blood_pressure_up), + 'blood_pressure_down' => static::transform($obj->blood_pressure_down), 'has_hypo' => $obj->has_hypo, 'has_hyper' => $obj->has_hyper, ], diff --git a/database/seeders/RecipeTagSeeder.php b/database/seeders/RecipeTagSeeder.php index e78ed35..b628941 100644 --- a/database/seeders/RecipeTagSeeder.php +++ b/database/seeders/RecipeTagSeeder.php @@ -5,8 +5,8 @@ declare(strict_types=1); namespace Database\Seeders; use App\Models\Recipe; -use Illuminate\Database\Seeder; use App\Models\Tag; +use Illuminate\Database\Seeder; class RecipeTagSeeder extends Seeder { @@ -17,12 +17,11 @@ class RecipeTagSeeder extends Seeder { if (Recipe::count() > 0) { $recipes = Recipe::all(); + $tags = Tag::factory()->count(5)->create(); - $recipes->each(static function ($recipe): void { - - $tags = Tag::factory()->count(5)->create(); - - $tagsIds = collect($tags)->map(fn($curTag) => $curTag['id']); + $recipes->each(static function ($recipe) use ($tags): void { + $randomTags = $tags->random(3); + $tagsIds = $randomTags->pluck('id'); $recipe->tags()->attach($tagsIds); }); } diff --git a/lang/en/validation.php b/lang/en/validation.php index 60fba71..2fdfae6 100644 --- a/lang/en/validation.php +++ b/lang/en/validation.php @@ -49,6 +49,7 @@ return [ 'exists' => 'The selected :attribute is invalid.', 'file' => 'The :attribute must be a file.', 'filled' => 'The :attribute field must have a value.', + 'min_words_count' => 'The :attribute must have at least :min words.', 'gt' => [ 'array' => 'The :attribute must have more than :value items.', 'file' => 'The :attribute must be greater than :value kilobytes.', diff --git a/lang/ru/reg_form.php b/lang/ru/reg_form.php index 38b7085..3f97a47 100644 --- a/lang/ru/reg_form.php +++ b/lang/ru/reg_form.php @@ -40,12 +40,12 @@ return [ 'save_changes' => 'Сохранить изменения', 'skip' => 'Пропустить', 'go_back' => 'Вернуться', - 'step3_head' => 'Так держать :)', + 'step3_head' => 'Так держать :) Шаг №3', 'primary_measurements' => 'Первичные замеры', 'chest_circumference' => 'Обхват груди', 'waist_circumference' => 'Обхват талии', 'hip_circumference' => 'Обхват бедр', - 'step4_head' => 'Давай в том же духе :)', + 'step4_head' => 'Давай в том же духе :) Шаг №4', 'your_blood_pressure' => 'Ваше артериальное давление?', 'average_pressure_readings' => 'Показатели артериального давления', 'pressure_up' => 'Верхннее', @@ -54,10 +54,10 @@ return [ 'prone_to_hypertension' => 'Есть ли у вас склонность к гипертонии?', 'yes' => 'Да', 'no' => 'Нет', - 'step5_head' => 'Расскажите о себе :)', - 'step6_head' => 'Расскажите о себе :)', - 'step7_head' => 'Расскажите о себе :)', - 'step8_head' => 'Ещё немного :)', + 'step5_head' => 'Расскажите о себе :) Шаг №5', + 'step6_head' => 'Расскажите о себе :) Шаг №6', + 'step7_head' => 'Расскажите о себе :) Шаг №7', + 'step8_head' => 'Ещё немного :) Шаг №8', 'has_alergy' => 'Наличие аллергии', 'enter_info' => 'Введите информацию...', 'take_pils' => 'Принимаете ли вы лекарства на постоянной основе? Если да, то укажите какие', diff --git a/lang/ru/validation.php b/lang/ru/validation.php index 726457c..5dd3ed7 100644 --- a/lang/ru/validation.php +++ b/lang/ru/validation.php @@ -49,6 +49,7 @@ return [ 'exists' => 'The selected :attribute is invalid.', 'file' => 'The :attribute must be a file.', 'filled' => 'The :attribute field must have a value.', + 'min_words_count' => 'Поле ":attribute" должно состоять минимум из :min слов.', 'gt' => [ 'array' => 'The :attribute must have more than :value items.', 'file' => 'The :attribute must be greater than :value kilobytes.', @@ -162,6 +163,31 @@ return [ 'attributes' => [ 'image' => 'Изображение', + 'unfavorite_foods' => 'не любимые продукты', + 'favorite_foods' => 'любимые продукты', + 'first_name' => 'Имя', + 'last_name' => 'Фамилия', + 'email' => 'Мэйл', + 'password' => 'Пароль', + 'password_confirmation' => 'Подтверждение пароля', + 'birthdate' => 'Дата рождения', + 'gender' => 'Пол', + 'country' => 'Страна', + 'city' => 'Город', + 'lang' => 'Язык', + 'weight' => 'Вес', + 'height' => 'Рост', + 'chest_circumference' => 'Замер груди', + 'waist_circumference' => 'Замер пояса', + 'hip_circumference' => 'Замер бёдер', + 'blood_pressure_up' => 'Верхнее давление', + 'blood_pressure_down' => 'Нижнее давление', + 'has_hypo' => 'Наличие гипотонии', + 'has_hyper' => 'Наличи гипертонии', + 'about_alergy' => 'Наличие аллерги на продукты', + 'about_taking_pils' => 'Наличи регулярного приёма лекарств', + 'about_sport_hobbies' => 'Спортивные предпочтения', + 'additional_info' => 'Дополнительная информация', ], ]; diff --git a/public/css/app.css b/public/css/app.css index 7c358cf..b71fe50 100644 --- a/public/css/app.css +++ b/public/css/app.css @@ -13182,16 +13182,12 @@ video { align-items: flex-end; }.items-center { align-items: center; -}.items-stretch { - align-items: stretch; }.justify-end { justify-content: flex-end; }.justify-center { justify-content: center; }.justify-between { justify-content: space-between; -}.justify-around { - justify-content: space-around; }.justify-items-center { justify-items: center; }.gap-1 { @@ -13207,9 +13203,6 @@ video { column-gap: 1.5rem; }.gap-y-8 { row-gap: 2rem; -}.gap-x-12 { - -moz-column-gap: 3rem; - column-gap: 3rem; }.space-x-2 > :not([hidden]) ~ :not([hidden]) { --tw-space-x-reverse: 0; margin-right: calc(0.5rem * var(--tw-space-x-reverse)); @@ -13254,14 +13247,14 @@ video { word-break: break-all; }.rounded { border-radius: 0.25rem; +}.rounded-3xl { + border-radius: 1.5rem; }.rounded-full { border-radius: 9999px; }.rounded-lg { border-radius: 0.5rem; }.rounded-md { border-radius: 0.375rem; -}.rounded-3xl { - border-radius: 1.5rem; }.rounded-b-none { border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; @@ -13316,12 +13309,12 @@ video { border-color: rgb(185 28 28 / var(--tw-border-opacity)); }.border-transparent { border-color: transparent; +}.bg-\[\#019a3e\] { + --tw-bg-opacity: 1; + background-color: rgb(1 154 62 / var(--tw-bg-opacity)); }.bg-blue-500 { --tw-bg-opacity: 1; background-color: rgb(59 130 246 / var(--tw-bg-opacity)); -}.bg-blue-600 { - --tw-bg-opacity: 1; - background-color: rgb(37 99 235 / var(--tw-bg-opacity)); }.bg-gray-100 { --tw-bg-opacity: 1; background-color: rgb(243 244 246 / var(--tw-bg-opacity)); @@ -13370,12 +13363,12 @@ video { }.bg-red-700 { --tw-bg-opacity: 1; background-color: rgb(185 28 28 / var(--tw-bg-opacity)); -}.bg-white { - --tw-bg-opacity: 1; - background-color: rgb(255 255 255 / var(--tw-bg-opacity)); }.bg-slate-400 { --tw-bg-opacity: 1; background-color: rgb(148 163 184 / var(--tw-bg-opacity)); +}.bg-white { + --tw-bg-opacity: 1; + background-color: rgb(255 255 255 / var(--tw-bg-opacity)); }.bg-opacity-25 { --tw-bg-opacity: 0.25; }.bg-cover { @@ -13531,10 +13524,10 @@ video { vertical-align: bottom; }.font-mono { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; -}.font-sans { - font-family: Figtree, ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; }.font-mulish { font-family: Mulish, ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; +}.font-sans { + font-family: Figtree, ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; }.text-2xl { font-size: 1.5rem; line-height: 2rem; @@ -13707,11 +13700,11 @@ video { }.ring-gray-300 { --tw-ring-opacity: 1; --tw-ring-color: rgb(209 213 219 / var(--tw-ring-opacity)); +}.ring-gray-900\/5 { + --tw-ring-color: rgb(17 24 39 / 0.05); }.ring-red-500 { --tw-ring-opacity: 1; --tw-ring-color: rgb(239 68 68 / var(--tw-ring-opacity)); -}.ring-gray-900\/5 { - --tw-ring-color: rgb(17 24 39 / 0.05); }.ring-opacity-5 { --tw-ring-opacity: 0.05; }.blur { @@ -13788,9 +13781,6 @@ video { }.hover\:border-gray-300:hover { --tw-border-opacity: 1; border-color: rgb(209 213 219 / var(--tw-border-opacity)); -}.hover\:bg-blue-500:hover { - --tw-bg-opacity: 1; - background-color: rgb(59 130 246 / var(--tw-bg-opacity)); }.hover\:bg-blue-600:hover { --tw-bg-opacity: 1; background-color: rgb(37 99 235 / var(--tw-bg-opacity)); @@ -13924,6 +13914,9 @@ video { }.focus\:ring-blue-200:focus { --tw-ring-opacity: 1; --tw-ring-color: rgb(191 219 254 / var(--tw-ring-opacity)); +}.focus\:ring-blue-500:focus { + --tw-ring-opacity: 1; + --tw-ring-color: rgb(59 130 246 / var(--tw-ring-opacity)); }.focus\:ring-blue-600:focus { --tw-ring-opacity: 1; --tw-ring-color: rgb(37 99 235 / var(--tw-ring-opacity)); @@ -13936,18 +13929,12 @@ video { }.focus\:ring-indigo-500:focus { --tw-ring-opacity: 1; --tw-ring-color: rgb(99 102 241 / var(--tw-ring-opacity)); -}.focus\:ring-indigo-600:focus { - --tw-ring-opacity: 1; - --tw-ring-color: rgb(79 70 229 / var(--tw-ring-opacity)); }.focus\:ring-red-200:focus { --tw-ring-opacity: 1; --tw-ring-color: rgb(254 202 202 / var(--tw-ring-opacity)); }.focus\:ring-red-500:focus { --tw-ring-opacity: 1; --tw-ring-color: rgb(239 68 68 / var(--tw-ring-opacity)); -}.focus\:ring-blue-500:focus { - --tw-ring-opacity: 1; - --tw-ring-color: rgb(59 130 246 / var(--tw-ring-opacity)); }.focus\:ring-opacity-50:focus { --tw-ring-opacity: 0.5; }.focus\:ring-offset-2:focus { @@ -13997,6 +13984,8 @@ video { grid-column: span 3 / span 3; }.sm\:col-span-4 { grid-column: span 4 / span 4; + }.sm\:col-span-6 { + grid-column: span 6 / span 6; }.sm\:-my-px { margin-top: -1px; margin-bottom: -1px; diff --git a/public/css/registration.css b/public/css/registration.css index 9edf0cf..c876b1f 100644 --- a/public/css/registration.css +++ b/public/css/registration.css @@ -1720,10 +1720,6 @@ select { .gap-6 { gap: 1.5rem; } -.gap-x-12 { - -moz-column-gap: 3rem; - column-gap: 3rem; -} .gap-x-6 { -moz-column-gap: 1.5rem; column-gap: 1.5rem; @@ -1879,14 +1875,14 @@ select { .border-transparent { border-color: transparent; } +.bg-\[\#019a3e\] { + --tw-bg-opacity: 1; + background-color: rgb(1 154 62 / var(--tw-bg-opacity)); +} .bg-blue-500 { --tw-bg-opacity: 1; background-color: rgb(59 130 246 / var(--tw-bg-opacity)); } -.bg-blue-600 { - --tw-bg-opacity: 1; - background-color: rgb(37 99 235 / var(--tw-bg-opacity)); -} .bg-gray-100 { --tw-bg-opacity: 1; background-color: rgb(243 244 246 / var(--tw-bg-opacity)); @@ -2558,11 +2554,6 @@ select { border-color: rgb(209 213 219 / var(--tw-border-opacity)); } -.hover\:bg-blue-500:hover { - --tw-bg-opacity: 1; - background-color: rgb(59 130 246 / var(--tw-bg-opacity)); -} - .hover\:bg-blue-600:hover { --tw-bg-opacity: 1; background-color: rgb(37 99 235 / var(--tw-bg-opacity)); @@ -2784,6 +2775,11 @@ select { --tw-ring-color: rgb(191 219 254 / var(--tw-ring-opacity)); } +.focus\:ring-blue-500:focus { + --tw-ring-opacity: 1; + --tw-ring-color: rgb(59 130 246 / var(--tw-ring-opacity)); +} + .focus\:ring-blue-600:focus { --tw-ring-opacity: 1; --tw-ring-color: rgb(37 99 235 / var(--tw-ring-opacity)); @@ -2804,11 +2800,6 @@ select { --tw-ring-color: rgb(99 102 241 / var(--tw-ring-opacity)); } -.focus\:ring-indigo-600:focus { - --tw-ring-opacity: 1; - --tw-ring-color: rgb(79 70 229 / var(--tw-ring-opacity)); -} - .focus\:ring-red-200:focus { --tw-ring-opacity: 1; --tw-ring-color: rgb(254 202 202 / var(--tw-ring-opacity)); @@ -2819,11 +2810,6 @@ select { --tw-ring-color: rgb(239 68 68 / var(--tw-ring-opacity)); } -.focus\:ring-blue-500:focus { - --tw-ring-opacity: 1; - --tw-ring-color: rgb(59 130 246 / var(--tw-ring-opacity)); -} - .focus\:ring-opacity-50:focus { --tw-ring-opacity: 0.5; } @@ -2915,6 +2901,10 @@ select { grid-column: span 4 / span 4; } + .sm\:col-span-6 { + grid-column: span 6 / span 6; + } + .sm\:-my-px { margin-top: -1px; margin-bottom: -1px; diff --git a/resources/views/livewire/registration/step2.blade.php b/resources/views/livewire/registration/step2.blade.php index ba8a984..c70c1e8 100644 --- a/resources/views/livewire/registration/step2.blade.php +++ b/resources/views/livewire/registration/step2.blade.php @@ -100,22 +100,25 @@ -