mirror of
https://github.com/pelican-dev/panel.git
synced 2025-05-29 13:14:45 +02:00
Fix faker
This commit is contained in:
parent
102955bf6a
commit
0c7ae26313
@ -7,6 +7,7 @@ use App\Models\Allocation;
|
|||||||
use App\Models\Egg;
|
use App\Models\Egg;
|
||||||
use App\Models\Node;
|
use App\Models\Node;
|
||||||
use App\Services\Allocations\AssignmentService;
|
use App\Services\Allocations\AssignmentService;
|
||||||
|
use App\Services\Servers\RandomWordService;
|
||||||
use App\Services\Servers\ServerCreationService;
|
use App\Services\Servers\ServerCreationService;
|
||||||
use Filament\Forms\Form;
|
use Filament\Forms\Form;
|
||||||
use Filament\Resources\Pages\CreateRecord;
|
use Filament\Resources\Pages\CreateRecord;
|
||||||
@ -45,7 +46,9 @@ class CreateServer extends CreateRecord
|
|||||||
$egg = Egg::find($get('egg_id'));
|
$egg = Egg::find($get('egg_id'));
|
||||||
$prefix = $egg ? str($egg->name)->lower()->kebab() . '-' : '';
|
$prefix = $egg ? str($egg->name)->lower()->kebab() . '-' : '';
|
||||||
|
|
||||||
$set('name', $prefix . fake()->domainWord);
|
$word = (new RandomWordService())->word();
|
||||||
|
|
||||||
|
$set('name', $prefix . $word);
|
||||||
}))
|
}))
|
||||||
->columnSpan([
|
->columnSpan([
|
||||||
'default' => 2,
|
'default' => 2,
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
namespace App\Filament\Resources\ServerResource\Pages;
|
namespace App\Filament\Resources\ServerResource\Pages;
|
||||||
|
|
||||||
use App\Filament\Resources\ServerResource;
|
use App\Filament\Resources\ServerResource;
|
||||||
|
use App\Services\Servers\RandomWordService;
|
||||||
use Filament\Actions;
|
use Filament\Actions;
|
||||||
use Filament\Forms;
|
use Filament\Forms;
|
||||||
use App\Enums\ContainerStatus;
|
use App\Enums\ContainerStatus;
|
||||||
@ -94,7 +95,9 @@ class EditServer extends EditRecord
|
|||||||
$egg = Egg::find($get('egg_id'));
|
$egg = Egg::find($get('egg_id'));
|
||||||
$prefix = $egg ? str($egg->name)->lower()->kebab() . '-' : '';
|
$prefix = $egg ? str($egg->name)->lower()->kebab() . '-' : '';
|
||||||
|
|
||||||
$set('name', $prefix . fake()->domainWord);
|
$word = (new RandomWordService())->word();
|
||||||
|
|
||||||
|
$set('name', $prefix . $word);
|
||||||
}))
|
}))
|
||||||
->columnSpan([
|
->columnSpan([
|
||||||
'default' => 2,
|
'default' => 2,
|
||||||
|
19
app/Services/Servers/RandomWordService.php
Normal file
19
app/Services/Servers/RandomWordService.php
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Services\Servers;
|
||||||
|
|
||||||
|
class RandomWordService
|
||||||
|
{
|
||||||
|
private const RANDOM_WORDS = [
|
||||||
|
'robin', 'seagull', 'pigeon', 'blue-jay', 'vulture', 'finch', 'falcon', 'phoenix', 'squirrel', 'parrot', 'hawk',
|
||||||
|
'sparrow', 'owl', 'swan', 'dove', 'cardinal', 'cow', 'penguin', 'chupacabra', 'spoonbill', 'humming', 'turkey',
|
||||||
|
'chicken', 'junco', 'eagle', 'woodpecker', 'mockingbird', 'grackle', 'lovebird', 'bluebird', 'magpie', 'starling',
|
||||||
|
'cockatiel', 'swallow', 'grosbeak', 'goose', 'forpus', 'budgerigar', 'mango', 'towhee', 'warbler', 'peregrine',
|
||||||
|
'nuthatch', 'chickadee', 'bananaquit', 'crow', 'raven', 'merlin', 'spatuletail',
|
||||||
|
];
|
||||||
|
|
||||||
|
public function word(): string
|
||||||
|
{
|
||||||
|
return array_random(self::RANDOM_WORDS);
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user