@ -11,12 +11,13 @@ use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Laratrust\Traits\LaratrustUserTrait;
|
||||
use Kyslik\ColumnSortable\Sortable;
|
||||
use Plank\Mediable\Mediable;
|
||||
use Request;
|
||||
use Route;
|
||||
|
||||
class User extends Authenticatable
|
||||
{
|
||||
use Filterable, LaratrustUserTrait, Notifiable, SoftDeletes, Sortable;
|
||||
use Filterable, LaratrustUserTrait, Notifiable, SoftDeletes, Sortable, Mediable;
|
||||
|
||||
protected $table = 'users';
|
||||
|
||||
@ -25,7 +26,7 @@ class User extends Authenticatable
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = ['name', 'email', 'password', 'locale', 'picture', 'enabled'];
|
||||
protected $fillable = ['name', 'email', 'password', 'locale', 'enabled'];
|
||||
|
||||
/**
|
||||
* The attributes that should be hidden for arrays.
|
||||
@ -87,7 +88,15 @@ class User extends Authenticatable
|
||||
}
|
||||
}
|
||||
|
||||
return $value;
|
||||
if (!empty($value)) {
|
||||
return $value;
|
||||
}
|
||||
|
||||
if (!$this->hasMedia('picture')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $this->getMedia('picture')->last();
|
||||
}
|
||||
|
||||
/**
|
||||
|
14
app/Models/Common/Media.php
Normal file
14
app/Models/Common/Media.php
Normal file
@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Common;
|
||||
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Plank\Mediable\Media as PMedia;
|
||||
|
||||
class Media extends PMedia
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $dates = ['deleted_at'];
|
||||
|
||||
}
|
@ -7,10 +7,11 @@ use EloquentFilter\Filterable;
|
||||
use Illuminate\Database\Eloquent\Model as Eloquent;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Kyslik\ColumnSortable\Sortable;
|
||||
use Plank\Mediable\Mediable;
|
||||
|
||||
class Company extends Eloquent
|
||||
{
|
||||
use Filterable, SoftDeletes, Sortable;
|
||||
use Filterable, SoftDeletes, Sortable, Mediable;
|
||||
|
||||
protected $table = 'companies';
|
||||
|
||||
@ -229,4 +230,22 @@ class Company extends Eloquent
|
||||
->orderBy('value', $direction)
|
||||
->select('companies.*');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current balance.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCompanyLogoAttribute($value)
|
||||
{
|
||||
if (!empty($value)) {
|
||||
return $value;
|
||||
}
|
||||
|
||||
if (!$this->hasMedia('company_logo')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $this->getMedia('company_logo')->last();
|
||||
}
|
||||
}
|
||||
|
@ -7,10 +7,11 @@ use App\Traits\Currencies;
|
||||
use App\Traits\DateTime;
|
||||
use Bkwld\Cloner\Cloneable;
|
||||
use Sofa\Eloquence\Eloquence;
|
||||
use Plank\Mediable\Mediable;
|
||||
|
||||
class Bill extends Model
|
||||
{
|
||||
use Cloneable, Currencies, DateTime, Eloquence;
|
||||
use Cloneable, Currencies, DateTime, Eloquence, Mediable;
|
||||
|
||||
protected $table = 'bills';
|
||||
|
||||
@ -21,7 +22,7 @@ class Bill extends Model
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = ['company_id', 'bill_number', 'order_number', 'bill_status_code', 'billed_at', 'due_at', 'amount', 'currency_code', 'currency_rate', 'vendor_id', 'vendor_name', 'vendor_email', 'vendor_tax_number', 'vendor_phone', 'vendor_address', 'notes', 'attachment'];
|
||||
protected $fillable = ['company_id', 'bill_number', 'order_number', 'bill_status_code', 'billed_at', 'due_at', 'amount', 'currency_code', 'currency_rate', 'vendor_id', 'vendor_name', 'vendor_email', 'vendor_tax_number', 'vendor_phone', 'vendor_address', 'notes'];
|
||||
|
||||
/**
|
||||
* Sortable columns.
|
||||
@ -128,4 +129,22 @@ class Bill extends Model
|
||||
{
|
||||
$this->attributes['currency_rate'] = (double) $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current balance.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getAttachmentAttribute($value)
|
||||
{
|
||||
if (!empty($value)) {
|
||||
return $value;
|
||||
}
|
||||
|
||||
if (!$this->hasMedia('attachment')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $this->getMedia('attachment')->last();
|
||||
}
|
||||
}
|
||||
|
@ -5,10 +5,11 @@ namespace App\Models\Expense;
|
||||
use App\Models\Model;
|
||||
use App\Traits\Currencies;
|
||||
use App\Traits\DateTime;
|
||||
use Plank\Mediable\Mediable;
|
||||
|
||||
class BillPayment extends Model
|
||||
{
|
||||
use Currencies, DateTime;
|
||||
use Currencies, DateTime, Mediable;
|
||||
|
||||
protected $table = 'bill_payments';
|
||||
|
||||
@ -19,7 +20,7 @@ class BillPayment extends Model
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = ['company_id', 'bill_id', 'account_id', 'paid_at', 'amount', 'currency_code', 'currency_rate', 'description', 'payment_method', 'reference', 'attachment'];
|
||||
protected $fillable = ['company_id', 'bill_id', 'account_id', 'paid_at', 'amount', 'currency_code', 'currency_rate', 'description', 'payment_method', 'reference'];
|
||||
|
||||
public function account()
|
||||
{
|
||||
@ -78,4 +79,22 @@ class BillPayment extends Model
|
||||
{
|
||||
return $query->sum('amount');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current balance.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getAttachmentAttribute($value)
|
||||
{
|
||||
if (!empty($value)) {
|
||||
return $value;
|
||||
}
|
||||
|
||||
if (!$this->hasMedia('attachment')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $this->getMedia('attachment')->last();
|
||||
}
|
||||
}
|
||||
|
@ -7,10 +7,11 @@ use App\Traits\Currencies;
|
||||
use App\Traits\DateTime;
|
||||
use Bkwld\Cloner\Cloneable;
|
||||
use Sofa\Eloquence\Eloquence;
|
||||
use Plank\Mediable\Mediable;
|
||||
|
||||
class Payment extends Model
|
||||
{
|
||||
use Cloneable, Currencies, DateTime, Eloquence;
|
||||
use Cloneable, Currencies, DateTime, Eloquence, Mediable;
|
||||
|
||||
protected $table = 'payments';
|
||||
|
||||
@ -19,7 +20,7 @@ class Payment extends Model
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = ['company_id', 'account_id', 'paid_at', 'amount', 'currency_code', 'currency_rate', 'vendor_id', 'description', 'category_id', 'payment_method', 'reference', 'attachment'];
|
||||
protected $fillable = ['company_id', 'account_id', 'paid_at', 'amount', 'currency_code', 'currency_rate', 'vendor_id', 'description', 'category_id', 'payment_method', 'reference'];
|
||||
|
||||
/**
|
||||
* Sortable columns.
|
||||
@ -91,4 +92,22 @@ class Payment extends Model
|
||||
{
|
||||
return $query->orderBy('paid_at', 'desc');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current balance.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getAttachmentAttribute($value)
|
||||
{
|
||||
if (!empty($value)) {
|
||||
return $value;
|
||||
}
|
||||
|
||||
if (!$this->hasMedia('attachment')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $this->getMedia('attachment')->last();
|
||||
}
|
||||
}
|
||||
|
@ -8,13 +8,21 @@ use App\Traits\DateTime;
|
||||
use App\Traits\Incomes;
|
||||
use Bkwld\Cloner\Cloneable;
|
||||
use Sofa\Eloquence\Eloquence;
|
||||
use Plank\Mediable\Mediable;
|
||||
|
||||
class Invoice extends Model
|
||||
{
|
||||
use Cloneable, Currencies, DateTime, Eloquence, Incomes;
|
||||
use Cloneable, Currencies, DateTime, Eloquence, Incomes, Mediable;
|
||||
|
||||
protected $table = 'invoices';
|
||||
|
||||
/**
|
||||
* The accessors to append to the model's array form.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $appends = ['attachment'];
|
||||
|
||||
protected $dates = ['deleted_at', 'invoiced_at', 'due_at'];
|
||||
|
||||
/**
|
||||
@ -22,7 +30,7 @@ class Invoice extends Model
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = ['company_id', 'invoice_number', 'order_number', 'invoice_status_code', 'invoiced_at', 'due_at', 'amount', 'currency_code', 'currency_rate', 'customer_id', 'customer_name', 'customer_email', 'customer_tax_number', 'customer_phone', 'customer_address', 'notes', 'attachment'];
|
||||
protected $fillable = ['company_id', 'invoice_number', 'order_number', 'invoice_status_code', 'invoiced_at', 'due_at', 'amount', 'currency_code', 'currency_rate', 'customer_id', 'customer_name', 'customer_email', 'customer_tax_number', 'customer_phone', 'customer_address', 'notes'];
|
||||
|
||||
/**
|
||||
* Sortable columns.
|
||||
@ -130,4 +138,22 @@ class Invoice extends Model
|
||||
{
|
||||
$this->attributes['currency_rate'] = (double) $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current balance.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getAttachmentAttribute($value)
|
||||
{
|
||||
if (!empty($value)) {
|
||||
return $value;
|
||||
}
|
||||
|
||||
if (!$this->hasMedia('attachment')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $this->getMedia('attachment')->last();
|
||||
}
|
||||
}
|
||||
|
@ -5,10 +5,11 @@ namespace App\Models\Income;
|
||||
use App\Models\Model;
|
||||
use App\Traits\Currencies;
|
||||
use App\Traits\DateTime;
|
||||
use Plank\Mediable\Mediable;
|
||||
|
||||
class InvoicePayment extends Model
|
||||
{
|
||||
use Currencies, DateTime;
|
||||
use Currencies, DateTime, Mediable;
|
||||
|
||||
protected $table = 'invoice_payments';
|
||||
|
||||
@ -19,7 +20,7 @@ class InvoicePayment extends Model
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = ['company_id', 'invoice_id', 'account_id', 'paid_at', 'amount', 'currency_code', 'currency_rate', 'description', 'payment_method', 'reference', 'attachment'];
|
||||
protected $fillable = ['company_id', 'invoice_id', 'account_id', 'paid_at', 'amount', 'currency_code', 'currency_rate', 'description', 'payment_method', 'reference'];
|
||||
|
||||
public function account()
|
||||
{
|
||||
@ -78,4 +79,22 @@ class InvoicePayment extends Model
|
||||
{
|
||||
return $query->sum('amount');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current balance.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getAttachmentAttribute($value)
|
||||
{
|
||||
if (!empty($value)) {
|
||||
return $value;
|
||||
}
|
||||
|
||||
if (!$this->hasMedia('attachment')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $this->getMedia('attachment')->last();
|
||||
}
|
||||
}
|
||||
|
@ -7,10 +7,11 @@ use App\Traits\Currencies;
|
||||
use App\Traits\DateTime;
|
||||
use Bkwld\Cloner\Cloneable;
|
||||
use Sofa\Eloquence\Eloquence;
|
||||
use Plank\Mediable\Mediable;
|
||||
|
||||
class Revenue extends Model
|
||||
{
|
||||
use Cloneable, Currencies, DateTime, Eloquence;
|
||||
use Cloneable, Currencies, DateTime, Eloquence, Mediable;
|
||||
|
||||
protected $table = 'revenues';
|
||||
|
||||
@ -19,7 +20,7 @@ class Revenue extends Model
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = ['company_id', 'account_id', 'paid_at', 'amount', 'currency_code', 'currency_rate', 'customer_id', 'description', 'category_id', 'payment_method', 'reference', 'attachment'];
|
||||
protected $fillable = ['company_id', 'account_id', 'paid_at', 'amount', 'currency_code', 'currency_rate', 'customer_id', 'description', 'category_id', 'payment_method', 'reference'];
|
||||
|
||||
/**
|
||||
* Sortable columns.
|
||||
@ -97,4 +98,22 @@ class Revenue extends Model
|
||||
{
|
||||
return $query->orderBy('paid_at', 'desc');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current balance.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getAttachmentAttribute($value)
|
||||
{
|
||||
if (!empty($value)) {
|
||||
return $value;
|
||||
}
|
||||
|
||||
if (!$this->hasMedia('attachment')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $this->getMedia('attachment')->last();
|
||||
}
|
||||
}
|
||||
|
@ -6,10 +6,11 @@ use App\Models\Model;
|
||||
use App\Traits\Currencies;
|
||||
use Bkwld\Cloner\Cloneable;
|
||||
use Sofa\Eloquence\Eloquence;
|
||||
use Plank\Mediable\Mediable;
|
||||
|
||||
class Item extends Model
|
||||
{
|
||||
use Cloneable, Currencies, Eloquence;
|
||||
use Cloneable, Currencies, Eloquence, Mediable;
|
||||
|
||||
protected $table = 'items';
|
||||
|
||||
@ -18,7 +19,7 @@ class Item extends Model
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = ['company_id', 'name', 'sku', 'description', 'sale_price', 'purchase_price', 'quantity', 'category_id', 'tax_id', 'picture', 'enabled'];
|
||||
protected $fillable = ['company_id', 'name', 'sku', 'description', 'sale_price', 'purchase_price', 'quantity', 'category_id', 'tax_id', 'enabled'];
|
||||
|
||||
/**
|
||||
* Sortable columns.
|
||||
@ -111,4 +112,22 @@ class Item extends Model
|
||||
->orderBy('name', $direction)
|
||||
->select('items.*');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current balance.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPictureAttribute($value)
|
||||
{
|
||||
if (!empty($value)) {
|
||||
return $value;
|
||||
}
|
||||
|
||||
if (!$this->hasMedia('picture')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $this->getMedia('picture')->last();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user