update email field to nullable

This commit is contained in:
JiaSheng
2023-08-08 20:52:09 +08:00
parent e31f1eda53
commit 2d7e850ea4
3 changed files with 17 additions and 10 deletions
@@ -7,7 +7,7 @@ use App\Classes\ValueObjects\Constants\BusinessType;
class CompanyProfileObject implements DataTransferObject
{
/** @var string */
/** @var string|null */
private $email;
/** @var string */
@@ -18,11 +18,11 @@ class CompanyProfileObject implements DataTransferObject
/**
* CompanyObject constructor.
* @param string $email
* @param string|null $email
* @param string $phone
* @param int|null $businessType
*/
public function __construct(string $email, string $phone, ?int $businessType = BusinessType::IMPORTER)
public function __construct(?string $email, string $phone, ?int $businessType = BusinessType::IMPORTER)
{
$this->email = $email;
$this->phone = $phone;
@@ -30,9 +30,9 @@ class CompanyProfileObject implements DataTransferObject
}
/**
* @return string
* @return null|string
*/
public function getEmail(): string
public function getEmail(): ?string
{
return $this->email;
}
@@ -19,8 +19,8 @@ class UpdatesCompanyProfile extends AbstractUpdateRecord
{
$model->business_type = $object->getBusinessType();
if ($model->contacts) {
$contact = $model->contacts()->first();
$contact = $model->contacts()->first();
if ($contact) {
$contact->email = $object->getEmail();
$contact->phone = $object->getPhone();
$contact->save();
@@ -11,7 +11,7 @@
<div class="row m-b-10">
<div class="col">
<validation-wrapper-component selectable :validator="$v.parameters.business_type">
<label>Business Type</label>
<label>Company Type</label>
<selectable-component :endpoint="route('api.company.business_type.list')" section="businessTypeListSection" valueColumn="id" :labelColumn="['type']" v-model="parameters.business_type"></selectable-component>
</validation-wrapper-component>
</div>
@@ -47,7 +47,7 @@
</template>
<script>
import modalFormHandler from "../../../general/mixins/modalFormHandler";
import { required } from "vuelidate/lib/validators";
import { required, email } from "vuelidate/lib/validators";
export default {
props: {
data: {
@@ -77,13 +77,20 @@
required,
},
email: {
// required,
email,
},
phone: {
required,
},
}
},
watch: {
'data': function() {
this.parameters.business_type = this.data.business_type;
this.parameters.email = this.data.contact ? this.data.contact.email : "";
this.parameters.phone = this.data.contact ? this.data.contact.phone : "";
}
},
methods: {
submitForm(){
this.submit(route('api.company.profile.update', this.data.id), 'put', this.section, true, true);