Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Laravel command argument validation #124

Open
sandervankasteel opened this issue Aug 1, 2022 · 0 comments
Open

Laravel command argument validation #124

sandervankasteel opened this issue Aug 1, 2022 · 0 comments

Comments

@sandervankasteel
Copy link
Owner

Potential implementation; based on the command referenced in

class SendEmails extends Command
{
    use ArgumentValidation;

    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'mail:send {user}';
 
    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Send a marketing email to a user';
 
    /**
     * Execute the console command.
     *
     * @param  \App\Support\DripEmailer  $drip
     * @return mixed
     */
    public function handle(DripEmailer $drip)
    {
        $drip->send(User::find($this->argument('user')));
    }
    
    protected function rules(): array
    {
       return [
           'user' => 'required|exists:user,id',
       ];
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant