mirror of
https://git.meshkee.com/cssd/cssd-back.git
synced 2026-10-12 09:41:05 +03:30
fix: change models namespace
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Kalnoy\Nestedset\NodeTrait;
|
||||
|
||||
class City extends Model
|
||||
{
|
||||
use NodeTrait;
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
|
||||
class Cycle extends Model
|
||||
{
|
||||
public $fillable = [
|
||||
'date', 'user_id', 'cycle_number', 'sterilizer_id', 'note', 'verified', 'unique_id'
|
||||
];
|
||||
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
public function labels(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Label::class, 'cycle_label')
|
||||
->withPivot('count');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Services\Media\HasMediaTrait;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Spatie\MediaLibrary\HasMedia;
|
||||
|
||||
class FakeModel extends Model implements HasMedia
|
||||
{
|
||||
use HasMediaTrait;
|
||||
|
||||
public $timestamps = false;
|
||||
|
||||
protected $fillable = ['batch_id'];
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Gallery extends Model
|
||||
{
|
||||
|
||||
protected $fillable = ['user_id', 'path'];
|
||||
public $timestamps = false;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class Input extends Model
|
||||
{
|
||||
public $fillable = [
|
||||
'name', 'type', 'size', 'test_type_id', 'parent_id', 'require_scanner'
|
||||
];
|
||||
|
||||
public function test_type(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(TestType::class);
|
||||
}
|
||||
|
||||
public function parent(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Input::class, 'parent_id');
|
||||
}
|
||||
|
||||
public function children(): HasMany
|
||||
{
|
||||
return $this->hasMany(Input::class, 'parent_id');
|
||||
}
|
||||
|
||||
public function options(): HasMany
|
||||
{
|
||||
return $this->hasMany(Option::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class InputValue extends Model
|
||||
{
|
||||
public $fillable = [
|
||||
'value', 'test_result_id', 'input_id', 'option_id'
|
||||
];
|
||||
|
||||
public function input(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Input::class);
|
||||
}
|
||||
|
||||
public function test_result(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(TestResult::class);
|
||||
}
|
||||
|
||||
public function option(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Option::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Constants\StatusTypeEnum;
|
||||
use App\Services\Media\HasMediaTrait;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphOne;
|
||||
use Spatie\Image\Exceptions\InvalidManipulation;
|
||||
use Spatie\MediaLibrary\HasMedia;
|
||||
use Spatie\MediaLibrary\MediaCollections\Models\Media;
|
||||
|
||||
class Item extends Model implements HasMedia
|
||||
{
|
||||
use HasMediaTrait;
|
||||
|
||||
public $fillable = [
|
||||
'name', 'size', 'unique_id', 'specific', 'note', 'user_id', 'udi', 'status', 'repair',
|
||||
'package_id', 'creator_id'
|
||||
];
|
||||
|
||||
public function scopeIsNotRepaired($query)
|
||||
{
|
||||
return $query->where('repair', 0);
|
||||
}
|
||||
|
||||
public function package(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Package::class);
|
||||
}
|
||||
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
public function creator(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, "creator_id");
|
||||
}
|
||||
|
||||
public function transfersAll(): MorphMany
|
||||
{
|
||||
return $this->morphMany(Transfer::class, "transferable")->orderBy("id", "desc");
|
||||
}
|
||||
|
||||
public function transfers(): MorphMany
|
||||
{
|
||||
return $this->morphMany(Transfer::class, "transferable")
|
||||
->where("status", StatusTypeEnum::APPROVED)
|
||||
->orderBy("id", "desc");
|
||||
}
|
||||
|
||||
public function latestTransfer(): MorphOne
|
||||
{
|
||||
return $this->morphOne(Transfer::class, "transferable")
|
||||
->where("status", StatusTypeEnum::APPROVED)
|
||||
->orderBy("id", "desc")->latest();
|
||||
}
|
||||
|
||||
public function transferActive(): MorphMany
|
||||
{
|
||||
return $this->morphMany(Transfer::class, "transferable")
|
||||
->where("status", StatusTypeEnum::APPROVED)
|
||||
->whereNull("to_date")
|
||||
->orderBy("id", "desc");
|
||||
}
|
||||
|
||||
public function registerMediaCollections(): void
|
||||
{
|
||||
$this->addMediaCollection('files')
|
||||
->useFallbackUrl('/files/default_pastry.jpg')
|
||||
->useFallbackPath(public_path('/files/default_pastry.jpg'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws InvalidManipulation
|
||||
*/
|
||||
public function registerMediaConversions(Media $media = null): void
|
||||
{
|
||||
$this->addMediaConversion('thumbnail')
|
||||
->width(480)
|
||||
->height(640)
|
||||
->nonQueued()
|
||||
->performOnCollections('files');
|
||||
}
|
||||
|
||||
protected static function getValidCollections(): array
|
||||
{
|
||||
return [
|
||||
'files'
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
|
||||
class Label extends Model
|
||||
{
|
||||
public $fillable = [
|
||||
'sterile_date', 'expire_date', 'sterilizer_id', 'cycle_number', 'lot_number', 'user_id',
|
||||
'package_id'
|
||||
];
|
||||
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
public function package(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Package::class);
|
||||
}
|
||||
|
||||
public function cycles(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Cycle::class, 'cycle_label')
|
||||
->withPivot('count');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class MedicalCenter extends Model
|
||||
{
|
||||
public $fillable = ['name', 'city_id', 'address', 'phone_number'];
|
||||
|
||||
public function users(): HasMany
|
||||
{
|
||||
return $this->hasMany(User::class);
|
||||
}
|
||||
|
||||
public function city(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(City::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Message extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
public $fillable = ['title', 'text', 'status', 'recipient_user_id', 'sender_user_id'];
|
||||
|
||||
public function sender_user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'sender_user_id');
|
||||
}
|
||||
|
||||
public function recipient_user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'recipient_user_id');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||
|
||||
class Option extends Model
|
||||
{
|
||||
public $fillable = ['title', 'input_id'];
|
||||
|
||||
public function input(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Input::class);
|
||||
}
|
||||
|
||||
public function input_value(): HasOne
|
||||
{
|
||||
return $this->hasOne(InputValue::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Constants\StatusTypeEnum;
|
||||
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\Database\Eloquent\Relations\MorphOne;
|
||||
|
||||
class Package extends Model
|
||||
{
|
||||
public $fillable = ['name', 'user_id', 'note', 'status', 'creator_id'];
|
||||
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
public function creator(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, "creator_id");
|
||||
}
|
||||
|
||||
public function items(): HasMany
|
||||
{
|
||||
return $this->hasMany(Item::class);
|
||||
}
|
||||
|
||||
public function labels(): HasMany
|
||||
{
|
||||
return $this->hasMany(Label::class);
|
||||
}
|
||||
|
||||
public function transfersAll(): MorphMany
|
||||
{
|
||||
return $this->morphMany(Transfer::class, "transferable")
|
||||
->orderBy("id", "desc");
|
||||
}
|
||||
|
||||
public function transfers(): MorphMany
|
||||
{
|
||||
return $this->morphMany(Transfer::class, "transferable")
|
||||
->where("status", StatusTypeEnum::APPROVED)
|
||||
->orderBy("id", "desc");
|
||||
}
|
||||
|
||||
public function latestTransfer(): MorphOne
|
||||
{
|
||||
return $this->morphOne(Transfer::class, "transferable")
|
||||
->where("status", StatusTypeEnum::APPROVED)
|
||||
->orderBy("id", "desc")
|
||||
->latest();
|
||||
}
|
||||
|
||||
public function transferActive(): MorphMany
|
||||
{
|
||||
return $this->morphMany(Transfer::class, "transferable")
|
||||
->where("status", StatusTypeEnum::APPROVED)
|
||||
->whereNull("to_date")
|
||||
->orderBy("id", "desc");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Services\Media\HasMediaTrait;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Spatie\Image\Exceptions\InvalidManipulation;
|
||||
use Spatie\MediaLibrary\HasMedia;
|
||||
use Spatie\MediaLibrary\MediaCollections\Models\Media;
|
||||
|
||||
class TestResult extends Model implements HasMedia
|
||||
{
|
||||
use HasMediaTrait;
|
||||
|
||||
public $fillable = ['result', 'verified', 'test_type_id', 'user_id', 'device_id', 'cycle_number', 'date'];
|
||||
|
||||
public function test_type(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(TestType::class);
|
||||
}
|
||||
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
public function input_values(): HasMany
|
||||
{
|
||||
return $this->hasMany(InputValue::class);
|
||||
}
|
||||
|
||||
public function registerMediaCollections(): void
|
||||
{
|
||||
$this->addMediaCollection('files')
|
||||
->useFallbackUrl('/files/default_pastry.jpg')
|
||||
->useFallbackPath(public_path('/files/default_pastry.jpg'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws InvalidManipulation
|
||||
*/
|
||||
public function registerMediaConversions(Media $media = null): void
|
||||
{
|
||||
$this->addMediaConversion('thumbnail')
|
||||
->width(480)
|
||||
->height(640)
|
||||
->nonQueued()
|
||||
->performOnCollections('files');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class TestType extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
public $fillable = ['name', 'unique_code', 'user_id', 'bar_code', 'device_label'];
|
||||
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
public function test_results(): HasMany
|
||||
{
|
||||
return $this->hasMany(TestResult::class);
|
||||
}
|
||||
|
||||
public function inputs(): HasMany
|
||||
{
|
||||
return $this->hasMany(Input::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Transfer extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
public $fillable = ['user_id', 'to_date', 'from_date', 'status', 'user_transfer_id'];
|
||||
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
public function userTransfer(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'user_transfer_id');
|
||||
}
|
||||
|
||||
public function transferable(): MorphTo
|
||||
{
|
||||
return $this->morphTo();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class Uploadable extends Model
|
||||
{
|
||||
|
||||
protected $fillable = [
|
||||
'uploadable_id', 'uploadable_type', 'gallery_id', 'image_role', 'batch_id'
|
||||
];
|
||||
public $timestamps = false;
|
||||
|
||||
public function gallery(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Gallery::class);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Laravel\Passport\HasApiTokens;
|
||||
use Spatie\Permission\Traits\HasRoles;
|
||||
|
||||
class User extends Authenticatable
|
||||
{
|
||||
use Notifiable, HasApiTokens, HasRoles;
|
||||
|
||||
protected $fillable = [
|
||||
'name', 'email', 'cell_number', 'password', 'status', 'medical_center_id', 'address',
|
||||
'gender'
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'password', 'remember_token',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'email_verified_at' => 'datetime',
|
||||
];
|
||||
|
||||
public function medical_center(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(MedicalCenter::class);
|
||||
}
|
||||
|
||||
public function test_results(): HasMany
|
||||
{
|
||||
return $this->hasMany(TestResult::class);
|
||||
}
|
||||
|
||||
public function test_types(): HasMany
|
||||
{
|
||||
return $this->hasMany(TestType::class);
|
||||
}
|
||||
|
||||
public function findForPassport($username)
|
||||
{
|
||||
return $this->where('cell_number', $username)->where('status', 'Active')->first();
|
||||
}
|
||||
|
||||
public function messagesSent(): HasMany
|
||||
{
|
||||
return $this->hasMany(Message::class, 'sender_user_id');
|
||||
}
|
||||
|
||||
public function messagesReceived(): HasMany
|
||||
{
|
||||
return $this->hasMany(Message::class, 'recipient_user_id');
|
||||
}
|
||||
|
||||
public function packages(): HasMany
|
||||
{
|
||||
return $this->hasMany(Package::class);
|
||||
}
|
||||
|
||||
public function items(): HasMany
|
||||
{
|
||||
return $this->hasMany(Item::class);
|
||||
}
|
||||
|
||||
public function labels(): HasMany
|
||||
{
|
||||
return $this->hasMany(Label::class);
|
||||
}
|
||||
|
||||
public function cycles(): HasMany
|
||||
{
|
||||
return $this->hasMany(Cycle::class);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user