app/View/Components: minor fixes.
This commit is contained in:
parent
766da19bb5
commit
e4363c078a
4 changed files with 16 additions and 6 deletions
|
|
@ -6,5 +6,5 @@ use Illuminate\View\Component;
|
|||
|
||||
class ClassIcon extends Icon
|
||||
{
|
||||
protected $prefix = 'classes';
|
||||
protected string $prefix = 'classes';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,5 +4,5 @@ namespace App\View\Components;
|
|||
|
||||
class ProfessionIcon extends Icon
|
||||
{
|
||||
protected $prefix = 'professions';
|
||||
protected string $prefix = 'professions';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ use Illuminate\Support\Str;
|
|||
|
||||
class RaceIcon extends Icon
|
||||
{
|
||||
protected $prefix = 'races';
|
||||
protected string $prefix = 'races';
|
||||
|
||||
/**
|
||||
* Create a new component instance.
|
||||
|
|
|
|||
Reference in a new issue