Formatting fixes.
This commit is contained in:
parent
0437947c82
commit
86b9f3d2f0
7 changed files with 161 additions and 161 deletions
|
|
@ -9,62 +9,62 @@ use App\Models\Wow;
|
|||
|
||||
class CardForm extends ModelForm
|
||||
{
|
||||
/**
|
||||
* Array of available characters
|
||||
*/
|
||||
public $characters;
|
||||
/**
|
||||
* Array of available characters
|
||||
*/
|
||||
public $characters;
|
||||
|
||||
/**
|
||||
* Array of available raids
|
||||
*/
|
||||
public $raids;
|
||||
/**
|
||||
* Array of available raids
|
||||
*/
|
||||
public $raids;
|
||||
|
||||
/**
|
||||
* Redirect after this route after record was created.
|
||||
*/
|
||||
public string $redirect_route = 'admin.card.index';
|
||||
/**
|
||||
* Redirect after this route after record was created.
|
||||
*/
|
||||
public string $redirect_route = 'admin.card.index';
|
||||
|
||||
public function mount(Card $card)
|
||||
{
|
||||
$this->record = $card;
|
||||
$this->characters = Character::all()->pluck('name', 'id');
|
||||
$this->raids = Raid::all()->pluck('name', 'id');
|
||||
$this->classes = Wow::$classes;
|
||||
$this->exist = $card->exists;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validation rules
|
||||
*/
|
||||
protected function rules()
|
||||
{
|
||||
return [
|
||||
'record.body' => 'required|string|min:3|max:200',
|
||||
'record.character_id' => 'exists:' . Character::class . ',id|nullable',
|
||||
'record.raid_id' => 'exists:' . Raid::class . ',id|nullable',
|
||||
'record.class' => 'in:' . collect($this->classes)->keys() . '|nullable',
|
||||
];
|
||||
}
|
||||
|
||||
public function updated($property, $value)
|
||||
public function mount(Card $card)
|
||||
{
|
||||
// Hack to force empty value to null.
|
||||
if (in_array($property, ['record.character_id', 'record.raid_id', 'record.class'])) {
|
||||
if (empty($value)) {
|
||||
$this->{$property} = null;
|
||||
}
|
||||
}
|
||||
$this->record = $card;
|
||||
$this->characters = Character::all()->pluck('name', 'id');
|
||||
$this->raids = Raid::all()->pluck('name', 'id');
|
||||
$this->classes = Wow::$classes;
|
||||
$this->exist = $card->exists;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validation rules
|
||||
*/
|
||||
protected function rules()
|
||||
{
|
||||
return [
|
||||
'record.body' => 'required|string|min:3|max:200',
|
||||
'record.character_id' => 'exists:' . Character::class . ',id|nullable',
|
||||
'record.raid_id' => 'exists:' . Raid::class . ',id|nullable',
|
||||
'record.class' => 'in:' . collect($this->classes)->keys() . '|nullable',
|
||||
];
|
||||
}
|
||||
|
||||
public function updated($property, $value)
|
||||
{
|
||||
// Hack to force empty value to null.
|
||||
if (in_array($property, ['record.character_id', 'record.raid_id', 'record.class'])) {
|
||||
if (empty($value)) {
|
||||
$this->{$property} = null;
|
||||
}
|
||||
}
|
||||
|
||||
$this->validateOnly($property);
|
||||
}
|
||||
|
||||
public function getSubjectProperty()
|
||||
{
|
||||
if ($this->record->character_id) {
|
||||
return $this->characters[$this->record->character_id];
|
||||
} else if ($this->record->class) {
|
||||
return $this->classes[$this->record->class];
|
||||
}
|
||||
return "Somebody";
|
||||
}
|
||||
public function getSubjectProperty()
|
||||
{
|
||||
if ($this->record->character_id) {
|
||||
return $this->characters[$this->record->character_id];
|
||||
} else if ($this->record->class) {
|
||||
return $this->classes[$this->record->class];
|
||||
}
|
||||
return "Somebody";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Reference in a new issue