If you familiar with Jetstream, you will noticed app/Actions directory in your project. The usage should only need to extend the base class, define rules and model going to use. With 4 above rules: inputs = $inputs; return $this; } public function setConstrainedBy(array $constrainedBy): self { $this->constrainedBy = $constrainedBy; return $this; } public function getConstrainedBy(): array { return $this->constrainedBy; } public function hasConstrained(): bool { return count($this->getConstrainedBy()) > 0; } public function getInputs(): array { return $this->inputs; } public function model(): string { if (! property_exists($this, 'model')) { throw ActionException::missingModelProperty(__CLASS__); } return $this->model; } public function execute() { Validator::make( array_merge( $this->getConstrainedBy(), $this->getInputs()), $this->rules())->validate(); return $this->record = DB::transaction(function () { return $this->hasConstrained()?

The usage: use \App\Actions\User\UpdateOrCreate as UpdateOrCreateUser; $data = [ 'name' => 'Nasrul Hazim', 'email' => 'nasrul@somewhere.com', 'password' => 'password', 'password_confirmation' => 'password', ]; (new UpdateOrCreateUser($data))->execute(); Another example: ['required', 'string', 'max:255'], ]; }}
Newsletter

Get the latest Laravel/PHP jobs, events and curated articles straight to your inbox, once a week

Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge. Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge.
Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Shirts painstakingly handcrafted by under-caffeinated developers. Shirts painstakingly handcrafted by under-caffeinated developers.
Community Partners