mirror of
https://github.com/InvoiceShelf/InvoiceShelf.git
synced 2026-04-07 13:41:23 +00:00
Laravel 11 (#84)
* Convert string references to `::class` PHP 5.5.9 adds the new static `class` property which provides the fully qualified class name. This is preferred over using strings for class names since the `class` property references are checked by PHP. * Use Faker methods Accessing Faker properties was deprecated in Faker 1.14. * Convert route options to fluent methods Laravel 8 adopts the tuple syntax for controller actions. Since the old options array is incompatible with this syntax, Shift converted them to use modern, fluent methods. * Adopt class based routes * Remove default `app` files * Shift core files * Streamline config files * Set new `ENV` variables * Default new `bootstrap/app.php` * Re-register HTTP middleware * Consolidate service providers * Re-register service providers * Re-register routes * Re-register scheduled commands * Bump Composer dependencies * Use `<env>` tags for configuration `<env>` tags have a lower precedence than system environment variables making it easier to overwrite PHPUnit configuration values in additional environments, such a CI. Review this blog post for more details on configuration precedence when testing Laravel: https://jasonmccreary.me/articles/laravel-testing-configuration-precedence/ * Adopt anonymous migrations * Rename `password_resets` table * Convert `$casts` property to method * Adopt Laravel type hints * Mark base controller as `abstract` * Remove `CreatesApplication` testing trait * Shift cleanup * Fix shift first issues * Updating Rules for laravel 11, sanctum config and pint * Fix Carbon issue on dashboard * Temporary fix for tests while migration is issue fixed on laravel side * Carbon needs numerical values, not strings * Minimum php version * Fix domain installation step not fetching the correct company_id * Fix Role Policy wasn't properly registered ---------
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace InvoiceShelf\Models;
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class Address extends Model
|
||||
{
|
||||
@@ -22,22 +23,22 @@ class Address extends Model
|
||||
return $name;
|
||||
}
|
||||
|
||||
public function user()
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
public function customer()
|
||||
public function customer(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Customer::class);
|
||||
}
|
||||
|
||||
public function company()
|
||||
public function company(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Company::class);
|
||||
}
|
||||
|
||||
public function country()
|
||||
public function country(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Country::class);
|
||||
}
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace InvoiceShelf\Models;
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||
use Silber\Bouncer\BouncerFacade;
|
||||
use Silber\Bouncer\Database\Role;
|
||||
use Spatie\MediaLibrary\HasMedia;
|
||||
@@ -58,97 +62,97 @@ class Company extends Model implements HasMedia
|
||||
return null;
|
||||
}
|
||||
|
||||
public function customers()
|
||||
public function customers(): HasMany
|
||||
{
|
||||
return $this->hasMany(Customer::class);
|
||||
}
|
||||
|
||||
public function owner()
|
||||
public function owner(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'owner_id');
|
||||
}
|
||||
|
||||
public function settings()
|
||||
public function settings(): HasMany
|
||||
{
|
||||
return $this->hasMany(CompanySetting::class);
|
||||
}
|
||||
|
||||
public function recurringInvoices()
|
||||
public function recurringInvoices(): HasMany
|
||||
{
|
||||
return $this->hasMany(RecurringInvoice::class);
|
||||
}
|
||||
|
||||
public function customFields()
|
||||
public function customFields(): HasMany
|
||||
{
|
||||
return $this->hasMany(CustomField::class);
|
||||
}
|
||||
|
||||
public function customFieldValues()
|
||||
public function customFieldValues(): HasMany
|
||||
{
|
||||
return $this->hasMany(CustomFieldValue::class);
|
||||
}
|
||||
|
||||
public function exchangeRateLogs()
|
||||
public function exchangeRateLogs(): HasMany
|
||||
{
|
||||
return $this->hasMany(ExchangeRateLog::class);
|
||||
}
|
||||
|
||||
public function exchangeRateProviders()
|
||||
public function exchangeRateProviders(): HasMany
|
||||
{
|
||||
return $this->hasMany(ExchangeRateProvider::class);
|
||||
}
|
||||
|
||||
public function invoices()
|
||||
public function invoices(): HasMany
|
||||
{
|
||||
return $this->hasMany(Invoice::class);
|
||||
}
|
||||
|
||||
public function expenses()
|
||||
public function expenses(): HasMany
|
||||
{
|
||||
return $this->hasMany(Expense::class);
|
||||
}
|
||||
|
||||
public function units()
|
||||
public function units(): HasMany
|
||||
{
|
||||
return $this->hasMany(Unit::class);
|
||||
}
|
||||
|
||||
public function expenseCategories()
|
||||
public function expenseCategories(): HasMany
|
||||
{
|
||||
return $this->hasMany(ExpenseCategory::class);
|
||||
}
|
||||
|
||||
public function taxTypes()
|
||||
public function taxTypes(): HasMany
|
||||
{
|
||||
return $this->hasMany(TaxType::class);
|
||||
}
|
||||
|
||||
public function items()
|
||||
public function items(): HasMany
|
||||
{
|
||||
return $this->hasMany(Item::class);
|
||||
}
|
||||
|
||||
public function payments()
|
||||
public function payments(): HasMany
|
||||
{
|
||||
return $this->hasMany(Payment::class);
|
||||
}
|
||||
|
||||
public function paymentMethods()
|
||||
public function paymentMethods(): HasMany
|
||||
{
|
||||
return $this->hasMany(PaymentMethod::class);
|
||||
}
|
||||
|
||||
public function estimates()
|
||||
public function estimates(): HasMany
|
||||
{
|
||||
return $this->hasMany(Estimate::class);
|
||||
}
|
||||
|
||||
public function address()
|
||||
public function address(): HasOne
|
||||
{
|
||||
return $this->hasOne(Address::class);
|
||||
}
|
||||
|
||||
public function users()
|
||||
public function users(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(User::class, 'user_company', 'company_id', 'user_id');
|
||||
}
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace InvoiceShelf\Models;
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class CompanySetting extends Model
|
||||
{
|
||||
@@ -11,7 +12,7 @@ class CompanySetting extends Model
|
||||
|
||||
protected $fillable = ['company_id', 'option', 'value'];
|
||||
|
||||
public function company()
|
||||
public function company(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Company::class);
|
||||
}
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace InvoiceShelf\Models;
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class Country extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
public function address()
|
||||
public function address(): HasMany
|
||||
{
|
||||
return $this->hasMany(Address::class);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace InvoiceShelf\Models;
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace InvoiceShelf\Models;
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class CustomField extends Model
|
||||
{
|
||||
@@ -22,9 +24,12 @@ class CustomField extends Model
|
||||
'defaultAnswer',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'options' => 'array',
|
||||
];
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'options' => 'array',
|
||||
];
|
||||
}
|
||||
|
||||
public function setTimeAnswerAttribute($value)
|
||||
{
|
||||
@@ -50,12 +55,12 @@ class CustomField extends Model
|
||||
return $this->customFieldValues()->exists();
|
||||
}
|
||||
|
||||
public function company()
|
||||
public function company(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Company::class);
|
||||
}
|
||||
|
||||
public function customFieldValues()
|
||||
public function customFieldValues(): HasMany
|
||||
{
|
||||
return $this->hasMany(CustomFieldValue::class);
|
||||
}
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace InvoiceShelf\Models;
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphTo;
|
||||
|
||||
class CustomFieldValue extends Model
|
||||
{
|
||||
@@ -38,17 +40,17 @@ class CustomFieldValue extends Model
|
||||
return $this->$value_type;
|
||||
}
|
||||
|
||||
public function company()
|
||||
public function company(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Company::class);
|
||||
}
|
||||
|
||||
public function customField()
|
||||
public function customField(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(CustomField::class);
|
||||
}
|
||||
|
||||
public function customFieldValuable()
|
||||
public function customFieldValuable(): MorphTo
|
||||
{
|
||||
return $this->morphTo();
|
||||
}
|
||||
|
||||
@@ -1,13 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace InvoiceShelf\Models;
|
||||
namespace App\Models;
|
||||
|
||||
use App\Notifications\CustomerMailResetPasswordNotification;
|
||||
use App\Traits\HasCustomFieldsTrait;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use InvoiceShelf\Notifications\CustomerMailResetPasswordNotification;
|
||||
use InvoiceShelf\Traits\HasCustomFieldsTrait;
|
||||
use Laravel\Sanctum\HasApiTokens;
|
||||
use Silber\Bouncer\Database\HasRolesAndAbilities;
|
||||
use Spatie\MediaLibrary\HasMedia;
|
||||
@@ -40,9 +43,12 @@ class Customer extends Authenticatable implements HasMedia
|
||||
'avatar',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'enable_portal' => 'boolean',
|
||||
];
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'enable_portal' => 'boolean',
|
||||
];
|
||||
}
|
||||
|
||||
public function getFormattedCreatedAtAttribute($value)
|
||||
{
|
||||
@@ -58,57 +64,57 @@ class Customer extends Authenticatable implements HasMedia
|
||||
}
|
||||
}
|
||||
|
||||
public function estimates()
|
||||
public function estimates(): HasMany
|
||||
{
|
||||
return $this->hasMany(Estimate::class);
|
||||
}
|
||||
|
||||
public function expenses()
|
||||
public function expenses(): HasMany
|
||||
{
|
||||
return $this->hasMany(Expense::class);
|
||||
}
|
||||
|
||||
public function invoices()
|
||||
public function invoices(): HasMany
|
||||
{
|
||||
return $this->hasMany(Invoice::class);
|
||||
}
|
||||
|
||||
public function payments()
|
||||
public function payments(): HasMany
|
||||
{
|
||||
return $this->hasMany(Payment::class);
|
||||
}
|
||||
|
||||
public function addresses()
|
||||
public function addresses(): HasMany
|
||||
{
|
||||
return $this->hasMany(Address::class);
|
||||
}
|
||||
|
||||
public function recurringInvoices()
|
||||
public function recurringInvoices(): HasMany
|
||||
{
|
||||
return $this->hasMany(RecurringInvoice::class);
|
||||
}
|
||||
|
||||
public function currency()
|
||||
public function currency(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Currency::class);
|
||||
}
|
||||
|
||||
public function creator()
|
||||
public function creator(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Customer::class, 'creator_id');
|
||||
}
|
||||
|
||||
public function company()
|
||||
public function company(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Company::class);
|
||||
}
|
||||
|
||||
public function billingAddress()
|
||||
public function billingAddress(): HasOne
|
||||
{
|
||||
return $this->hasOne(Address::class)->where('type', Address::BILLING_TYPE);
|
||||
}
|
||||
|
||||
public function shippingAddress()
|
||||
public function shippingAddress(): HasOne
|
||||
{
|
||||
return $this->hasOne(Address::class)->where('type', Address::SHIPPING_TYPE);
|
||||
}
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace InvoiceShelf\Models;
|
||||
namespace App\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphTo;
|
||||
|
||||
class EmailLog extends Model
|
||||
{
|
||||
@@ -12,7 +13,7 @@ class EmailLog extends Model
|
||||
|
||||
protected $guarded = ['id'];
|
||||
|
||||
public function mailable()
|
||||
public function mailable(): MorphTo
|
||||
{
|
||||
return $this->morphTo();
|
||||
}
|
||||
|
||||
@@ -1,19 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace InvoiceShelf\Models;
|
||||
namespace App\Models;
|
||||
|
||||
use App;
|
||||
use App\Mail\SendEstimateMail;
|
||||
use App\Services\SerialNumberFormatter;
|
||||
use App\Traits\GeneratesPdfTrait;
|
||||
use App\Traits\HasCustomFieldsTrait;
|
||||
use Barryvdh\DomPDF\Facade\Pdf as PDF;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Facades\Vite;
|
||||
use Illuminate\Support\Str;
|
||||
use InvoiceShelf\Mail\SendEstimateMail;
|
||||
use InvoiceShelf\Services\SerialNumberFormatter;
|
||||
use InvoiceShelf\Traits\GeneratesPdfTrait;
|
||||
use InvoiceShelf\Traits\HasCustomFieldsTrait;
|
||||
use Spatie\MediaLibrary\HasMedia;
|
||||
use Spatie\MediaLibrary\InteractsWithMedia;
|
||||
use Vinkla\Hashids\Facades\Hashids;
|
||||
@@ -53,51 +56,54 @@ class Estimate extends Model implements HasMedia
|
||||
|
||||
protected $guarded = ['id'];
|
||||
|
||||
protected $casts = [
|
||||
'total' => 'integer',
|
||||
'tax' => 'integer',
|
||||
'sub_total' => 'integer',
|
||||
'discount' => 'float',
|
||||
'discount_val' => 'integer',
|
||||
'exchange_rate' => 'float',
|
||||
];
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'total' => 'integer',
|
||||
'tax' => 'integer',
|
||||
'sub_total' => 'integer',
|
||||
'discount' => 'float',
|
||||
'discount_val' => 'integer',
|
||||
'exchange_rate' => 'float',
|
||||
];
|
||||
}
|
||||
|
||||
public function getEstimatePdfUrlAttribute()
|
||||
{
|
||||
return url('/estimates/pdf/'.$this->unique_hash);
|
||||
}
|
||||
|
||||
public function emailLogs()
|
||||
public function emailLogs(): MorphMany
|
||||
{
|
||||
return $this->morphMany('App\Models\EmailLog', 'mailable');
|
||||
}
|
||||
|
||||
public function items()
|
||||
public function items(): HasMany
|
||||
{
|
||||
return $this->hasMany('InvoiceShelf\Models\EstimateItem');
|
||||
return $this->hasMany(\App\Models\EstimateItem::class);
|
||||
}
|
||||
|
||||
public function customer()
|
||||
public function customer(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Customer::class, 'customer_id');
|
||||
}
|
||||
|
||||
public function creator()
|
||||
public function creator(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo('InvoiceShelf\Models\User', 'creator_id');
|
||||
return $this->belongsTo(\App\Models\User::class, 'creator_id');
|
||||
}
|
||||
|
||||
public function company()
|
||||
public function company(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo('InvoiceShelf\Models\Company');
|
||||
return $this->belongsTo(\App\Models\Company::class);
|
||||
}
|
||||
|
||||
public function currency()
|
||||
public function currency(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Currency::class);
|
||||
}
|
||||
|
||||
public function taxes()
|
||||
public function taxes(): HasMany
|
||||
{
|
||||
return $this->hasMany(Tax::class);
|
||||
}
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace InvoiceShelf\Models;
|
||||
namespace App\Models;
|
||||
|
||||
use App\Traits\HasCustomFieldsTrait;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use InvoiceShelf\Traits\HasCustomFieldsTrait;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class EstimateItem extends Model
|
||||
{
|
||||
@@ -15,26 +17,29 @@ class EstimateItem extends Model
|
||||
'id',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'price' => 'integer',
|
||||
'total' => 'integer',
|
||||
'discount' => 'float',
|
||||
'quantity' => 'float',
|
||||
'discount_val' => 'integer',
|
||||
'tax' => 'integer',
|
||||
];
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'price' => 'integer',
|
||||
'total' => 'integer',
|
||||
'discount' => 'float',
|
||||
'quantity' => 'float',
|
||||
'discount_val' => 'integer',
|
||||
'tax' => 'integer',
|
||||
];
|
||||
}
|
||||
|
||||
public function estimate()
|
||||
public function estimate(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Estimate::class);
|
||||
}
|
||||
|
||||
public function item()
|
||||
public function item(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Item::class);
|
||||
}
|
||||
|
||||
public function taxes()
|
||||
public function taxes(): HasMany
|
||||
{
|
||||
return $this->hasMany(Tax::class);
|
||||
}
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace InvoiceShelf\Models;
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class ExchangeRateLog extends Model
|
||||
{
|
||||
@@ -13,16 +14,19 @@ class ExchangeRateLog extends Model
|
||||
'id',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'exchange_rate' => 'float',
|
||||
];
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'exchange_rate' => 'float',
|
||||
];
|
||||
}
|
||||
|
||||
public function currency()
|
||||
public function currency(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Currency::class);
|
||||
}
|
||||
|
||||
public function company()
|
||||
public function company(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Company::class);
|
||||
}
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace InvoiceShelf\Models;
|
||||
namespace App\Models;
|
||||
|
||||
use App\Http\Requests\ExchangeRateProviderRequest;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use InvoiceShelf\Http\Requests\ExchangeRateProviderRequest;
|
||||
|
||||
class ExchangeRateProvider extends Model
|
||||
{
|
||||
@@ -15,13 +16,16 @@ class ExchangeRateProvider extends Model
|
||||
'id',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'currencies' => 'array',
|
||||
'driver_config' => 'array',
|
||||
'active' => 'boolean',
|
||||
];
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'currencies' => 'array',
|
||||
'driver_config' => 'array',
|
||||
'active' => 'boolean',
|
||||
];
|
||||
}
|
||||
|
||||
public function company()
|
||||
public function company(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Company::class);
|
||||
}
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace InvoiceShelf\Models;
|
||||
namespace App\Models;
|
||||
|
||||
use App\Traits\HasCustomFieldsTrait;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use InvoiceShelf\Traits\HasCustomFieldsTrait;
|
||||
use Spatie\MediaLibrary\HasMedia;
|
||||
use Spatie\MediaLibrary\InteractsWithMedia;
|
||||
|
||||
@@ -29,39 +30,42 @@ class Expense extends Model implements HasMedia
|
||||
'receiptMeta',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'notes' => 'string',
|
||||
'exchange_rate' => 'float',
|
||||
];
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'notes' => 'string',
|
||||
'exchange_rate' => 'float',
|
||||
];
|
||||
}
|
||||
|
||||
public function category()
|
||||
public function category(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(ExpenseCategory::class, 'expense_category_id');
|
||||
}
|
||||
|
||||
public function customer()
|
||||
public function customer(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Customer::class, 'customer_id');
|
||||
}
|
||||
|
||||
public function company()
|
||||
public function company(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Company::class, 'company_id');
|
||||
}
|
||||
|
||||
public function paymentMethod()
|
||||
public function paymentMethod(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(PaymentMethod::class);
|
||||
}
|
||||
|
||||
public function currency()
|
||||
public function currency(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Currency::class, 'currency_id');
|
||||
}
|
||||
|
||||
public function creator()
|
||||
public function creator(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo('InvoiceShelf\Models\User', 'creator_id');
|
||||
return $this->belongsTo(\App\Models\User::class, 'creator_id');
|
||||
}
|
||||
|
||||
public function getFormattedExpenseDateAttribute($value)
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace InvoiceShelf\Models;
|
||||
namespace App\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class ExpenseCategory extends Model
|
||||
{
|
||||
@@ -19,12 +21,12 @@ class ExpenseCategory extends Model
|
||||
*/
|
||||
protected $appends = ['amount', 'formattedCreatedAt'];
|
||||
|
||||
public function expenses()
|
||||
public function expenses(): HasMany
|
||||
{
|
||||
return $this->hasMany(Expense::class);
|
||||
}
|
||||
|
||||
public function company()
|
||||
public function company(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Company::class);
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace InvoiceShelf\Models;
|
||||
namespace App\Models;
|
||||
|
||||
use App\Carbon;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use InvoiceShelf\Carbon;
|
||||
|
||||
class FileDisk extends Model
|
||||
{
|
||||
@@ -18,9 +18,12 @@ class FileDisk extends Model
|
||||
'id',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'set_as_default' => 'boolean',
|
||||
];
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'set_as_default' => 'boolean',
|
||||
];
|
||||
}
|
||||
|
||||
public function setCredentialsAttribute($value)
|
||||
{
|
||||
|
||||
@@ -1,19 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace InvoiceShelf\Models;
|
||||
namespace App\Models;
|
||||
|
||||
use App;
|
||||
use App\Mail\SendInvoiceMail;
|
||||
use App\Services\SerialNumberFormatter;
|
||||
use App\Traits\GeneratesPdfTrait;
|
||||
use App\Traits\HasCustomFieldsTrait;
|
||||
use Barryvdh\DomPDF\Facade\Pdf as PDF;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Facades\Vite;
|
||||
use Illuminate\Support\Str;
|
||||
use InvoiceShelf\Mail\SendInvoiceMail;
|
||||
use InvoiceShelf\Services\SerialNumberFormatter;
|
||||
use InvoiceShelf\Traits\GeneratesPdfTrait;
|
||||
use InvoiceShelf\Traits\HasCustomFieldsTrait;
|
||||
use Nwidart\Modules\Facades\Module;
|
||||
use Spatie\MediaLibrary\HasMedia;
|
||||
use Spatie\MediaLibrary\InteractsWithMedia;
|
||||
@@ -48,15 +51,6 @@ class Invoice extends Model implements HasMedia
|
||||
'due_date',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'total' => 'integer',
|
||||
'tax' => 'integer',
|
||||
'sub_total' => 'integer',
|
||||
'discount' => 'float',
|
||||
'discount_val' => 'integer',
|
||||
'exchange_rate' => 'float',
|
||||
];
|
||||
|
||||
protected $guarded = [
|
||||
'id',
|
||||
];
|
||||
@@ -68,52 +62,64 @@ class Invoice extends Model implements HasMedia
|
||||
'invoicePdfUrl',
|
||||
];
|
||||
|
||||
public function transactions()
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'total' => 'integer',
|
||||
'tax' => 'integer',
|
||||
'sub_total' => 'integer',
|
||||
'discount' => 'float',
|
||||
'discount_val' => 'integer',
|
||||
'exchange_rate' => 'float',
|
||||
];
|
||||
}
|
||||
|
||||
public function transactions(): HasMany
|
||||
{
|
||||
return $this->hasMany(Transaction::class);
|
||||
}
|
||||
|
||||
public function emailLogs()
|
||||
public function emailLogs(): MorphMany
|
||||
{
|
||||
return $this->morphMany('App\Models\EmailLog', 'mailable');
|
||||
}
|
||||
|
||||
public function items()
|
||||
public function items(): HasMany
|
||||
{
|
||||
return $this->hasMany('InvoiceShelf\Models\InvoiceItem');
|
||||
return $this->hasMany(\App\Models\InvoiceItem::class);
|
||||
}
|
||||
|
||||
public function taxes()
|
||||
public function taxes(): HasMany
|
||||
{
|
||||
return $this->hasMany(Tax::class);
|
||||
}
|
||||
|
||||
public function payments()
|
||||
public function payments(): HasMany
|
||||
{
|
||||
return $this->hasMany(Payment::class);
|
||||
}
|
||||
|
||||
public function currency()
|
||||
public function currency(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Currency::class);
|
||||
}
|
||||
|
||||
public function company()
|
||||
public function company(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Company::class);
|
||||
}
|
||||
|
||||
public function customer()
|
||||
public function customer(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Customer::class, 'customer_id');
|
||||
}
|
||||
|
||||
public function recurringInvoice()
|
||||
public function recurringInvoice(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(RecurringInvoice::class);
|
||||
}
|
||||
|
||||
public function creator()
|
||||
public function creator(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'creator_id');
|
||||
}
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace InvoiceShelf\Models;
|
||||
namespace App\Models;
|
||||
|
||||
use App\Traits\HasCustomFieldsTrait;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use InvoiceShelf\Traits\HasCustomFieldsTrait;
|
||||
|
||||
class InvoiceItem extends Model
|
||||
{
|
||||
@@ -17,31 +19,34 @@ class InvoiceItem extends Model
|
||||
'id',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'price' => 'integer',
|
||||
'total' => 'integer',
|
||||
'discount' => 'float',
|
||||
'quantity' => 'float',
|
||||
'discount_val' => 'integer',
|
||||
'tax' => 'integer',
|
||||
];
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'price' => 'integer',
|
||||
'total' => 'integer',
|
||||
'discount' => 'float',
|
||||
'quantity' => 'float',
|
||||
'discount_val' => 'integer',
|
||||
'tax' => 'integer',
|
||||
];
|
||||
}
|
||||
|
||||
public function invoice()
|
||||
public function invoice(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Invoice::class);
|
||||
}
|
||||
|
||||
public function item()
|
||||
public function item(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Item::class);
|
||||
}
|
||||
|
||||
public function taxes()
|
||||
public function taxes(): HasMany
|
||||
{
|
||||
return $this->hasMany(Tax::class);
|
||||
}
|
||||
|
||||
public function recurringInvoice()
|
||||
public function recurringInvoice(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(RecurringInvoice::class);
|
||||
}
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace InvoiceShelf\Models;
|
||||
namespace App\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class Item extends Model
|
||||
@@ -13,30 +15,33 @@ class Item extends Model
|
||||
|
||||
protected $guarded = ['id'];
|
||||
|
||||
protected $casts = [
|
||||
'price' => 'integer',
|
||||
];
|
||||
|
||||
protected $appends = [
|
||||
'formattedCreatedAt',
|
||||
];
|
||||
|
||||
public function unit()
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'price' => 'integer',
|
||||
];
|
||||
}
|
||||
|
||||
public function unit(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Unit::class, 'unit_id');
|
||||
}
|
||||
|
||||
public function company()
|
||||
public function company(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Company::class);
|
||||
}
|
||||
|
||||
public function creator()
|
||||
public function creator(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo('InvoiceShelf\Models\User', 'creator_id');
|
||||
return $this->belongsTo(\App\Models\User::class, 'creator_id');
|
||||
}
|
||||
|
||||
public function currency()
|
||||
public function currency(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Currency::class);
|
||||
}
|
||||
@@ -109,7 +114,7 @@ class Item extends Model
|
||||
return Carbon::parse($this->created_at)->format($dateFormat);
|
||||
}
|
||||
|
||||
public function taxes()
|
||||
public function taxes(): HasMany
|
||||
{
|
||||
return $this->hasMany(Tax::class)
|
||||
->where('invoice_item_id', null)
|
||||
@@ -121,12 +126,12 @@ class Item extends Model
|
||||
$query->where('items.company_id', request()->header('company'));
|
||||
}
|
||||
|
||||
public function invoiceItems()
|
||||
public function invoiceItems(): HasMany
|
||||
{
|
||||
return $this->hasMany(InvoiceItem::class);
|
||||
}
|
||||
|
||||
public function estimateItems()
|
||||
public function estimateItems(): HasMany
|
||||
{
|
||||
return $this->hasMany(EstimateItem::class);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace InvoiceShelf\Models;
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace InvoiceShelf\Models;
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class Note extends Model
|
||||
{
|
||||
@@ -11,7 +12,7 @@ class Note extends Model
|
||||
|
||||
protected $guarded = ['id'];
|
||||
|
||||
public function company()
|
||||
public function company(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Company::class);
|
||||
}
|
||||
|
||||
@@ -1,16 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace InvoiceShelf\Models;
|
||||
namespace App\Models;
|
||||
|
||||
use App\Jobs\GeneratePaymentPdfJob;
|
||||
use App\Mail\SendPaymentMail;
|
||||
use App\Services\SerialNumberFormatter;
|
||||
use App\Traits\GeneratesPdfTrait;
|
||||
use App\Traits\HasCustomFieldsTrait;
|
||||
use Barryvdh\DomPDF\Facade\Pdf as PDF;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use InvoiceShelf\Jobs\GeneratePaymentPdfJob;
|
||||
use InvoiceShelf\Mail\SendPaymentMail;
|
||||
use InvoiceShelf\Services\SerialNumberFormatter;
|
||||
use InvoiceShelf\Traits\GeneratesPdfTrait;
|
||||
use InvoiceShelf\Traits\HasCustomFieldsTrait;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
||||
use Spatie\MediaLibrary\HasMedia;
|
||||
use Spatie\MediaLibrary\InteractsWithMedia;
|
||||
use Vinkla\Hashids\Facades\Hashids;
|
||||
@@ -42,10 +44,13 @@ class Payment extends Model implements HasMedia
|
||||
'paymentPdfUrl',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'notes' => 'string',
|
||||
'exchange_rate' => 'float',
|
||||
];
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'notes' => 'string',
|
||||
'exchange_rate' => 'float',
|
||||
];
|
||||
}
|
||||
|
||||
protected static function booted()
|
||||
{
|
||||
@@ -84,42 +89,42 @@ class Payment extends Model implements HasMedia
|
||||
return url('/payments/pdf/'.$this->unique_hash);
|
||||
}
|
||||
|
||||
public function transaction()
|
||||
public function transaction(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Transaction::class);
|
||||
}
|
||||
|
||||
public function emailLogs()
|
||||
public function emailLogs(): MorphMany
|
||||
{
|
||||
return $this->morphMany('App\Models\EmailLog', 'mailable');
|
||||
}
|
||||
|
||||
public function customer()
|
||||
public function customer(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Customer::class, 'customer_id');
|
||||
}
|
||||
|
||||
public function company()
|
||||
public function company(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Company::class);
|
||||
}
|
||||
|
||||
public function invoice()
|
||||
public function invoice(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Invoice::class);
|
||||
}
|
||||
|
||||
public function creator()
|
||||
public function creator(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo('InvoiceShelf\Models\User', 'creator_id');
|
||||
return $this->belongsTo(\App\Models\User::class, 'creator_id');
|
||||
}
|
||||
|
||||
public function currency()
|
||||
public function currency(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Currency::class);
|
||||
}
|
||||
|
||||
public function paymentMethod()
|
||||
public function paymentMethod(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(PaymentMethod::class);
|
||||
}
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace InvoiceShelf\Models;
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class PaymentMethod extends Model
|
||||
{
|
||||
@@ -17,27 +19,30 @@ class PaymentMethod extends Model
|
||||
|
||||
public const TYPE_MODULE = 'MODULE';
|
||||
|
||||
protected $casts = [
|
||||
'settings' => 'array',
|
||||
'use_test_env' => 'boolean',
|
||||
];
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'settings' => 'array',
|
||||
'use_test_env' => 'boolean',
|
||||
];
|
||||
}
|
||||
|
||||
public function setSettingsAttribute($value)
|
||||
{
|
||||
$this->attributes['settings'] = json_encode($value);
|
||||
}
|
||||
|
||||
public function payments()
|
||||
public function payments(): HasMany
|
||||
{
|
||||
return $this->hasMany(Payment::class);
|
||||
}
|
||||
|
||||
public function expenses()
|
||||
public function expenses(): HasMany
|
||||
{
|
||||
return $this->hasMany(Expense::class);
|
||||
}
|
||||
|
||||
public function company()
|
||||
public function company(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Company::class);
|
||||
}
|
||||
|
||||
@@ -1,14 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace InvoiceShelf\Models;
|
||||
namespace App\Models;
|
||||
|
||||
use App\Http\Requests\RecurringInvoiceRequest;
|
||||
use App\Services\SerialNumberFormatter;
|
||||
use App\Traits\HasCustomFieldsTrait;
|
||||
use Carbon\Carbon;
|
||||
use Cron;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use InvoiceShelf\Http\Requests\RecurringInvoiceRequest;
|
||||
use InvoiceShelf\Services\SerialNumberFormatter;
|
||||
use InvoiceShelf\Traits\HasCustomFieldsTrait;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Vinkla\Hashids\Facades\Hashids;
|
||||
|
||||
class RecurringInvoice extends Model
|
||||
@@ -43,10 +45,13 @@ class RecurringInvoice extends Model
|
||||
'formattedLimitDate',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'exchange_rate' => 'float',
|
||||
'send_automatically' => 'boolean',
|
||||
];
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'exchange_rate' => 'float',
|
||||
'send_automatically' => 'boolean',
|
||||
];
|
||||
}
|
||||
|
||||
public function getFormattedStartsAtAttribute()
|
||||
{
|
||||
@@ -76,37 +81,37 @@ class RecurringInvoice extends Model
|
||||
return Carbon::parse($this->created_at)->format($dateFormat);
|
||||
}
|
||||
|
||||
public function invoices()
|
||||
public function invoices(): HasMany
|
||||
{
|
||||
return $this->hasMany(Invoice::class);
|
||||
}
|
||||
|
||||
public function taxes()
|
||||
public function taxes(): HasMany
|
||||
{
|
||||
return $this->hasMany(Tax::class);
|
||||
}
|
||||
|
||||
public function items()
|
||||
public function items(): HasMany
|
||||
{
|
||||
return $this->hasMany(InvoiceItem::class);
|
||||
}
|
||||
|
||||
public function customer()
|
||||
public function customer(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Customer::class);
|
||||
}
|
||||
|
||||
public function company()
|
||||
public function company(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Company::class);
|
||||
}
|
||||
|
||||
public function creator()
|
||||
public function creator(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'creator_id');
|
||||
}
|
||||
|
||||
public function currency()
|
||||
public function currency(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Currency::class);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace InvoiceShelf\Models;
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace InvoiceShelf\Models;
|
||||
namespace App\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class Tax extends Model
|
||||
@@ -15,47 +16,50 @@ class Tax extends Model
|
||||
'id',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'amount' => 'integer',
|
||||
'percent' => 'float',
|
||||
];
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'amount' => 'integer',
|
||||
'percent' => 'float',
|
||||
];
|
||||
}
|
||||
|
||||
public function taxType()
|
||||
public function taxType(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(TaxType::class);
|
||||
}
|
||||
|
||||
public function invoice()
|
||||
public function invoice(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Invoice::class);
|
||||
}
|
||||
|
||||
public function recurringInvoice()
|
||||
public function recurringInvoice(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(RecurringInvoice::class);
|
||||
}
|
||||
|
||||
public function estimate()
|
||||
public function estimate(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Estimate::class);
|
||||
}
|
||||
|
||||
public function currency()
|
||||
public function currency(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Currency::class);
|
||||
}
|
||||
|
||||
public function invoiceItem()
|
||||
public function invoiceItem(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(InvoiceItem::class);
|
||||
}
|
||||
|
||||
public function estimateItem()
|
||||
public function estimateItem(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(EstimateItem::class);
|
||||
}
|
||||
|
||||
public function item()
|
||||
public function item(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Item::class);
|
||||
}
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace InvoiceShelf\Models;
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class TaxType extends Model
|
||||
{
|
||||
@@ -13,21 +15,24 @@ class TaxType extends Model
|
||||
'id',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'percent' => 'float',
|
||||
'compound_tax' => 'boolean',
|
||||
];
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'percent' => 'float',
|
||||
'compound_tax' => 'boolean',
|
||||
];
|
||||
}
|
||||
|
||||
public const TYPE_GENERAL = 'GENERAL';
|
||||
|
||||
public const TYPE_MODULE = 'MODULE';
|
||||
|
||||
public function taxes()
|
||||
public function taxes(): HasMany
|
||||
{
|
||||
return $this->hasMany(Tax::class);
|
||||
}
|
||||
|
||||
public function company()
|
||||
public function company(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Company::class);
|
||||
}
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace InvoiceShelf\Models;
|
||||
namespace App\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Vinkla\Hashids\Facades\Hashids;
|
||||
|
||||
class Transaction extends Model
|
||||
@@ -25,17 +27,17 @@ class Transaction extends Model
|
||||
|
||||
public const SUCCESS = 'SUCCESS';
|
||||
|
||||
public function payments()
|
||||
public function payments(): HasMany
|
||||
{
|
||||
return $this->hasMany(Payment::class);
|
||||
}
|
||||
|
||||
public function invoice()
|
||||
public function invoice(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Invoice::class);
|
||||
}
|
||||
|
||||
public function company()
|
||||
public function company(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Company::class);
|
||||
}
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace InvoiceShelf\Models;
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class Unit extends Model
|
||||
{
|
||||
@@ -11,12 +13,12 @@ class Unit extends Model
|
||||
|
||||
protected $fillable = ['name', 'company_id'];
|
||||
|
||||
public function items()
|
||||
public function items(): HasMany
|
||||
{
|
||||
return $this->hasMany(Item::class);
|
||||
}
|
||||
|
||||
public function company()
|
||||
public function company(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Company::class);
|
||||
}
|
||||
|
||||
@@ -1,15 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace InvoiceShelf\Models;
|
||||
namespace App\Models;
|
||||
|
||||
use App\Http\Requests\UserRequest;
|
||||
use App\Notifications\MailResetPasswordNotification;
|
||||
use App\Traits\HasCustomFieldsTrait;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use InvoiceShelf\Http\Requests\UserRequest;
|
||||
use InvoiceShelf\Notifications\MailResetPasswordNotification;
|
||||
use InvoiceShelf\Traits\HasCustomFieldsTrait;
|
||||
use Laravel\Sanctum\HasApiTokens;
|
||||
use Silber\Bouncer\BouncerFacade;
|
||||
use Silber\Bouncer\Database\HasRolesAndAbilities;
|
||||
@@ -87,77 +91,80 @@ class User extends Authenticatable implements HasMedia
|
||||
|
||||
public function getFormattedCreatedAtAttribute($value)
|
||||
{
|
||||
$dateFormat = CompanySetting::getSetting('carbon_date_format', request()->header('company'));
|
||||
$company_id = (CompanySetting::where('company_id', request()->header('company'))->exists())
|
||||
? request()->header('company')
|
||||
: $this->companies()->first()->id;
|
||||
$dateFormat = CompanySetting::getSetting('carbon_date_format', $company_id);
|
||||
|
||||
return Carbon::parse($this->created_at)->format($dateFormat);
|
||||
}
|
||||
|
||||
public function estimates()
|
||||
public function estimates(): HasMany
|
||||
{
|
||||
return $this->hasMany(Estimate::class, 'creator_id');
|
||||
}
|
||||
|
||||
public function customers()
|
||||
public function customers(): HasMany
|
||||
{
|
||||
return $this->hasMany(Customer::class, 'creator_id');
|
||||
}
|
||||
|
||||
public function recurringInvoices()
|
||||
public function recurringInvoices(): HasMany
|
||||
{
|
||||
return $this->hasMany(RecurringInvoice::class, 'creator_id');
|
||||
}
|
||||
|
||||
public function currency()
|
||||
public function currency(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Currency::class, 'currency_id');
|
||||
}
|
||||
|
||||
public function creator()
|
||||
public function creator(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo('InvoiceShelf\Models\User', 'creator_id');
|
||||
return $this->belongsTo(\App\Models\User::class, 'creator_id');
|
||||
}
|
||||
|
||||
public function companies()
|
||||
public function companies(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Company::class, 'user_company', 'user_id', 'company_id');
|
||||
}
|
||||
|
||||
public function expenses()
|
||||
public function expenses(): HasMany
|
||||
{
|
||||
return $this->hasMany(Expense::class, 'creator_id');
|
||||
}
|
||||
|
||||
public function payments()
|
||||
public function payments(): HasMany
|
||||
{
|
||||
return $this->hasMany(Payment::class, 'creator_id');
|
||||
}
|
||||
|
||||
public function invoices()
|
||||
public function invoices(): HasMany
|
||||
{
|
||||
return $this->hasMany(Invoice::class, 'creator_id');
|
||||
}
|
||||
|
||||
public function items()
|
||||
public function items(): HasMany
|
||||
{
|
||||
return $this->hasMany(Item::class, 'creator_id');
|
||||
}
|
||||
|
||||
public function settings()
|
||||
public function settings(): HasMany
|
||||
{
|
||||
return $this->hasMany(UserSetting::class, 'user_id');
|
||||
}
|
||||
|
||||
public function addresses()
|
||||
public function addresses(): HasMany
|
||||
{
|
||||
return $this->hasMany(Address::class);
|
||||
}
|
||||
|
||||
public function billingAddress()
|
||||
public function billingAddress(): HasOne
|
||||
{
|
||||
return $this->hasOne(Address::class)->where('type', Address::BILLING_TYPE);
|
||||
}
|
||||
|
||||
public function shippingAddress()
|
||||
public function shippingAddress(): HasOne
|
||||
{
|
||||
return $this->hasOne(Address::class)->where('type', Address::SHIPPING_TYPE);
|
||||
}
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace InvoiceShelf\Models;
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class UserSetting extends Model
|
||||
{
|
||||
@@ -11,7 +12,7 @@ class UserSetting extends Model
|
||||
|
||||
protected $guarded = ['id'];
|
||||
|
||||
public function user()
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user