2018-10-15 14:40:34 +02:00
|
|
|
<?php
|
2019-05-11 05:32:07 +02:00
|
|
|
/**
|
|
|
|
* Invoice Ninja (https://invoiceninja.com)
|
|
|
|
*
|
|
|
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
|
|
|
*
|
|
|
|
* @copyright Copyright (c) 2019. Invoice Ninja LLC (https://invoiceninja.com)
|
|
|
|
*
|
|
|
|
* @license https://opensource.org/licenses/AAL
|
|
|
|
*/
|
2018-10-15 14:40:34 +02:00
|
|
|
|
|
|
|
namespace App\Models;
|
|
|
|
|
2019-05-03 09:57:55 +02:00
|
|
|
use App\Models\Filterable;
|
2018-11-20 05:36:56 +01:00
|
|
|
use App\Utils\Traits\MakesHash;
|
2018-10-15 14:40:34 +02:00
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
|
2018-11-02 11:54:46 +01:00
|
|
|
class Payment extends BaseModel
|
2018-10-15 14:40:34 +02:00
|
|
|
{
|
2018-11-20 05:36:56 +01:00
|
|
|
use MakesHash;
|
2019-05-03 09:57:55 +02:00
|
|
|
use Filterable;
|
2019-05-13 08:18:46 +02:00
|
|
|
|
|
|
|
const STATUS_PENDING = 1;
|
|
|
|
const STATUS_VOIDED = 2;
|
|
|
|
const STATUS_FAILED = 3;
|
|
|
|
const STATUS_COMPLETED = 4;
|
|
|
|
const STATUS_PARTIALLY_REFUNDED = 5;
|
|
|
|
const STATUS_REFUNDED = 6;
|
|
|
|
|
2019-06-26 06:04:10 +02:00
|
|
|
protected $fillable = [
|
|
|
|
'client_id',
|
|
|
|
'payment_type_id',
|
|
|
|
'amount',
|
|
|
|
'payment_date',
|
|
|
|
'transaction_reference'
|
2018-11-20 05:36:56 +01:00
|
|
|
];
|
|
|
|
|
2019-05-03 09:57:55 +02:00
|
|
|
public function client()
|
|
|
|
{
|
|
|
|
return $this->belongsTo(Client::class);
|
|
|
|
}
|
2018-11-20 05:36:56 +01:00
|
|
|
|
2019-05-03 09:57:55 +02:00
|
|
|
public function company()
|
2018-11-20 05:36:56 +01:00
|
|
|
{
|
2019-05-03 09:57:55 +02:00
|
|
|
return $this->belongsTo(Company::class);
|
2018-11-20 05:36:56 +01:00
|
|
|
}
|
|
|
|
|
2019-05-03 09:57:55 +02:00
|
|
|
public function user()
|
2018-11-20 05:36:56 +01:00
|
|
|
{
|
2019-05-03 09:57:55 +02:00
|
|
|
return $this->belongsTo(User::class);
|
2018-11-20 05:36:56 +01:00
|
|
|
}
|
2019-04-28 07:31:32 +02:00
|
|
|
|
|
|
|
public function documents()
|
|
|
|
{
|
|
|
|
return $this->morphMany(Document::class, 'documentable');
|
|
|
|
}
|
2019-05-13 08:18:46 +02:00
|
|
|
|
|
|
|
public function invoices()
|
|
|
|
{
|
|
|
|
return $this->morphedByMany(Invoice::class, 'paymentable');
|
|
|
|
}
|
2019-05-15 07:03:18 +02:00
|
|
|
|
|
|
|
public function company_ledger()
|
|
|
|
{
|
|
|
|
return $this->morphMany(CompanyLedger::class, 'company_ledgerable');
|
|
|
|
}
|
2019-08-16 07:20:28 +02:00
|
|
|
|
|
|
|
public static function typeForId(int $payment_type_id)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function badgeForStatus(int $status)
|
|
|
|
{
|
|
|
|
switch ($status) {
|
|
|
|
case 'value':
|
|
|
|
# code...
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
# code...
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2018-10-15 14:40:34 +02:00
|
|
|
}
|