Initial integration with Quickbooks
This commit is contained in:
@@ -36,6 +36,11 @@ class Account extends Model
|
||||
return $this->belongsTo(Country::class);
|
||||
}
|
||||
|
||||
public function external()
|
||||
{
|
||||
return $this->belongsToMany(External\Integrations::class,'external_account',NULL,'external_integration_id');
|
||||
}
|
||||
|
||||
public function invoices()
|
||||
{
|
||||
return $this->hasMany(Invoice::class);
|
||||
@@ -91,6 +96,11 @@ class Account extends Model
|
||||
return sprintf('<a href="/r/switch/start/%s"><i class="fa fa-external-link"></i></a>',$this->user_id);
|
||||
}
|
||||
|
||||
public function getTypeAttribute()
|
||||
{
|
||||
return $this->company ? 'Business' : 'Private';
|
||||
}
|
||||
|
||||
private function _address()
|
||||
{
|
||||
$return = [];
|
||||
@@ -131,4 +141,19 @@ class Account extends Model
|
||||
return $item->active AND $item->due > 0;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the external account ID for a specific integration
|
||||
*
|
||||
* @param External\Integrations $o
|
||||
* @return mixed
|
||||
*/
|
||||
public function ExternalAccounting(External\Integrations $o)
|
||||
{
|
||||
return $this
|
||||
->external()
|
||||
->where('id','=',$o->id)
|
||||
->where('site_id','=',$this->site_id)
|
||||
->first();
|
||||
}
|
||||
}
|
27
app/Models/External/Integrations.php
vendored
Normal file
27
app/Models/External/Integrations.php
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\External;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
use App\User;
|
||||
|
||||
class Integrations extends Model
|
||||
{
|
||||
public $table = 'external_integrations';
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
function scopeActive()
|
||||
{
|
||||
return $this->where('active',TRUE);
|
||||
}
|
||||
|
||||
function scopeType($query,string $type)
|
||||
{
|
||||
return $query->where('type',$type);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user