Ngiler SH3LL 360
Home
Information
Create File
Create Folder
:
/
home
/
tbf
/
tbfguestbe.tbf.ro
/
app
/
Models
/
Information Server
MySQL :
OFF
Perl :
OFF
CURL :
ON
WGET :
OFF
PKEXEC :
OFF
Directive
Local Value
IP Address
89.40.16.97
System
Linux server.atelieruldeit.ro 3.10.0-1160.el7.x86_64 #1 SMP Mon Oct 19 16:18:59 UTC 2020 x86_64
User
tbf
PHP Version
7.3.33
Software
Apache
Doc root
Writable
close
Edit File :
Position.php
| Size :
4.01
KB
Copy
<?php namespace App\Models; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Eloquent\Relations\BelongsToMany; use Illuminate\Database\Eloquent\Relations\HasMany; use Illuminate\Database\Eloquent\Relations\HasOne; use Illuminate\Database\Eloquent\SoftDeletes; class Position extends Model { use HasFactory, SoftDeletes; const IN_PROGRESS = 'in_progress'; const PROCESSING = 'processing'; const COMPLETED = 'completed'; const PROCESS_STATUS_NOT_STARTED = 'not_started'; const PROCESS_STATUS_IN_PROGRESS = 'in_progress'; const PROCESS_STATUS_FAILED = 'failed'; const PROCESS_STATUS_COMPLETED = 'completed'; protected $fillable = ['name', 'description', 'emoji', 'instance_id', 'module_id', 'max_users', 'activity_suggestions', 'status', 'evaluation_completed', 'need_for_recruitment', 'responsibility_process_status', 'procedure_process_status', 'recruitment_process_status']; /** @var array $casts */ protected $casts = [ 'instance_id' => 'int', 'module_id' => 'int', 'max_users' => 'int', 'activity_suggestions' => 'array', 'evaluation_completed' => 'bool', 'need_for_recruitment' => 'bool' ]; public static function boot(){ parent::boot(); self::creating(function(Position $position){ $authUser = auth()->user(); if ($authUser) { $position->instance_id = $authUser->instance_id; } $position->module_id = Module::RESPONSIBILITIES; }); static::deleting(function (Position $position) { $position->users()->update(['position_user.deleted_at' => now()]); }); } /** * The users that belong to the position. * * @return BelongsToMany */ public function users(): BelongsToMany { return $this->belongsToMany(User::class)->withPivot('is_responsible', 'status', 'deleted_at')->wherePivot('deleted_at', '=', null)->wherePivot('is_admin', '=', false)->withTimestamps(); } /** * The users with is_admin true, that belong to the position. * * @return BelongsToMany */ public function admins(): BelongsToMany { return $this->belongsToMany(User::class)->wherePivot('deleted_at', '=', null)->wherePivot('is_admin', '=', true)->withTimestamps(); } /** * The options that belong to the position. * * @return BelongsToMany */ public function options(): BelongsToMany { return $this->belongsToMany(Option::class)->withTimestamps(); } /** * The users that belong to the position. * * @return BelongsTo */ public function responsible(): BelongsTo { return $this->belongsTo(User::class, 'position_user')->wherePivot('is_responsible', true); } /** * The instance that belong to the position. * * @return BelongsTo */ public function instance(): BelongsTo { return $this->belongsTo(Instance::class); } /** * The module that belong to the position. * * @return BelongsTo */ public function module(): BelongsTo { return $this->belongsTo(Module::class); } /** * Activities * * @return HasMany */ public function activities(): HasMany { return $this->hasMany(Activity::class); } /** * Responsibility * * @return HasMany */ public function responsibilities(): HasMany { return $this->hasMany(Responsibility::class); } /** * Procedure * * @return HasMany */ public function procedures(): HasMany { return $this->hasMany(Procedure::class); } /** * Last recruitment * * @return HasOne */ public function recruitment(): HasOne { return $this->hasOne(Recruitment::class)->latest(); } }
Back