diff --git a/app/View/Components/ClassIcon.php b/app/View/Components/ClassIcon.php index af42b9b..8da501d 100644 --- a/app/View/Components/ClassIcon.php +++ b/app/View/Components/ClassIcon.php @@ -6,5 +6,5 @@ use Illuminate\View\Component; class ClassIcon extends Icon { - protected $prefix = 'classes'; + protected string $prefix = 'classes'; } diff --git a/app/View/Components/Icon.php b/app/View/Components/Icon.php index 5089f75..33559dc 100644 --- a/app/View/Components/Icon.php +++ b/app/View/Components/Icon.php @@ -8,9 +8,15 @@ use Illuminate\View\Component; abstract class Icon extends Component { - protected $prefix = ''; + /** + * Path prefix. + */ + protected string $prefix = ''; - public $url; + /** + * Image url. + */ + public string $url; /** * Create a new component instance. @@ -19,7 +25,11 @@ abstract class Icon extends Component */ public function __construct(string $name) { - $file = sprintf('%s/%s.jpg', $this->prefix, Str::lower($name)); + $file = Str::of($name)->lower()->append('.jpg'); + if (strlen($this->prefix)) { + $file = collect([$this->prefix, $file])->join('/'); + } + $this->url = Storage::disk('images')->url($file); } diff --git a/app/View/Components/ProfessionIcon.php b/app/View/Components/ProfessionIcon.php index 416de63..7681781 100644 --- a/app/View/Components/ProfessionIcon.php +++ b/app/View/Components/ProfessionIcon.php @@ -4,5 +4,5 @@ namespace App\View\Components; class ProfessionIcon extends Icon { - protected $prefix = 'professions'; + protected string $prefix = 'professions'; } diff --git a/app/View/Components/RaceIcon.php b/app/View/Components/RaceIcon.php index 1c75ee9..e4e07d9 100644 --- a/app/View/Components/RaceIcon.php +++ b/app/View/Components/RaceIcon.php @@ -7,7 +7,7 @@ use Illuminate\Support\Str; class RaceIcon extends Icon { - protected $prefix = 'races'; + protected string $prefix = 'races'; /** * Create a new component instance.