Archived
1
0
Fork 0

Formatting fixes.

This commit is contained in:
Henrik Hautakoski 2023-02-19 13:56:09 +01:00
parent 0437947c82
commit 86b9f3d2f0
7 changed files with 161 additions and 161 deletions

View file

@ -9,68 +9,68 @@ use Illuminate\Support\Str;
abstract class ModelForm extends Component
{
use Alert;
use Alert;
/**
* The model record
*/
public $record;
/**
* The model record
*/
public $record;
/**
* True if the record already exists in the database.
*/
public bool $exist;
/**
* True if the record already exists in the database.
*/
public bool $exist;
/**
* Redirect after this route after record was created.
*/
public string $redirect_route;
/**
* Redirect after this route after record was created.
*/
public string $redirect_route;
/**
* Get the name of the model
*/
public function getModelName() : string
{
return Str::afterLast(get_class($this->record), '\\');
}
/**
* Get the name of the model
*/
public function getModelName(): string
{
return Str::afterLast(get_class($this->record), '\\');
}
public function updated($property, $value)
public function updated($property, $value)
{
$this->validateOnly($property);
}
/**
* Returns true if this record has not been stored in the database.
*/
public function isNew() : bool
{
return !$this->exist;
}
/**
* Returns true if this record has not been stored in the database.
*/
public function isNew(): bool
{
return !$this->exist;
}
/**
* Submit the form, create/update record.
*/
public function submit()
{
$this->validate();
$this->record->save();
/**
* Submit the form, create/update record.
*/
public function submit()
{
$this->validate();
$this->record->save();
if ($this->isNew()) {
return redirect()->route($this->redirect_route)
->with('info', __("{$this->getModelName()} was successfully created."));
}
if ($this->isNew()) {
return redirect()->route($this->redirect_route)
->with('info', __("{$this->getModelName()} was successfully created."));
}
$this->info(__("{$this->getModelName()} was successfully updated."));
}
$this->info(__("{$this->getModelName()} was successfully updated."));
}
/**
* Render the setup page
*/
public function render()
{
$script = Str::lower($this->getModelName());
$script = Str::lower($this->getModelName());
return view("form.$script")
->layout('layouts.admin');
->layout('layouts.admin');
}
}