File manager - Edit - /var/www/html/spdc/api/app/Models/Occurrency.php
Back
<?php namespace App\Models; use Carbon\Carbon; use App\Events\OccurrencySaving; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Casts\Attribute; use Illuminate\Database\Eloquent\Relations\HasOne; use Illuminate\Database\Eloquent\Concerns\HasUuids; use Illuminate\Database\Eloquent\Relations\HasMany; use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Relations\BelongsToMany; use Illuminate\Database\Eloquent\Relations\HasManyThrough; class Occurrency extends BaseModel { use HasFactory; use HasUuids; protected $table = 'occurrencies'; // Replace with your actual table name protected $fillable = [ 'auth_user_id', 'code', 'user', 'address_id', 'category_option_id', 'original_category_id', 'occurrency_requester_id', 'images', 'description' ]; protected $appends = [ 'date', 'hour', ]; protected $casts = [ 'user' => 'json', 'images' => 'json' ]; protected $with = [ 'address', 'requester', 'movements' ]; /** * The event map for the model. * * @var array */ protected $dispatchesEvents = [ 'saving' => OccurrencySaving::class, ]; /** * Returns creation date. * * @return \Illuminate\Database\Eloquent\Casts\Attribute */ protected function date(): Attribute { return new Attribute( get: fn () => Carbon::parse($this->created_at)->format('d/m/Y'), ); } /** * Returns creation time. * * @return \Illuminate\Database\Eloquent\Casts\Attribute */ protected function hour(): Attribute { return new Attribute( get: fn () => Carbon::parse($this->created_at)->format('H:m:s'), ); } /** * Get the address that owns the Occurrency * * @return \Illuminate\Database\Eloquent\Relations\BelongsTo */ public function address(): BelongsTo { return $this->belongsTo(Address::class); } /** * Get all of the forms for the Occurrency * * @return \Illuminate\Database\Eloquent\Relations\HasMany */ public function forms(): HasMany { return $this->hasMany(OccurrencyForm::class); } /** * Get all of the fields for the Occurrency * * @return \Illuminate\Database\Eloquent\Relations\HasManyThrough */ public function fields(): HasManyThrough { return $this->hasManyThrough(OccurrencyField::class, OccurrencyForm::class); } /** * Get the originalCategory that owns the Occurrency * * @return \Illuminate\Database\Eloquent\Relations\BelongsTo */ public function originalCategory(): BelongsTo { return $this->belongsTo(Category::class, 'original_category_id'); } /** * Get the category that owns the Occurrency * * @return \Illuminate\Database\Eloquent\Relations\BelongsTo */ public function category(): BelongsTo { return $this->belongsTo(CategoryOption::class, 'category_option_id'); } /** * The occurrencyTypes that belong to the Occurrency * * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany */ public function occurrencyTypes(): BelongsToMany { return $this->belongsToMany(OccurrencyType::class, 'occurrency_occurrency_type', 'occurrency_id', 'occurrency_type_id'); } /** * Get the inspection associated with the Occurrency * * @return \Illuminate\Database\Eloquent\Relations\HasOne */ public function inspection(): HasOne { return $this->hasOne(OccurrencyInspection::class); } /** * Get the execution associated with the Occurrency * * @return \Illuminate\Database\Eloquent\Relations\HasOne */ public function execution(): HasOne { return $this->hasOne(OccurrencyExecution::class); } /** * Get the requester that owns the Occurrency * * @return \Illuminate\Database\Eloquent\Relations\BelongsTo */ public function requester(): BelongsTo { return $this->belongsTo(OccurrencyRequester::class, 'occurrency_requester_id', 'id'); } /** * Get all of the scriptures for the Occurrency * * @return \Illuminate\Database\Eloquent\Relations\HasMany */ public function scriptures(): HasMany { return $this->hasMany(OccurrencyScripture::class); } /** * The schedules that belong to the Schedule * * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany */ public function schedules(): BelongsToMany { return $this->belongsToMany(Occurrency::class, 'schedule_occurrencies', 'occurrency_id', 'schedule_id'); } /** * Get all of the movements for the Occurrency * * @return \Illuminate\Database\Eloquent\Relations\HasMany */ public function movements(): HasMany { return $this->hasMany(OccurrencyMovement::class); } }
| ver. 1.4 |
Github
|
.
| PHP 8.3.28 | Generation time: 0.01 |
proxy
|
phpinfo
|
Settings