Otherwise phpstorm doesn't understand the paths correctly. He thinks that this is not a complete application, but a package. And when creating a class, the namespace indicates “app” with a small letter, but should be “App”.
		
			
				
	
	
		
			47 lines
		
	
	
		
			948 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			47 lines
		
	
	
		
			948 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
<?php declare(strict_types=1);
 | 
						|
 | 
						|
namespace App\Enums;
 | 
						|
 | 
						|
use Illuminate\Support\Collection;
 | 
						|
 | 
						|
enum Lang: int
 | 
						|
{
 | 
						|
    case Ru = 1;
 | 
						|
    case En = 2;
 | 
						|
 | 
						|
    public function getTitle(): string
 | 
						|
    {
 | 
						|
        return match ($this) {
 | 
						|
            self::Ru => 'Русский',
 | 
						|
            self::En => 'English'
 | 
						|
        };
 | 
						|
    }
 | 
						|
 | 
						|
    public function getLocale(): string
 | 
						|
    {
 | 
						|
        return match ($this) {
 | 
						|
            self::Ru => 'ru',
 | 
						|
            self::En => 'en'
 | 
						|
        };
 | 
						|
    }
 | 
						|
 | 
						|
    public static function toArray(): array
 | 
						|
    {
 | 
						|
        $choices = [];
 | 
						|
        foreach (self::cases() as $lang) {
 | 
						|
            $choices[] = [
 | 
						|
                'name' => $lang->name,
 | 
						|
                'value' => $lang->value,
 | 
						|
                'title' => $lang->getTitle(),
 | 
						|
                'locale' => $lang->getLocale()
 | 
						|
            ];
 | 
						|
        }
 | 
						|
        return $choices;
 | 
						|
    }
 | 
						|
 | 
						|
    public static function toCollection(): Collection
 | 
						|
    {
 | 
						|
        return collect(self::toArray());
 | 
						|
    }
 | 
						|
}
 |