mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-05-19 19:55:02 +00:00
- removed invoicing from oasis
This commit is contained in:
@@ -1,96 +0,0 @@
|
||||
<?php
|
||||
namespace App\Models\Oasis;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Str;
|
||||
use Kyslik\ColumnSortable\Sortable;
|
||||
use Laravel\Scout\Searchable;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use TeamTNT\TNTSearch\Indexer\TNTIndexer;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
|
||||
/**
|
||||
* @method static whereUserId($id)
|
||||
*/
|
||||
class Client extends Model
|
||||
{
|
||||
use HasFactory, Searchable, Sortable;
|
||||
|
||||
public $guarded = ['id'];
|
||||
|
||||
public $incrementing = false;
|
||||
|
||||
protected $keyType = 'string';
|
||||
|
||||
public $sortable = [
|
||||
'created_at',
|
||||
'name',
|
||||
];
|
||||
|
||||
/**
|
||||
* Format avatar to full url
|
||||
*
|
||||
* @return \Illuminate\Contracts\Routing\UrlGenerator|string
|
||||
*/
|
||||
public function getAvatarAttribute()
|
||||
{
|
||||
// Get avatar from external storage
|
||||
if ($this->attributes['avatar'] && ! is_storage_driver('local')) {
|
||||
return Storage::temporaryUrl($this->attributes['avatar'], now()->addDay());
|
||||
}
|
||||
|
||||
// Get avatar from local storage
|
||||
if ($this->attributes['avatar']) {
|
||||
return url('/' . $this->attributes['avatar']);
|
||||
}
|
||||
|
||||
return url('/assets/images/default-avatar.png');
|
||||
}
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->hasOne(User::class, 'id', 'user_id');
|
||||
}
|
||||
|
||||
public function invoices()
|
||||
{
|
||||
return $this->hasMany(Invoice::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Index file
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function toSearchableArray()
|
||||
{
|
||||
$array = $this->toArray();
|
||||
|
||||
$client_name = Str::slug($array['name'], ' ');
|
||||
$client_email = Str::slug($array['email'], ' ');
|
||||
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'clientName' => $array['name'],
|
||||
'clientNameNgrams' => utf8_encode((new TNTIndexer)->buildTrigrams(implode(', ', [$client_name]))),
|
||||
'clientEmail' => $array['email'],
|
||||
'clientEmailNgrams' => utf8_encode((new TNTIndexer)->buildTrigrams(implode(', ', [$client_email]))),
|
||||
];
|
||||
}
|
||||
|
||||
protected static function boot()
|
||||
{
|
||||
parent::boot();
|
||||
|
||||
static::creating(function ($client) {
|
||||
$client->id = (string) Str::uuid();
|
||||
});
|
||||
|
||||
static::deleting(function ($client) {
|
||||
if ($client->getRawOriginal('avatar')) {
|
||||
Storage::delete($client->getRawOriginal('avatar'));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,84 +0,0 @@
|
||||
<?php
|
||||
namespace App\Models\Oasis;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Str;
|
||||
use Laravel\Scout\Searchable;
|
||||
use Kyslik\ColumnSortable\Sortable;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use TeamTNT\TNTSearch\Indexer\TNTIndexer;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
|
||||
class Invoice extends Model
|
||||
{
|
||||
use HasFactory, Searchable, Sortable;
|
||||
|
||||
protected $casts = [
|
||||
'items' => 'array',
|
||||
'user' => 'array',
|
||||
'client' => 'array',
|
||||
];
|
||||
|
||||
public $guarded = [
|
||||
'id',
|
||||
];
|
||||
|
||||
public $sortable = [
|
||||
'invoice_number',
|
||||
'created_at',
|
||||
'total_net',
|
||||
];
|
||||
|
||||
public $incrementing = false;
|
||||
|
||||
protected $keyType = 'string';
|
||||
|
||||
public function author()
|
||||
{
|
||||
return $this->hasOne(User::class, 'id', 'user_id');
|
||||
}
|
||||
|
||||
public function client()
|
||||
{
|
||||
return $this->hasOne(Client::class, 'id', 'user_id');
|
||||
}
|
||||
|
||||
public function toSearchableArray()
|
||||
{
|
||||
$array = $this->toArray();
|
||||
|
||||
$client_name = Str::slug($array['client']['name'], ' ');
|
||||
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'clientName' => $array['client']['name'],
|
||||
'clientNameNgrams' => utf8_encode((new TNTIndexer)->buildTrigrams(implode(', ', [$client_name]))),
|
||||
'invoiceNumber' => $array['invoice_number'],
|
||||
'invoiceNumberNgrams' => utf8_encode((new TNTIndexer)->buildTrigrams(implode(', ', [$array['invoice_number']]))),
|
||||
];
|
||||
}
|
||||
|
||||
protected static function boot()
|
||||
{
|
||||
parent::boot();
|
||||
|
||||
static::creating(function ($invoice) {
|
||||
$invoice->id = (string) Str::uuid();
|
||||
|
||||
$invoice->total_net = invoice_total($invoice);
|
||||
$invoice->total_tax = invoice_total_tax($invoice);
|
||||
|
||||
$invoice->currency = 'CZK';
|
||||
});
|
||||
|
||||
static::updating(function ($invoice) {
|
||||
$invoice->total_net = invoice_total($invoice);
|
||||
$invoice->total_tax = invoice_total_tax($invoice);
|
||||
});
|
||||
|
||||
static::deleting(function ($invoice) {
|
||||
Storage::delete(invoice_path($invoice));
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
<?php
|
||||
namespace App\Models\Oasis;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
|
||||
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();
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user