> */ public function rules(): array { $editing = $this->getMethod() == 'PUT'; $address = Rule::unique('users'); if ($editing) { $address->ignore($this->member); } return [ 'name' => ['required'], 'email' => ['required', new IdnEmail, $address], 'phone' => ['nullable'], 'password' => $editing ? ['nullable', 'min:8'] : ['required', 'min:8'], 'companies' => ['required'], 'companies.*.id' => ['required'], 'companies.*.role' => ['required'], ]; } /** * The account row on its own, stamped with whoever is filing it. * * On an edit the stamp is written again, so the column records the last * person to save the form rather than the one who opened the account. * * @return array */ public function getUserPayload() { return collect($this->validated()) ->only(self::ACCOUNT_FIELDS) ->merge(['creator_id' => $this->user()->id]) ->toArray(); } }