fix some bugs
This commit is contained in:
@@ -175,8 +175,11 @@ class CustomerController extends SuperController
|
||||
|
||||
$customer = Customer::findOrFail($id);
|
||||
|
||||
if (array_key_exists('referral_to_id', $data) && filled($customer->referral_to_id)) {
|
||||
unset($data['referral_to_id']);
|
||||
if (array_key_exists('referral_to_id', $data)) {
|
||||
$incoming = is_string($data['referral_to_id']) ? trim($data['referral_to_id']) : $data['referral_to_id'];
|
||||
if (filled($customer->referral_to_id) || $incoming === null || $incoming === '') {
|
||||
unset($data['referral_to_id']);
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($data['fname'], $data['lname'])) {
|
||||
|
||||
@@ -6,6 +6,7 @@ use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Carbon\Carbon;
|
||||
use Rooyesh\Wallet\models\Wallet;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Symfony\Component\HttpKernel\Exception\UnprocessableEntityHttpException;
|
||||
@@ -136,6 +137,17 @@ class Customer extends Authenticatable implements JWTSubject
|
||||
$this->attributes['password'] = Hash::make($value);
|
||||
}
|
||||
|
||||
public function setBirthDateAttribute($value): void
|
||||
{
|
||||
if ($value === null || $value === '') {
|
||||
$this->attributes['birth_date'] = null;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->attributes['birth_date'] = Carbon::parse($value)->format('Y-m-d');
|
||||
}
|
||||
|
||||
public function getJWTIdentifier()
|
||||
{
|
||||
return $this->getKey();
|
||||
|
||||
Reference in New Issue
Block a user