Merge pull request #1892 from SevanNerse/model-extras
this makes possible adding extra attributes to models
This commit is contained in:
commit
d824cb2ca5
@ -21,6 +21,23 @@ abstract class Model extends Eloquent
|
|||||||
'enabled' => 'boolean',
|
'enabled' => 'boolean',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
public $allAttributes = [
|
||||||
|
//
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new Eloquent model instance.
|
||||||
|
*
|
||||||
|
* @param array $attributes
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct(array $attributes = [])
|
||||||
|
{
|
||||||
|
$this->allAttributes = $attributes;
|
||||||
|
|
||||||
|
parent::__construct($attributes);
|
||||||
|
}
|
||||||
|
|
||||||
public static function observe($classes)
|
public static function observe($classes)
|
||||||
{
|
{
|
||||||
parent::observe($classes);
|
parent::observe($classes);
|
||||||
|
@ -49,19 +49,19 @@ class Transfers extends Import
|
|||||||
private function getExpenseTransactionId($row)
|
private function getExpenseTransactionId($row)
|
||||||
{
|
{
|
||||||
$expense_transaction = Transaction::create([
|
$expense_transaction = Transaction::create([
|
||||||
'company_id' => session('company_id'),
|
'company_id' => session('company_id'),
|
||||||
'type' => 'expense',
|
'type' => 'expense',
|
||||||
'account_id' => $row['from_account_id'],
|
'account_id' => $row['from_account_id'],
|
||||||
'paid_at' => $row['transferred_at'],
|
'paid_at' => $row['transferred_at'],
|
||||||
'currency_code' => $row['from_currency_code'],
|
'currency_code' => $row['from_currency_code'],
|
||||||
'currency_rate' => $row['from_currency_rate'],
|
'currency_rate' => $row['from_currency_rate'],
|
||||||
'amount' => $row['amount'],
|
'amount' => $row['amount'],
|
||||||
'contact_id' => 0,
|
'contact_id' => 0,
|
||||||
'description' => $row['description'],
|
'description' => $row['description'],
|
||||||
'category_id' => Category::transfer(), // Transfer Category ID
|
'category_id' => Category::transfer(), // Transfer Category ID
|
||||||
'payment_method' => $row['payment_method'],
|
'payment_method' => $row['payment_method'],
|
||||||
'reference' => $row['reference'],
|
'reference' => $row['reference'],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return $expense_transaction->id;
|
return $expense_transaction->id;
|
||||||
}
|
}
|
||||||
@ -81,19 +81,19 @@ class Transfers extends Import
|
|||||||
}
|
}
|
||||||
|
|
||||||
$income_transaction = Transaction::create([
|
$income_transaction = Transaction::create([
|
||||||
'company_id' => session('company_id'),
|
'company_id' => session('company_id'),
|
||||||
'type' => 'income',
|
'type' => 'income',
|
||||||
'account_id' => $row['to_account_id'],
|
'account_id' => $row['to_account_id'],
|
||||||
'paid_at' => $row['transferred_at'],
|
'paid_at' => $row['transferred_at'],
|
||||||
'currency_code' => $row['to_currency_code'],
|
'currency_code' => $row['to_currency_code'],
|
||||||
'currency_rate' => $row['to_currency_rate'],
|
'currency_rate' => $row['to_currency_rate'],
|
||||||
'amount' => $amount,
|
'amount' => $amount,
|
||||||
'contact_id' => 0,
|
'contact_id' => 0,
|
||||||
'description' => $row['description'],
|
'description' => $row['description'],
|
||||||
'category_id' => Category::transfer(), // Transfer Category ID
|
'category_id' => Category::transfer(), // Transfer Category ID
|
||||||
'payment_method' => $row['payment_method'],
|
'payment_method' => $row['payment_method'],
|
||||||
'reference' => $row['reference'],
|
'reference' => $row['reference'],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return $income_transaction->id;
|
return $income_transaction->id;
|
||||||
}
|
}
|
||||||
|
@ -3,8 +3,8 @@
|
|||||||
namespace App\Imports\Purchases;
|
namespace App\Imports\Purchases;
|
||||||
|
|
||||||
use App\Abstracts\Import;
|
use App\Abstracts\Import;
|
||||||
use App\Models\Banking\Transaction as Model;
|
|
||||||
use App\Http\Requests\Banking\Transaction as Request;
|
use App\Http\Requests\Banking\Transaction as Request;
|
||||||
|
use App\Models\Banking\Transaction as Model;
|
||||||
|
|
||||||
class Payments extends Import
|
class Payments extends Import
|
||||||
{
|
{
|
||||||
|
@ -3,8 +3,8 @@
|
|||||||
namespace App\Imports\Purchases;
|
namespace App\Imports\Purchases;
|
||||||
|
|
||||||
use App\Abstracts\Import;
|
use App\Abstracts\Import;
|
||||||
use App\Models\Common\Contact as Model;
|
|
||||||
use App\Http\Requests\Common\Contact as Request;
|
use App\Http\Requests\Common\Contact as Request;
|
||||||
|
use App\Models\Common\Contact as Model;
|
||||||
|
|
||||||
class Vendors extends Import
|
class Vendors extends Import
|
||||||
{
|
{
|
||||||
|
@ -3,8 +3,8 @@
|
|||||||
namespace App\Imports\Sales;
|
namespace App\Imports\Sales;
|
||||||
|
|
||||||
use App\Abstracts\Import;
|
use App\Abstracts\Import;
|
||||||
use App\Models\Common\Contact as Model;
|
|
||||||
use App\Http\Requests\Common\Contact as Request;
|
use App\Http\Requests\Common\Contact as Request;
|
||||||
|
use App\Models\Common\Contact as Model;
|
||||||
|
|
||||||
class Customers extends Import
|
class Customers extends Import
|
||||||
{
|
{
|
||||||
|
@ -28,6 +28,10 @@ class Company extends Eloquent
|
|||||||
'enabled' => 'boolean',
|
'enabled' => 'boolean',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
public $allAttributes = [
|
||||||
|
//
|
||||||
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sortable columns.
|
* Sortable columns.
|
||||||
*
|
*
|
||||||
@ -35,6 +39,19 @@ class Company extends Eloquent
|
|||||||
*/
|
*/
|
||||||
public $sortable = ['name', 'domain', 'email', 'enabled', 'created_at'];
|
public $sortable = ['name', 'domain', 'email', 'enabled', 'created_at'];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new Eloquent model instance.
|
||||||
|
*
|
||||||
|
* @param array $attributes
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct(array $attributes = [])
|
||||||
|
{
|
||||||
|
$this->allAttributes = $attributes;
|
||||||
|
|
||||||
|
parent::__construct($attributes);
|
||||||
|
}
|
||||||
|
|
||||||
public static function boot()
|
public static function boot()
|
||||||
{
|
{
|
||||||
parent::boot();
|
parent::boot();
|
||||||
|
@ -13,8 +13,6 @@ class Setting extends Eloquent
|
|||||||
|
|
||||||
protected $tenantable = true;
|
protected $tenantable = true;
|
||||||
|
|
||||||
public $timestamps = false;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attributes that should be mass-assignable.
|
* Attributes that should be mass-assignable.
|
||||||
*
|
*
|
||||||
@ -22,6 +20,25 @@ class Setting extends Eloquent
|
|||||||
*/
|
*/
|
||||||
protected $fillable = ['company_id', 'key', 'value'];
|
protected $fillable = ['company_id', 'key', 'value'];
|
||||||
|
|
||||||
|
public $allAttributes = [
|
||||||
|
//
|
||||||
|
];
|
||||||
|
|
||||||
|
public $timestamps = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new Eloquent model instance.
|
||||||
|
*
|
||||||
|
* @param array $attributes
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct(array $attributes = [])
|
||||||
|
{
|
||||||
|
$this->allAttributes = $attributes;
|
||||||
|
|
||||||
|
parent::__construct($attributes);
|
||||||
|
}
|
||||||
|
|
||||||
public function company()
|
public function company()
|
||||||
{
|
{
|
||||||
return $this->belongsTo('App\Models\Common\Company');
|
return $this->belongsTo('App\Models\Common\Company');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user