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

Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future. Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future.
Community Partners