Correction typages
This commit is contained in:
parent
d930a9e13c
commit
b65ad8c19e
6 changed files with 37 additions and 38 deletions
|
|
@ -16,7 +16,6 @@ use Illuminate\Http\Request;
|
|||
use Illuminate\Validation\ValidationException;
|
||||
use Kwaadpepper\ExceptionHandler\Exceptions\ExceptionHandler;
|
||||
use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException;
|
||||
use Throwable;
|
||||
|
||||
class Handler extends ExceptionHandler
|
||||
{
|
||||
|
|
@ -56,7 +55,7 @@ class Handler extends ExceptionHandler
|
|||
* @param \Throwable $e
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
*/
|
||||
public function render($request, Throwable $e)
|
||||
public function render($request, \Throwable $e)
|
||||
{
|
||||
if (Helper::isRequestForApiV2($request) and $request->isJson()) {
|
||||
return $this->handleApiV2Exception($request, $e);
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@
|
|||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Carbon;
|
||||
|
||||
class BrandStat extends Model
|
||||
{
|
||||
|
|
@ -41,9 +40,9 @@ class BrandStat extends Model
|
|||
*/
|
||||
protected static function booted()
|
||||
{
|
||||
static::creating(function (BrandStat $stat) {
|
||||
if (!$stat->created_at) {
|
||||
$stat->created_at = Carbon::now();
|
||||
static::creating(function (self $model) {
|
||||
if (!$model->created_at) {
|
||||
$model->created_at = now();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ class Customer extends Model
|
|||
/**
|
||||
* Customer Brand belongsToMany relation
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\belongsToMany
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
||||
*/
|
||||
public function brands()
|
||||
{
|
||||
|
|
@ -98,10 +98,10 @@ class Customer extends Model
|
|||
}
|
||||
}
|
||||
}
|
||||
$query = CustomerInfo::whereHas('brand', function (Builder $query) use ($brand) {
|
||||
$query->where('id', $brand->id);
|
||||
})->whereHas('customer', function (Builder $query) {
|
||||
$query->where('id', $this->id);
|
||||
$query = CustomerInfo::query()->whereHas('brand', function (Builder $q) use ($brand) {
|
||||
$q->where('id', $brand->id);
|
||||
})->whereHas('customer', function (Builder $q) {
|
||||
$q->where('id', $this->id);
|
||||
});
|
||||
if ($firstOrNewOrFail === self::FIRST_OR_NEW) {
|
||||
return $query->firstOrNew();
|
||||
|
|
@ -131,10 +131,10 @@ class Customer extends Model
|
|||
}
|
||||
}
|
||||
}
|
||||
$query = CustomerLogin::whereHas('brand', function (Builder $query) use ($brand) {
|
||||
$query->where('id', $brand->id);
|
||||
})->whereHas('customer', function (Builder $query) use ($brand) {
|
||||
$query->where('id', $this->id);
|
||||
$query = CustomerLogin::query()->whereHas('brand', function (Builder $q) use ($brand) {
|
||||
$q->where('id', $brand->id);
|
||||
})->whereHas('customer', function (Builder $q) {
|
||||
$q->where('id', $this->id);
|
||||
});
|
||||
if ($firstOrNewOrFail === self::FIRST_OR_NEW) {
|
||||
return $query->firstOrNew();
|
||||
|
|
@ -201,11 +201,11 @@ class Customer extends Model
|
|||
*/
|
||||
public function getAnswers(Service $service): Collection
|
||||
{
|
||||
return Answer::whereHas('customers', function ($q) {
|
||||
$q->whereId($this->id);
|
||||
})->whereHas('question', function ($q) use ($service) {
|
||||
$q->whereHas('brand', function ($q) use ($service) {
|
||||
$q->whereId($service->brand->id);
|
||||
return Answer::query()->whereHas('customers', function (Builder $q) {
|
||||
$q->where('id', $this->id);
|
||||
})->whereHas('question', function (Builder $q) use ($service) {
|
||||
$q->whereHas('brand', function (Builder $q) use ($service) {
|
||||
$q->where('id', $service->brand->id);
|
||||
});
|
||||
})->get();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
namespace App\Models;
|
||||
|
||||
use App\Enums\Country;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
|
@ -56,14 +57,14 @@ class CustomerInfo extends Model
|
|||
*/
|
||||
protected static function booted()
|
||||
{
|
||||
static::creating(function (CustomerInfo $customerInfo) {
|
||||
$customerInfo->hashcode = Str::uuid();
|
||||
static::creating(function (self $model) {
|
||||
$model->hashcode = Str::uuid();
|
||||
});
|
||||
static::deleting(function (CustomerInfo $customerInfo) {
|
||||
CustomerOptInHistory::whereHas('customer', function ($q) use ($customerInfo) {
|
||||
$q->whereId($customerInfo->customer->id);
|
||||
})->whereHas('brand', function ($q) use ($customerInfo) {
|
||||
$q->whereId($customerInfo->brand->id);
|
||||
static::deleting(function (self $model) {
|
||||
CustomerOptInHistory::query()->whereHas('customer', function (Builder $q) use ($model) {
|
||||
$q->where('id', $model->customer->id);
|
||||
})->whereHas('brand', function (Builder $q) use ($model) {
|
||||
$q->where('id', $model->brand->id);
|
||||
})->delete();
|
||||
});
|
||||
}
|
||||
|
|
@ -111,9 +112,9 @@ class CustomerInfo extends Model
|
|||
*/
|
||||
public static function getFromEmail(Brand $brand, string $email)
|
||||
{
|
||||
return CustomerInfo::whereHas('brand', function ($q) use ($brand) {
|
||||
return CustomerInfo::query()->whereHas('brand', function (Builder $q) use ($brand) {
|
||||
$q->where('id', $brand->id);
|
||||
})->whereHas('customer', function ($q) use ($email) {
|
||||
})->whereHas('customer', function (Builder $q) use ($email) {
|
||||
$q->where('email', $email);
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,14 +44,14 @@ class CustomerLogin extends Model
|
|||
*/
|
||||
protected static function booted()
|
||||
{
|
||||
static::creating(function ($customerLogin) {
|
||||
if (Hash::needsRehash($customerLogin->password)) {
|
||||
$customerLogin->password = Hash::make(trim($customerLogin->password));
|
||||
static::creating(function (self $model) {
|
||||
if (Hash::needsRehash($model->password)) {
|
||||
$model->password = Hash::make(trim($model->password));
|
||||
}
|
||||
});
|
||||
static::updating(function ($customerLogin) {
|
||||
if (Hash::needsRehash($customerLogin->password)) {
|
||||
$customerLogin->password = Hash::make(trim($customerLogin->password));
|
||||
static::updating(function (self $model) {
|
||||
if (Hash::needsRehash($model->password)) {
|
||||
$model->password = Hash::make(trim($model->password));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -68,9 +68,9 @@ class Service extends Model
|
|||
*/
|
||||
protected static function booted()
|
||||
{
|
||||
static::creating(function (self $service) {
|
||||
$service->generateBearerToken();
|
||||
$service->generateBearerPassword();
|
||||
static::creating(function (self $model) {
|
||||
$model->generateBearerToken();
|
||||
$model->generateBearerPassword();
|
||||
});
|
||||
static::created(function () {
|
||||
// * Flush Eloquent cache.
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue