Files
Portfolio-Game/api/app/Models/Skill.php
skycel 4db96a0ded Add skills page with category grouping (Story 2.4)
- Enhance Skill model with getCurrentLevel() and ordered scope
- Update SkillController to group by category with translated labels
- Add level and project_count to SkillResource
- Create skill.ts types (Skill, SkillCategory, SkillsResponse)
- Create useFetchSkills composable
- Create SkillCard component with animated progress bar
- Implement competences.vue with:
  - Responsive grid (2/3/4 columns)
  - Category sections with icons
  - Stagger animations (respects prefers-reduced-motion)
  - Loading/error/empty states
  - Placeholder for vis.js skill tree (Epic 3)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-06 10:37:10 +01:00

47 lines
1.1 KiB
PHP

<?php
namespace App\Models;
use App\Traits\HasTranslations;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
class Skill extends Model
{
use HasTranslations;
protected $fillable = [
'slug',
'name_key',
'description_key',
'icon',
'category',
'max_level',
'display_order',
];
public function projects(): BelongsToMany
{
return $this->belongsToMany(Project::class, 'skill_project')
->withPivot(['level_before', 'level_after', 'level_description_key'])
->withTimestamps();
}
public function scopeByCategory(Builder $query, string $category): Builder
{
return $query->where('category', $category);
}
public function scopeOrdered(Builder $query): Builder
{
return $query->orderBy('category')->orderBy('display_order');
}
public function getCurrentLevel(): int
{
$maxLevelAfter = $this->projects()->max('skill_project.level_after');
return $maxLevelAfter ?? 1;
}
}