diff --git a/app/Http/Controllers/MonitoringController.php b/app/Http/Controllers/DailyAchievementController.php similarity index 90% rename from app/Http/Controllers/MonitoringController.php rename to app/Http/Controllers/DailyAchievementController.php index 1de3083..6331119 100644 --- a/app/Http/Controllers/MonitoringController.php +++ b/app/Http/Controllers/DailyAchievementController.php @@ -5,7 +5,7 @@ use App\Models\Monitoring; use Illuminate\Http\Request; -class MonitoringController extends Controller +class DailyAchievementController extends Controller { /** * Display index page. @@ -14,7 +14,7 @@ class MonitoringController extends Controller */ public function index() { - return view('monitoring.index'); + return view('monitoring.daily-achievement.index'); } /** @@ -24,7 +24,7 @@ public function index() */ public function create() { - return view('monitoring.create'); + return view('monitoring.daily-achievement.create'); } /** diff --git a/app/Models/Achievement.php b/app/Models/Achievement.php index 2690faa..7b64a54 100644 --- a/app/Models/Achievement.php +++ b/app/Models/Achievement.php @@ -8,7 +8,8 @@ class Achievement extends Model { use HasFactory, - Concerns\Achievement\Attribute; + Concerns\Achievement\Attribute, + Concerns\Achievement\Relation; /** * {@inheritDoc} diff --git a/app/Models/Concerns/Achievement/Relation.php b/app/Models/Concerns/Achievement/Relation.php new file mode 100644 index 0000000..237d7ee --- /dev/null +++ b/app/Models/Concerns/Achievement/Relation.php @@ -0,0 +1,48 @@ +belongsTo(User::class); + } + + /** + * Return \App\Models\User model relation value. + * + * @return \App\Models\User|null + */ + public function getUserRelationValue(): ?User + { + return $this->getRelationValue('user'); + } + + /** + * Set \App\Models\User model relation value. + * + * @param \App\Models\User $user + * @return $this + */ + public function setUserRelationValue(User $user) + { + $this->user()->associate($user); + + return $this; + } +} diff --git a/app/Models/Concerns/Education/Attribute.php b/app/Models/Concerns/Education/Attribute.php deleted file mode 100644 index bf453a7..0000000 --- a/app/Models/Concerns/Education/Attribute.php +++ /dev/null @@ -1,13 +0,0 @@ - $achievements * * @see \App\Models\User */ @@ -26,9 +30,9 @@ public function branch(): BelongsTo /** * Return \App\Models\Branch model relation value. * - * @return \App\Models\Branch + * @return \App\Models\Branch|null */ - public function getBranchRelationValue(): Branch + public function getBranchRelationValue(): ?Branch { return $this->getRelationValue('branch'); } @@ -45,4 +49,39 @@ public function setBranchRelationValue(Branch $branch) return $this; } + + /** + * Define a one-to-many relationship with App\Models\Achievement. + * + * @return \Illuminate\Database\Eloquent\Relations\HasMany + */ + public function achievements(): HasMany + { + return $this->hasMany(Achievement::class); + } + + /** + * Return collection of \App\Models\Achievement model relation value. + * + * @return \Illuminate\Database\Eloquent\Collection<\App\Models\Achievement> + */ + public function getAchievementsRelationValue(): Collection + { + return $this->getCollectionValue('achievements', Achievement::class); + } + + /** + * Set collection of \App\Models\Achievement model relation value. + * + * @param \Illuminate\Database\Eloquent\Collection<\App\Models\Achievement> $achievements + * @return $this + */ + public function setAchievementsRelationValue(Collection $achievements) + { + if ($this->isCollectionValid($achievements, Achievement::class)) { + $this->setRelation('achievements', $achievements); + } + + return $this; + } } diff --git a/app/Models/Education.php b/app/Models/Education.php deleted file mode 100644 index 69f23b3..0000000 --- a/app/Models/Education.php +++ /dev/null @@ -1,19 +0,0 @@ -id(); + $table->foreignIdFor(User::class)->nullable()->constrained()->cascadeOnUpdate()->nullOnDelete(); $table->string('name'); $table->timestamps(); @@ -31,6 +33,6 @@ public function up() */ public function down() { - Schema::dropIfExists('educations'); + Schema::dropIfExists('achievements'); } }; diff --git a/resources/views/components/sidebar.blade.php b/resources/views/components/sidebar.blade.php index b5c7bd4..92fe655 100644 --- a/resources/views/components/sidebar.blade.php +++ b/resources/views/components/sidebar.blade.php @@ -97,8 +97,8 @@