diff --git a/app/Http/Controllers/ConsultantDiaryCommentController.php b/app/Http/Controllers/ConsultantDiaryCommentController.php new file mode 100644 index 0000000..07b65d1 --- /dev/null +++ b/app/Http/Controllers/ConsultantDiaryCommentController.php @@ -0,0 +1,106 @@ + 1, + 'diary' => $diary, + ]; + return view('diary.consultant_comments', $data); + } + + /** + * Show the form for editing the specified resource. + * + * @param \App\Models\Diary $diary + * @return \Illuminate\Http\Response + */ + public function edit(Diary $diary) + { + $curMeals = $diary->meals()->orderBy('type')->get(); + $typeNames = [ + __('diary.breakfast'), + __('diary.dinner'), + __('diary.supper'), + __('diary.lunch'), + __('diary.snacks') + ]; + + $data = [ + 'daysCount' => 1, + 'diary' => $diary, + 'curDiary' => $diary, + 'curMeals' => $curMeals, + 'typeNames' => $typeNames, + ]; + return view('diary.consultant_comments_edit', $data); + } + + /** + * Update the specified resource in storage. + * + * @param \Illuminate\Http\Request $request + * @param \App\Models\Diary $diary + * @return \Illuminate\Http\Response + */ + public function update(Request $request, Diary $diary) + { + // + } + + /** + * Remove the specified resource from storage. + * + * @param \App\Models\Diary $consultantDiaryComment + * @return \Illuminate\Http\Response + */ + public function destroy(Diary $diary) + { + // + } +} diff --git a/app/Http/Controllers/DiaryController.php b/app/Http/Controllers/DiaryController.php index 0eb1a17..ecd49a5 100644 --- a/app/Http/Controllers/DiaryController.php +++ b/app/Http/Controllers/DiaryController.php @@ -114,6 +114,7 @@ class DiaryController extends Controller $curDiary = Diary::find($id); $curDiary->wakeup = $request->input('wakeup'); $curDiary->retire = $request->input('retire'); + $curDiary->comment = $request->input('comment') ?? ''; $curDiary->closed = true; $curDiary->save(); return redirect()->route('diary.show', $id); diff --git a/app/Http/Livewire/Diary/ConsultantCommentsEdit.php b/app/Http/Livewire/Diary/ConsultantCommentsEdit.php new file mode 100644 index 0000000..7396ae5 --- /dev/null +++ b/app/Http/Livewire/Diary/ConsultantCommentsEdit.php @@ -0,0 +1,61 @@ +comments = (new ConsultantDiaryComment())->where( + 'user_id', + Auth::id() + )->where( + 'diary_id', + $this->diary->id + )->pluck('comment', 'comment_type')->toArray(); + } + + public function render() + { + $commentTypes = ['breakfast', 'dinner', 'supper', 'lunch', 'snacks', 'wakeup_time', 'total']; + + return view( + 'livewire.diary.consultant-comments-edit', + [ + 'commentTypes' => $commentTypes, + ] + ); + } + + public function save() + { + foreach($this->comments as $key => $comment) { + $updateComment = ConsultantDiaryComment::updateOrCreate( + [ + 'user_id' => Auth::id(), + 'diary_id' => $this->diary->id, + 'comment_type' => $key, + ], + ['comment' => $comment] + ); + $updateComment->save(); + } + } +} diff --git a/app/Models/ConsultantDiaryComment.php b/app/Models/ConsultantDiaryComment.php new file mode 100644 index 0000000..8ecbc0e --- /dev/null +++ b/app/Models/ConsultantDiaryComment.php @@ -0,0 +1,14 @@ +2.2,<2.4" + }, + "require-dev": { + "cache/integration-tests": "dev-master", + "doctrine/coding-standard": "^9", + "phpunit/phpunit": "^7.5 || ^8.5 || ^9.5", + "psr/cache": "^1.0 || ^2.0 || ^3.0", + "symfony/cache": "^4.4 || ^5.4 || ^6", + "symfony/var-exporter": "^4.4 || ^5.4 || ^6" + }, + "type": "library", + "autoload": { + "psr-4": { + "Doctrine\\Common\\Cache\\": "lib/Doctrine/Common/Cache" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com" + }, + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com" + } + ], + "description": "PHP Doctrine Cache library is a popular cache implementation that supports many different drivers such as redis, memcache, apc, mongodb and others.", + "homepage": "https://www.doctrine-project.org/projects/cache.html", + "keywords": [ + "abstraction", + "apcu", + "cache", + "caching", + "couchdb", + "memcached", + "php", + "redis", + "xcache" + ], + "support": { + "issues": "https://github.com/doctrine/cache/issues", + "source": "https://github.com/doctrine/cache/tree/2.2.0" + }, + "funding": [ + { + "url": "https://www.doctrine-project.org/sponsorship.html", + "type": "custom" + }, + { + "url": "https://www.patreon.com/phpdoctrine", + "type": "patreon" + }, + { + "url": "https://tidelift.com/funding/github/packagist/doctrine%2Fcache", + "type": "tidelift" + } + ], + "time": "2022-05-20T20:07:39+00:00" + }, + { + "name": "doctrine/dbal", + "version": "3.3.6", + "source": { + "type": "git", + "url": "https://github.com/doctrine/dbal.git", + "reference": "9e7f76dd1cde81c62574fdffa5a9c655c847ad21" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/dbal/zipball/9e7f76dd1cde81c62574fdffa5a9c655c847ad21", + "reference": "9e7f76dd1cde81c62574fdffa5a9c655c847ad21", + "shasum": "" + }, + "require": { + "composer-runtime-api": "^2", + "doctrine/cache": "^1.11|^2.0", + "doctrine/deprecations": "^0.5.3|^1", + "doctrine/event-manager": "^1.0", + "php": "^7.3 || ^8.0", + "psr/cache": "^1|^2|^3", + "psr/log": "^1|^2|^3" + }, + "require-dev": { + "doctrine/coding-standard": "9.0.0", + "jetbrains/phpstorm-stubs": "2022.1", + "phpstan/phpstan": "1.6.3", + "phpstan/phpstan-strict-rules": "^1.2", + "phpunit/phpunit": "9.5.20", + "psalm/plugin-phpunit": "0.16.1", + "squizlabs/php_codesniffer": "3.6.2", + "symfony/cache": "^5.2|^6.0", + "symfony/console": "^2.7|^3.0|^4.0|^5.0|^6.0", + "vimeo/psalm": "4.23.0" + }, + "suggest": { + "symfony/console": "For helpful console commands such as SQL execution and import of files." + }, + "bin": [ + "bin/doctrine-dbal" + ], + "type": "library", + "autoload": { + "psr-4": { + "Doctrine\\DBAL\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com" + } + ], + "description": "Powerful PHP database abstraction layer (DBAL) with many features for database schema introspection and management.", + "homepage": "https://www.doctrine-project.org/projects/dbal.html", + "keywords": [ + "abstraction", + "database", + "db2", + "dbal", + "mariadb", + "mssql", + "mysql", + "oci8", + "oracle", + "pdo", + "pgsql", + "postgresql", + "queryobject", + "sasql", + "sql", + "sqlite", + "sqlserver", + "sqlsrv" + ], + "support": { + "issues": "https://github.com/doctrine/dbal/issues", + "source": "https://github.com/doctrine/dbal/tree/3.3.6" + }, + "funding": [ + { + "url": "https://www.doctrine-project.org/sponsorship.html", + "type": "custom" + }, + { + "url": "https://www.patreon.com/phpdoctrine", + "type": "patreon" + }, + { + "url": "https://tidelift.com/funding/github/packagist/doctrine%2Fdbal", + "type": "tidelift" + } + ], + "time": "2022-05-02T17:21:01+00:00" + }, + { + "name": "doctrine/deprecations", + "version": "v1.0.0", + "source": { + "type": "git", + "url": "https://github.com/doctrine/deprecations.git", + "reference": "0e2a4f1f8cdfc7a92ec3b01c9334898c806b30de" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/deprecations/zipball/0e2a4f1f8cdfc7a92ec3b01c9334898c806b30de", + "reference": "0e2a4f1f8cdfc7a92ec3b01c9334898c806b30de", + "shasum": "" + }, + "require": { + "php": "^7.1|^8.0" + }, + "require-dev": { + "doctrine/coding-standard": "^9", + "phpunit/phpunit": "^7.5|^8.5|^9.5", + "psr/log": "^1|^2|^3" + }, + "suggest": { + "psr/log": "Allows logging deprecations via PSR-3 logger implementation" + }, + "type": "library", + "autoload": { + "psr-4": { + "Doctrine\\Deprecations\\": "lib/Doctrine/Deprecations" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "A small layer on top of trigger_error(E_USER_DEPRECATED) or PSR-3 logging with options to disable all deprecations or selectively for packages.", + "homepage": "https://www.doctrine-project.org/", + "support": { + "issues": "https://github.com/doctrine/deprecations/issues", + "source": "https://github.com/doctrine/deprecations/tree/v1.0.0" + }, + "time": "2022-05-02T15:47:09+00:00" + }, + { + "name": "doctrine/event-manager", + "version": "1.1.1", + "source": { + "type": "git", + "url": "https://github.com/doctrine/event-manager.git", + "reference": "41370af6a30faa9dc0368c4a6814d596e81aba7f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/event-manager/zipball/41370af6a30faa9dc0368c4a6814d596e81aba7f", + "reference": "41370af6a30faa9dc0368c4a6814d596e81aba7f", + "shasum": "" + }, + "require": { + "php": "^7.1 || ^8.0" + }, + "conflict": { + "doctrine/common": "<2.9@dev" + }, + "require-dev": { + "doctrine/coding-standard": "^6.0", + "phpunit/phpunit": "^7.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Doctrine\\Common\\": "lib/Doctrine/Common" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com" + }, + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com" + }, + { + "name": "Marco Pivetta", + "email": "ocramius@gmail.com" + } + ], + "description": "The Doctrine Event Manager is a simple PHP event system that was built to be used with the various Doctrine projects.", + "homepage": "https://www.doctrine-project.org/projects/event-manager.html", + "keywords": [ + "event", + "event dispatcher", + "event manager", + "event system", + "events" + ], + "support": { + "issues": "https://github.com/doctrine/event-manager/issues", + "source": "https://github.com/doctrine/event-manager/tree/1.1.x" + }, + "funding": [ + { + "url": "https://www.doctrine-project.org/sponsorship.html", + "type": "custom" + }, + { + "url": "https://www.patreon.com/phpdoctrine", + "type": "patreon" + }, + { + "url": "https://tidelift.com/funding/github/packagist/doctrine%2Fevent-manager", + "type": "tidelift" + } + ], + "time": "2020-05-29T18:28:51+00:00" + }, { "name": "doctrine/inflector", "version": "2.0.4", @@ -2975,6 +3316,55 @@ }, "time": "2020-04-05T10:47:18+00:00" }, + { + "name": "psr/cache", + "version": "3.0.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/cache.git", + "reference": "aa5030cfa5405eccfdcb1083ce040c2cb8d253bf" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/cache/zipball/aa5030cfa5405eccfdcb1083ce040c2cb8d253bf", + "reference": "aa5030cfa5405eccfdcb1083ce040c2cb8d253bf", + "shasum": "" + }, + "require": { + "php": ">=8.0.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Cache\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "Common interface for caching libraries", + "keywords": [ + "cache", + "psr", + "psr-6" + ], + "support": { + "source": "https://github.com/php-fig/cache/tree/3.0.0" + }, + "time": "2021-02-03T23:26:27+00:00" + }, { "name": "psr/container", "version": "2.0.2", diff --git a/database/migrations/2022_06_03_085504_create_consultant_diary_comments_table.php b/database/migrations/2022_06_03_085504_create_consultant_diary_comments_table.php new file mode 100644 index 0000000..1b8960f --- /dev/null +++ b/database/migrations/2022_06_03_085504_create_consultant_diary_comments_table.php @@ -0,0 +1,35 @@ +id(); + $table->bigInteger('user_id')->comment('consultant id'); + $table->bigInteger('diary_id'); + $table->string('comment_type', 128); + $table->text('comment'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('consultant_diary_comments'); + } +}; diff --git a/database/migrations/2022_06_03_131304_add_comment_to_diaries.php b/database/migrations/2022_06_03_131304_add_comment_to_diaries.php new file mode 100644 index 0000000..b71057b --- /dev/null +++ b/database/migrations/2022_06_03_131304_add_comment_to_diaries.php @@ -0,0 +1,32 @@ +text('comment'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('diaries', function (Blueprint $table) { + $table->dropColumn('comment'); + }); + } +}; diff --git a/lang/en/diary.php b/lang/en/diary.php new file mode 100644 index 0000000..715124d --- /dev/null +++ b/lang/en/diary.php @@ -0,0 +1,9 @@ + 'Breakfast', + 'dinner' => 'Dinner', + 'supper' => 'Supper', + 'lunch' => 'Lunch', + 'snacks' => 'Snacks', +]; diff --git a/lang/ru/diary.php b/lang/ru/diary.php new file mode 100644 index 0000000..f79a82b --- /dev/null +++ b/lang/ru/diary.php @@ -0,0 +1,9 @@ + 'Завтрaк', + 'dinner' => 'Обед', + 'supper' => 'Ужин', + 'lunch,' => 'Ланч', + 'snacks' => 'Перекусы', +]; diff --git a/public/img/icons/addmeasure.svg b/public/img/icons/addmeasure.svg new file mode 100644 index 0000000..91fc3cd --- /dev/null +++ b/public/img/icons/addmeasure.svg @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + diff --git a/public/img/icons/addweight.svg b/public/img/icons/addweight.svg new file mode 100644 index 0000000..5b82392 --- /dev/null +++ b/public/img/icons/addweight.svg @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + diff --git a/resources/views/diary/consultant_comments.blade.php b/resources/views/diary/consultant_comments.blade.php new file mode 100644 index 0000000..d9cfac6 --- /dev/null +++ b/resources/views/diary/consultant_comments.blade.php @@ -0,0 +1,77 @@ +@extends('layouts/eatvio') + +@section('main_section') +@php + $curDiary = $diary; + $curMeals = $curDiary->meals()->orderBy('type')->get(); + $typeNames = ['Завтрaк', 'Обед', 'Ужин', 'Ланч', 'Перекусы']; +@endphp + +
+
+ Календарь +
+ +
{{ $curDiary->date }}
+
+
+ +
+
+

Проснулись

+
+ + {{ $curDiary->wakeup }} +
+
+
+

Легли спать

+
+ + {{ $curDiary->retire }} +
+
+
+ @foreach($curMeals as $key => $meal) +
+
+

{{ $typeNames[$meal->type] }}

+
+
+ Сытность:{{ $meal->satiety }} +
+
+ Настроение:{{ $meal->mood }} +
+
+ + {{ $meal->time }} +
+
+
+ @if(count($meal->portions)) +
+
+
+ + @foreach($meal->portions as $portion) + + + + + @endforeach +
{{ $portion->product_name }}{{ $portion->quantity }} {{ $portion->portion }}
+
+
+
+ @endif +
+ @endforeach + +
+ РЕДАКТИРОВАТЬ ДЕНЬ +
+ + +
+@endsection diff --git a/resources/views/diary/consultant_comments_edit.blade.php b/resources/views/diary/consultant_comments_edit.blade.php new file mode 100644 index 0000000..9ef4dbf --- /dev/null +++ b/resources/views/diary/consultant_comments_edit.blade.php @@ -0,0 +1,9 @@ +@extends('layouts/eatvio') +@section('main_section') + +@endsection diff --git a/resources/views/diary/index.blade.php b/resources/views/diary/index.blade.php index 9d3cc28..5c021a4 100644 --- a/resources/views/diary/index.blade.php +++ b/resources/views/diary/index.blade.php @@ -31,6 +31,13 @@ @livewire('meal-form', ['diaryId' => $diaryId]) +
+ +

Дополнительная информация для консультанта

+ +
+
+
diff --git a/resources/views/diary/show.blade.php b/resources/views/diary/show.blade.php index 1dfdf6a..22c3d0d 100644 --- a/resources/views/diary/show.blade.php +++ b/resources/views/diary/show.blade.php @@ -67,6 +67,13 @@ @endforeach +
+ +

Дополнительная информация:

+
{{ $curDiary->comment ?? '' }}
+
+
+
РЕДАКТИРОВАТЬ ДЕНЬ
diff --git a/resources/views/livewire/diary/consultant-comments-edit.blade.php b/resources/views/livewire/diary/consultant-comments-edit.blade.php new file mode 100644 index 0000000..8369fb4 --- /dev/null +++ b/resources/views/livewire/diary/consultant-comments-edit.blade.php @@ -0,0 +1,89 @@ +
+ + +
+
+

Проснулись

+
+ + {{ $diary->wakeup }} +
+
+
+

Легли спать

+
+ + {{ $diary->retire }} +
+
+
+ +
+
+ + @foreach($curMeals as $key => $meal) +
+
+

{{ $typeNames[$meal->type] }}

+
+
+ Сытность:{{ $meal->satiety }} +
+
+ Настроение:{{ $meal->mood }} +
+
+ + {{ $meal->time }} +
+
+
+ @if(count($meal->portions)) +
+
+
+ + @foreach($meal->portions as $portion) + + + + + @endforeach +
{{ $portion->product_name }}{{ $portion->quantity }} {{ $portion->portion }}
+
+
+
+ @endif +
+ @if(count($meal->portions)) +
+ +
+ @endif + @endforeach +
+ +

Дополнительная информация:

+
{{ $diary->comment }}
+
+
+ +
+ +
+ + + +
+ diff --git a/resources/views/livewire/profile/circumference-chart.blade.php b/resources/views/livewire/profile/circumference-chart.blade.php index 0b2ce8f..7607616 100644 --- a/resources/views/livewire/profile/circumference-chart.blade.php +++ b/resources/views/livewire/profile/circumference-chart.blade.php @@ -1,5 +1,5 @@
-
+
{{ __('profile.circumference') }}:
{{ __('profile.chest') }}:{{ $lastOneMisure->chest_circumference ?? '0' }} @@ -7,11 +7,9 @@ {{ __('profile.hips') }}:{{ $lastOneMisure->hip_circumference ?? '0'}}
-
- -
diff --git a/resources/views/livewire/profile/weight-chart.blade.php b/resources/views/livewire/profile/weight-chart.blade.php index ead6a34..8fcec49 100644 --- a/resources/views/livewire/profile/weight-chart.blade.php +++ b/resources/views/livewire/profile/weight-chart.blade.php @@ -1,16 +1,14 @@
-
+
{{ __('profile.weight') }}:
{{ __('profile.was') }}:{{ $user->weight_measures()->get()->first()->weight ?? '0' }} {{ __('profile.became') }}:{{ $user->weight_measures()->get()->last()->weight ?? '0' }}
-
- -
+
diff --git a/routes/web.php b/routes/web.php index 5de81d8..1a057ae 100644 --- a/routes/web.php +++ b/routes/web.php @@ -2,6 +2,7 @@ use App\Http\Controllers\DiaryController; use App\Http\Controllers\CalendarController; +use App\Http\Controllers\ConsultantDiaryCommentController; use App\Http\Controllers\ProfileController; use App\Http\Controllers\UserDetailzController; use App\Http\Controllers\UserController; @@ -59,5 +60,11 @@ Route::group([ 'consultant_request' => 'user' ] ); + Route::resource('consultant_diary_comment', ConsultantDiaryCommentController::class) + ->parameters( + [ + 'consultant_diary_comment' => 'diary' + ] + ); }); });