mirror of
https://github.com/crater-invoice/crater.git
synced 2025-10-27 19:51:09 -04:00
v6 update
This commit is contained in:
@ -19,6 +19,9 @@ class Company extends Model implements HasMedia
|
||||
'id'
|
||||
];
|
||||
|
||||
public const COMPANY_LEVEL = 'company_level';
|
||||
public const CUSTOMER_LEVEL = 'customer_level';
|
||||
|
||||
protected $appends = ['logo', 'logo_path'];
|
||||
|
||||
public function getRolesAttribute()
|
||||
@ -241,7 +244,9 @@ class Company extends Model implements HasMedia
|
||||
'invoice_set_due_date_automatically' => 'YES',
|
||||
'invoice_due_date_days' => 7,
|
||||
'bulk_exchange_rate_configured' => 'YES',
|
||||
'estimate_convert_action' => 'no_action'
|
||||
'estimate_convert_action' => 'no_action',
|
||||
'automatically_expire_public_links' => 'YES',
|
||||
'link_expiry_days' => 7,
|
||||
];
|
||||
|
||||
CompanySetting::setSettings($settings, $this->id);
|
||||
|
||||
@ -2,7 +2,6 @@
|
||||
|
||||
namespace Crater\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
@ -14,6 +13,11 @@ class CustomField extends Model
|
||||
'id',
|
||||
];
|
||||
|
||||
protected $dates = [
|
||||
'date_answer',
|
||||
'date_time_answer'
|
||||
];
|
||||
|
||||
protected $appends = [
|
||||
'defaultAnswer',
|
||||
];
|
||||
@ -22,13 +26,6 @@ class CustomField extends Model
|
||||
'options' => 'array',
|
||||
];
|
||||
|
||||
public function setDateAnswerAttribute($value)
|
||||
{
|
||||
if ($value && $value != null) {
|
||||
$this->attributes['date_answer'] = Carbon::createFromFormat('Y-m-d', $value);
|
||||
}
|
||||
}
|
||||
|
||||
public function setTimeAnswerAttribute($value)
|
||||
{
|
||||
if ($value && $value != null) {
|
||||
@ -36,13 +33,6 @@ class CustomField extends Model
|
||||
}
|
||||
}
|
||||
|
||||
public function setDateTimeAnswerAttribute($value)
|
||||
{
|
||||
if ($value && $value != null) {
|
||||
$this->attributes['date_time_answer'] = Carbon::createFromFormat('Y-m-d H:i', $value);
|
||||
}
|
||||
}
|
||||
|
||||
public function setOptionsAttribute($value)
|
||||
{
|
||||
$this->attributes['options'] = json_encode($value);
|
||||
|
||||
@ -2,7 +2,6 @@
|
||||
|
||||
namespace Crater\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
@ -10,6 +9,11 @@ class CustomFieldValue extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $dates = [
|
||||
'date_answer',
|
||||
'date_time_answer'
|
||||
];
|
||||
|
||||
protected $guarded = [
|
||||
'id',
|
||||
];
|
||||
@ -18,13 +22,6 @@ class CustomFieldValue extends Model
|
||||
'defaultAnswer',
|
||||
];
|
||||
|
||||
public function setDateAnswerAttribute($value)
|
||||
{
|
||||
if ($value && $value != null) {
|
||||
$this->attributes['date_answer'] = Carbon::createFromFormat('Y-m-d', $value);
|
||||
}
|
||||
}
|
||||
|
||||
public function setTimeAnswerAttribute($value)
|
||||
{
|
||||
if ($value && $value != null) {
|
||||
@ -34,14 +31,6 @@ class CustomFieldValue extends Model
|
||||
}
|
||||
}
|
||||
|
||||
public function setDateTimeAnswerAttribute($value)
|
||||
{
|
||||
if ($value && $value != null) {
|
||||
$this->attributes['date_time_answer'] = Carbon::createFromFormat('Y-m-d H:i', $value);
|
||||
}
|
||||
$this->attributes['time_answer'] = null;
|
||||
}
|
||||
|
||||
public function getDefaultAnswerAttribute()
|
||||
{
|
||||
$value_type = getCustomFieldValueKey($this->type);
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
namespace Crater\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Crater\Notifications\CustomerMailResetPasswordNotification;
|
||||
use Crater\Traits\HasCustomFieldsTrait;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
@ -39,6 +40,10 @@ class Customer extends Authenticatable implements HasMedia
|
||||
'avatar'
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'enable_portal' => 'boolean',
|
||||
];
|
||||
|
||||
public function getFormattedCreatedAtAttribute($value)
|
||||
{
|
||||
$dateFormat = CompanySetting::getSetting('carbon_date_format', $this->company_id);
|
||||
@ -108,6 +113,11 @@ class Customer extends Authenticatable implements HasMedia
|
||||
return $this->hasOne(Address::class)->where('type', Address::SHIPPING_TYPE);
|
||||
}
|
||||
|
||||
public function sendPasswordResetNotification($token)
|
||||
{
|
||||
$this->notify(new CustomerMailResetPasswordNotification($token));
|
||||
}
|
||||
|
||||
public function getAvatarAttribute()
|
||||
{
|
||||
$avatar = $this->getMedia('customer_avatar')->first();
|
||||
|
||||
@ -1,40 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use Crater\Models\Currency;
|
||||
use Crater\Models\Customer;
|
||||
use Crater\Models\User;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
|
||||
class CustomerFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* The name of the factory's corresponding model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $model = Customer::class;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function definition()
|
||||
{
|
||||
return [
|
||||
'name' => $this->faker->name,
|
||||
'company_name' => $this->faker->company,
|
||||
'contact_name' => $this->faker->name,
|
||||
'website' => $this->faker->url,
|
||||
'enable_portal' => true,
|
||||
'email' => $this->faker->unique()->safeEmail,
|
||||
'phone' => $this->faker->phoneNumber,
|
||||
'company_id' => User::find(1)->companies()->first()->id,
|
||||
'password' => Hash::make('secret'),
|
||||
'currency_id' => Currency::find(1)->id,
|
||||
];
|
||||
}
|
||||
}
|
||||
@ -2,6 +2,7 @@
|
||||
|
||||
namespace Crater\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
@ -15,4 +16,18 @@ class EmailLog extends Model
|
||||
{
|
||||
return $this->morphTo();
|
||||
}
|
||||
|
||||
public function isExpired()
|
||||
{
|
||||
$linkexpiryDays = CompanySetting::getSetting('link_expiry_days', $this->mailable()->get()->toArray()[0]['company_id']);
|
||||
$checkExpiryLinks = CompanySetting::getSetting('automatically_expire_public_links', $this->mailable()->get()->toArray()[0]['company_id']);
|
||||
|
||||
$expiryDate = $this->created_at->addDays($linkexpiryDays);
|
||||
|
||||
if ($checkExpiryLinks == 'YES' && Carbon::now()->format('Y-m-d') > $expiryDate->format('Y-m-d')) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -35,6 +35,8 @@ class Estimate extends Model implements HasMedia
|
||||
'created_at',
|
||||
'updated_at',
|
||||
'deleted_at',
|
||||
'estimate_date',
|
||||
'expiry_date'
|
||||
];
|
||||
|
||||
protected $appends = [
|
||||
@ -54,20 +56,6 @@ class Estimate extends Model implements HasMedia
|
||||
'exchange_rate' => 'float'
|
||||
];
|
||||
|
||||
public function setEstimateDateAttribute($value)
|
||||
{
|
||||
if ($value) {
|
||||
$this->attributes['estimate_date'] = Carbon::createFromFormat('Y-m-d', $value);
|
||||
}
|
||||
}
|
||||
|
||||
public function setExpiryDateAttribute($value)
|
||||
{
|
||||
if ($value) {
|
||||
$this->attributes['expiry_date'] = Carbon::createFromFormat('Y-m-d', $value);
|
||||
}
|
||||
}
|
||||
|
||||
public function getEstimatePdfUrlAttribute()
|
||||
{
|
||||
return url('/estimates/pdf/'.$this->unique_hash);
|
||||
|
||||
@ -16,6 +16,10 @@ class Expense extends Model implements HasMedia
|
||||
use InteractsWithMedia;
|
||||
use HasCustomFieldsTrait;
|
||||
|
||||
protected $dates = [
|
||||
'expense_date',
|
||||
];
|
||||
|
||||
protected $guarded = ['id'];
|
||||
|
||||
protected $appends = [
|
||||
@ -30,13 +34,6 @@ class Expense extends Model implements HasMedia
|
||||
'exchange_rate' => 'float'
|
||||
];
|
||||
|
||||
public function setExpenseDateAttribute($value)
|
||||
{
|
||||
if ($value) {
|
||||
$this->attributes['expense_date'] = Carbon::createFromFormat('Y-m-d', $value);
|
||||
}
|
||||
}
|
||||
|
||||
public function category()
|
||||
{
|
||||
return $this->belongsTo(ExpenseCategory::class, 'expense_category_id');
|
||||
|
||||
@ -13,6 +13,7 @@ use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Str;
|
||||
use Nwidart\Modules\Facades\Module;
|
||||
use Spatie\MediaLibrary\HasMedia;
|
||||
use Spatie\MediaLibrary\InteractsWithMedia;
|
||||
use Vinkla\Hashids\Facades\Hashids;
|
||||
@ -39,6 +40,8 @@ class Invoice extends Model implements HasMedia
|
||||
'created_at',
|
||||
'updated_at',
|
||||
'deleted_at',
|
||||
'invoice_date',
|
||||
'due_date'
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
@ -61,18 +64,9 @@ class Invoice extends Model implements HasMedia
|
||||
'invoicePdfUrl',
|
||||
];
|
||||
|
||||
public function setInvoiceDateAttribute($value)
|
||||
public function transactions()
|
||||
{
|
||||
if ($value) {
|
||||
$this->attributes['invoice_date'] = Carbon::createFromFormat('Y-m-d', $value);
|
||||
}
|
||||
}
|
||||
|
||||
public function setDueDateAttribute($value)
|
||||
{
|
||||
if ($value) {
|
||||
$this->attributes['due_date'] = Carbon::createFromFormat('Y-m-d', $value);
|
||||
}
|
||||
return $this->hasMany(Transaction::class);
|
||||
}
|
||||
|
||||
public function emailLogs()
|
||||
@ -125,6 +119,15 @@ class Invoice extends Model implements HasMedia
|
||||
return url('/invoices/pdf/'.$this->unique_hash);
|
||||
}
|
||||
|
||||
public function getPaymentModuleEnabledAttribute()
|
||||
{
|
||||
if (Module::has('Payments')) {
|
||||
return Module::isEnabled('Payments');
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getAllowEditAttribute()
|
||||
{
|
||||
$retrospective_edit = CompanySetting::getSetting('retrospective_edits', $this->company_id);
|
||||
|
||||
13
app/Models/Module.php
Normal file
13
app/Models/Module.php
Normal file
@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace Crater\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Module extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $guarded = ['id'];
|
||||
}
|
||||
@ -28,7 +28,7 @@ class Payment extends Model implements HasMedia
|
||||
public const PAYMENT_MODE_CREDIT_CARD = 'CREDIT_CARD';
|
||||
public const PAYMENT_MODE_BANK_TRANSFER = 'BANK_TRANSFER';
|
||||
|
||||
protected $dates = ['created_at', 'updated_at'];
|
||||
protected $dates = ['created_at', 'updated_at', 'payment_date'];
|
||||
|
||||
protected $guarded = ['id'];
|
||||
|
||||
@ -54,10 +54,10 @@ class Payment extends Model implements HasMedia
|
||||
});
|
||||
}
|
||||
|
||||
public function setPaymentDateAttribute($value)
|
||||
public function setSettingsAttribute($value)
|
||||
{
|
||||
if ($value) {
|
||||
$this->attributes['payment_date'] = Carbon::createFromFormat('Y-m-d', $value);
|
||||
$this->attributes['settings'] = json_encode($value);
|
||||
}
|
||||
}
|
||||
|
||||
@ -80,6 +80,11 @@ class Payment extends Model implements HasMedia
|
||||
return url('/payments/pdf/'.$this->unique_hash);
|
||||
}
|
||||
|
||||
public function transaction()
|
||||
{
|
||||
return $this->belongsTo(Transaction::class);
|
||||
}
|
||||
|
||||
public function emailLogs()
|
||||
{
|
||||
return $this->morphMany('App\Models\EmailLog', 'mailable');
|
||||
@ -183,7 +188,7 @@ class Payment extends Model implements HasMedia
|
||||
|
||||
public function updatePayment($request)
|
||||
{
|
||||
$data = $request->all();
|
||||
$data = $request->getPaymentPayload();
|
||||
|
||||
if ($request->invoice_id && (! $this->invoice_id || $this->invoice_id !== $request->invoice_id)) {
|
||||
$invoice = Invoice::find($request->invoice_id);
|
||||
@ -427,7 +432,40 @@ class Payment extends Model implements HasMedia
|
||||
'{PAYMENT_MODE}' => $this->paymentMethod ? $this->paymentMethod->name : null,
|
||||
'{PAYMENT_NUMBER}' => $this->payment_number,
|
||||
'{PAYMENT_AMOUNT}' => $this->reference_number,
|
||||
'{PAYMENT_LINK}' => $this->paymentPdfUrl,
|
||||
'{PAYMENT_LINK}' => url('/customer/payments/pdf/'.$this->unique_hash)
|
||||
];
|
||||
}
|
||||
|
||||
public static function generatePayment($transaction)
|
||||
{
|
||||
$invoice = Invoice::find($transaction->invoice_id);
|
||||
|
||||
$serial = (new SerialNumberFormatter())
|
||||
->setModel(new Payment())
|
||||
->setCompany(request()->header('company'))
|
||||
->setCustomer($invoice->customer_id)
|
||||
->setNextNumbers();
|
||||
|
||||
$data['payment_number'] = $serial->getNextNumber();
|
||||
$data['payment_date'] = Carbon::now()->format('y-m-d');
|
||||
$data['amount'] = $invoice->total;
|
||||
$data['invoice_id'] = $invoice->id;
|
||||
$data['payment_method_id'] = request()->payment_method_id;
|
||||
$data['customer_id'] = $invoice->customer_id;
|
||||
$data['exchange_rate'] = $invoice->exchange_rate;
|
||||
$data['base_amount'] = $data['amount'] * $data['exchange_rate'];
|
||||
$data['currency_id'] = $invoice->currency_id;
|
||||
$data['company_id'] = request()->header('company');
|
||||
$data['transaction_id'] = $transaction->id;
|
||||
|
||||
$payment = Payment::create($data);
|
||||
$payment->unique_hash = Hashids::connection(Payment::class)->encode($payment->id);
|
||||
$payment->sequence_number = $serial->nextSequenceNumber;
|
||||
$payment->customer_sequence_number = $serial->nextCustomerSequenceNumber;
|
||||
$payment->save();
|
||||
|
||||
$invoice->subtractInvoicePayment($invoice->total);
|
||||
|
||||
return $payment;
|
||||
}
|
||||
}
|
||||
|
||||
@ -9,7 +9,22 @@ class PaymentMethod extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = ['name', 'company_id'];
|
||||
protected $guarded = [
|
||||
'id'
|
||||
];
|
||||
|
||||
public const TYPE_GENERAL = 'GENERAL';
|
||||
public const TYPE_MODULE = 'MODULE';
|
||||
|
||||
protected $casts = [
|
||||
'settings' => 'array',
|
||||
'use_test_env' => 'boolean'
|
||||
];
|
||||
|
||||
public function setSettingsAttribute($value)
|
||||
{
|
||||
$this->attributes['settings'] = json_encode($value);
|
||||
}
|
||||
|
||||
public function payments()
|
||||
{
|
||||
@ -33,7 +48,7 @@ class PaymentMethod extends Model
|
||||
|
||||
public function scopeWhereSearch($query, $search)
|
||||
{
|
||||
$query->where('name', 'LIKE', '%'.$search.'%');
|
||||
$query->where('name', 'LIKE', '%' . $search . '%');
|
||||
}
|
||||
|
||||
public function scopeApplyFilters($query, array $filters)
|
||||
@ -64,11 +79,19 @@ class PaymentMethod extends Model
|
||||
|
||||
public static function createPaymentMethod($request)
|
||||
{
|
||||
$data = $request->validated();
|
||||
$data['company_id'] = $request->header('company');
|
||||
$data = $request->getPaymentMethodPayload();
|
||||
|
||||
$paymentMethod = self::create($data);
|
||||
|
||||
return $paymentMethod;
|
||||
}
|
||||
|
||||
public static function getSettings($id)
|
||||
{
|
||||
$settings = PaymentMethod::whereCompany()
|
||||
->find($id)
|
||||
->settings;
|
||||
|
||||
return $settings;
|
||||
}
|
||||
}
|
||||
|
||||
@ -326,6 +326,8 @@ class RecurringInvoice extends Model
|
||||
$newInvoice['discount_type'] = $this->discount_type;
|
||||
$newInvoice['notes'] = $this->notes;
|
||||
$newInvoice['exchange_rate'] = $this->exchange_rate;
|
||||
$newInvoice['sales_tax_type'] = $this->sales_tax_type;
|
||||
$newInvoice['sales_tax_address_type'] = $this->sales_tax_address_type;
|
||||
$newInvoice['invoice_number'] = $serial->getNextNumber();
|
||||
$newInvoice['sequence_number'] = $serial->nextSequenceNumber;
|
||||
$newInvoice['customer_sequence_number'] = $serial->nextCustomerSequenceNumber;
|
||||
|
||||
@ -9,6 +9,8 @@ class Setting extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = ['option', 'value'];
|
||||
|
||||
public static function setSetting($key, $setting)
|
||||
{
|
||||
$old = self::whereOption($key)->first();
|
||||
@ -26,6 +28,21 @@ class Setting extends Model
|
||||
$set->save();
|
||||
}
|
||||
|
||||
public static function setSettings($settings)
|
||||
{
|
||||
foreach ($settings as $key => $value) {
|
||||
self::updateOrCreate(
|
||||
[
|
||||
'option' => $key,
|
||||
],
|
||||
[
|
||||
'option' => $key,
|
||||
'value' => $value,
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public static function getSetting($key)
|
||||
{
|
||||
$setting = static::whereOption($key)->first();
|
||||
@ -36,4 +53,12 @@ class Setting extends Model
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static function getSettings($settings)
|
||||
{
|
||||
return static::whereIn('option', $settings)
|
||||
->get()->mapWithKeys(function ($item) {
|
||||
return [$item['option'] => $item['value']];
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -9,13 +9,8 @@ class TaxType extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'percent',
|
||||
'company_id',
|
||||
'compound_tax',
|
||||
'collective_tax',
|
||||
'description',
|
||||
protected $guarded = [
|
||||
'id',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
@ -23,6 +18,9 @@ class TaxType extends Model
|
||||
'compound_tax' => 'boolean'
|
||||
];
|
||||
|
||||
public const TYPE_GENERAL = 'GENERAL';
|
||||
public const TYPE_MODULE = 'MODULE';
|
||||
|
||||
public function taxes()
|
||||
{
|
||||
return $this->hasMany(Tax::class);
|
||||
|
||||
75
app/Models/Transaction.php
Normal file
75
app/Models/Transaction.php
Normal file
@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
namespace Crater\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Vinkla\Hashids\Facades\Hashids;
|
||||
|
||||
class Transaction extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $guarded = [
|
||||
'id'
|
||||
];
|
||||
|
||||
protected $dates = [
|
||||
'transaction_date'
|
||||
];
|
||||
|
||||
public const PENDING = 'PENDING';
|
||||
public const FAILED = 'FAILED';
|
||||
public const SUCCESS = 'SUCCESS';
|
||||
|
||||
public function payments()
|
||||
{
|
||||
return $this->hasMany(Payment::class);
|
||||
}
|
||||
|
||||
public function invoice()
|
||||
{
|
||||
return $this->belongsTo(Invoice::class);
|
||||
}
|
||||
|
||||
public function company()
|
||||
{
|
||||
return $this->belongsTo(Company::class);
|
||||
}
|
||||
|
||||
public function completeTransaction()
|
||||
{
|
||||
$this->status = self::SUCCESS;
|
||||
$this->save();
|
||||
}
|
||||
|
||||
public function failedTransaction()
|
||||
{
|
||||
$this->status = self::FAILED;
|
||||
$this->save();
|
||||
}
|
||||
|
||||
public static function createTransaction($data)
|
||||
{
|
||||
$transaction = self::create($data);
|
||||
$transaction->unique_hash = Hashids::connection(Transaction::class)->encode($transaction->id);
|
||||
$transaction->save();
|
||||
|
||||
return $transaction;
|
||||
}
|
||||
|
||||
public function isExpired()
|
||||
{
|
||||
$linkexpiryDays = CompanySetting::getSetting('link_expiry_days', $this->company_id);
|
||||
$checkExpiryLinks = CompanySetting::getSetting('automatically_expire_public_links', $this->company_id);
|
||||
|
||||
$expiryDate = $this->updated_at->addDays($linkexpiryDays);
|
||||
|
||||
if ($checkExpiryLinks == 'YES' && $this->status == self::SUCCESS && Carbon::now()->format('Y-m-d') > $expiryDate->format('Y-m-d')) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -109,7 +109,7 @@ class User extends Authenticatable implements HasMedia
|
||||
|
||||
public function currency()
|
||||
{
|
||||
return $this->belongsTo(Currency::class);
|
||||
return $this->belongsTo(Currency::class, 'currency_id');
|
||||
}
|
||||
|
||||
public function creator()
|
||||
@ -147,6 +147,21 @@ class User extends Authenticatable implements HasMedia
|
||||
return $this->hasMany(UserSetting::class, 'user_id');
|
||||
}
|
||||
|
||||
public function addresses()
|
||||
{
|
||||
return $this->hasMany(Address::class);
|
||||
}
|
||||
|
||||
public function billingAddress()
|
||||
{
|
||||
return $this->hasOne(Address::class)->where('type', Address::BILLING_TYPE);
|
||||
}
|
||||
|
||||
public function shippingAddress()
|
||||
{
|
||||
return $this->hasOne(Address::class)->where('type', Address::SHIPPING_TYPE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Override the mail body for reset password notification mail.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user