v6 update

This commit is contained in:
Mohit Panjwani
2022-01-10 16:06:17 +05:30
parent b770e6277f
commit bdea879273
722 changed files with 19047 additions and 9186 deletions

View File

@ -9,7 +9,22 @@ class PaymentMethod extends Model
{
use HasFactory;
protected $fillable = ['name', 'company_id'];
protected $guarded = [
'id'
];
public const TYPE_GENERAL = 'GENERAL';
public const TYPE_MODULE = 'MODULE';
protected $casts = [
'settings' => 'array',
'use_test_env' => 'boolean'
];
public function setSettingsAttribute($value)
{
$this->attributes['settings'] = json_encode($value);
}
public function payments()
{
@ -33,7 +48,7 @@ class PaymentMethod extends Model
public function scopeWhereSearch($query, $search)
{
$query->where('name', 'LIKE', '%'.$search.'%');
$query->where('name', 'LIKE', '%' . $search . '%');
}
public function scopeApplyFilters($query, array $filters)
@ -64,11 +79,19 @@ class PaymentMethod extends Model
public static function createPaymentMethod($request)
{
$data = $request->validated();
$data['company_id'] = $request->header('company');
$data = $request->getPaymentMethodPayload();
$paymentMethod = self::create($data);
return $paymentMethod;
}
public static function getSettings($id)
{
$settings = PaymentMethod::whereCompany()
->find($id)
->settings;
return $settings;
}
}