added invoice profile

This commit is contained in:
Peter Papp
2021-04-27 10:16:31 +02:00
parent f7135c9b27
commit e7c4048258
11 changed files with 232 additions and 145 deletions
-23
View File
@@ -37,11 +37,6 @@ class Invoice extends Model
return $this->hasOne(Client::class, 'id', 'user_id');
}
/**
* Index file
*
* @return array
*/
public function toSearchableArray()
{
$array = $this->toArray();
@@ -72,24 +67,6 @@ class Invoice extends Model
$invoice->total_tax = invoice_total_tax($invoice);
$invoice->currency = 'CZK';
$user = Auth::user() ?? User::find($invoice->user_id);
$invoice->author_name = $user->settings->name ?? null;
$invoice->author_stamp = ''; // TODO: doplnit
$invoice->user = [
'name' => $user->settings->name ?? null,
'address' => $user->settings->address ?? null,
'state' => $user->settings->state ?? null,
'city' => $user->settings->city ?? null,
'postal_code' => $user->settings->postcode ?? null,
'country' => $user->settings->country ?? null,
'phone_number' => $user->settings->phoneNumber ?? null,
'bank_name' => $user->settings->bank_name ?? null,
'iban' => $user->settings->iban ?? null,
'swift' => $user->settings->swift ?? null,
];
});
}
}
+33
View File
@@ -0,0 +1,33 @@
<?php
namespace App\Models\Oasis;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Str;
class InvoiceProfile extends Model
{
use HasFactory;
public $guarded = ['id'];
public $incrementing = false;
protected $keyType = 'string';
public function user()
{
return $this->hasOne(User::class, 'id', 'user_id');
}
protected static function boot()
{
parent::boot();
static::creating(function ($invoice) {
$invoice->id = (string) Str::uuid();
});
}
}