mirror of
https://github.com/crater-invoice/crater.git
synced 2025-10-27 19:51:09 -04:00
v6 update
This commit is contained in:
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user