| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- <?php
- namespace App\Models;
- use Illuminate\Database\Eloquent\Factories\HasFactory;
- use Illuminate\Database\Eloquent\Model;
- /**
- * @property int $id
- * @property int|null $unit_id
- * @property int $applicant_user_id
- * @property int|null $responsable_user_id
- * @property int|null $student_id
- * @property string $title
- * @property string|null $description
- * @property string $severity
- * @property \Illuminate\Support\Carbon|null $created_at
- * @property \Illuminate\Support\Carbon|null $updated_at
- * @property string|null $deleted_at
- * @property string|null $scope
- * @property string|null $sector
- * @property string $status
- * @property string $origin
- * @property int|null $applicant_unit_id
- * @property int|null $target_unit_id
- * @property string|null $batch_id
- * @property-read \App\Models\Unit|null $applicantUnit
- * @property-read \App\Models\User $applicantUser
- * @property-read \App\Models\User|null $responsableUser
- * @property-read \App\Models\Unit|null $targetUnit
- * @method static \Illuminate\Database\Eloquent\Builder<static>|SupportTicket newModelQuery()
- * @method static \Illuminate\Database\Eloquent\Builder<static>|SupportTicket newQuery()
- * @method static \Illuminate\Database\Eloquent\Builder<static>|SupportTicket query()
- * @method static \Illuminate\Database\Eloquent\Builder<static>|SupportTicket visibleToUnit(int $unitId)
- * @method static \Illuminate\Database\Eloquent\Builder<static>|SupportTicket whereApplicantUnitId($value)
- * @method static \Illuminate\Database\Eloquent\Builder<static>|SupportTicket whereApplicantUserId($value)
- * @method static \Illuminate\Database\Eloquent\Builder<static>|SupportTicket whereBatchId($value)
- * @method static \Illuminate\Database\Eloquent\Builder<static>|SupportTicket whereCreatedAt($value)
- * @method static \Illuminate\Database\Eloquent\Builder<static>|SupportTicket whereDeletedAt($value)
- * @method static \Illuminate\Database\Eloquent\Builder<static>|SupportTicket whereDescription($value)
- * @method static \Illuminate\Database\Eloquent\Builder<static>|SupportTicket whereId($value)
- * @method static \Illuminate\Database\Eloquent\Builder<static>|SupportTicket whereOrigin($value)
- * @method static \Illuminate\Database\Eloquent\Builder<static>|SupportTicket whereResponsableUserId($value)
- * @method static \Illuminate\Database\Eloquent\Builder<static>|SupportTicket whereScope($value)
- * @method static \Illuminate\Database\Eloquent\Builder<static>|SupportTicket whereSector($value)
- * @method static \Illuminate\Database\Eloquent\Builder<static>|SupportTicket whereSeverity($value)
- * @method static \Illuminate\Database\Eloquent\Builder<static>|SupportTicket whereStatus($value)
- * @method static \Illuminate\Database\Eloquent\Builder<static>|SupportTicket whereStudentId($value)
- * @method static \Illuminate\Database\Eloquent\Builder<static>|SupportTicket whereTargetUnitId($value)
- * @method static \Illuminate\Database\Eloquent\Builder<static>|SupportTicket whereTitle($value)
- * @method static \Illuminate\Database\Eloquent\Builder<static>|SupportTicket whereUnitId($value)
- * @method static \Illuminate\Database\Eloquent\Builder<static>|SupportTicket whereUpdatedAt($value)
- * @mixin \Eloquent
- */
- class SupportTicket extends Model
- {
- use HasFactory;
- protected $table = 'support_tickets';
- protected $guarded = [
- 'id', // Add more fields that shouldn't be edited here
- ];
- protected $casts = [
- 'created_at' => 'datetime',
- 'updated_at' => 'datetime',
- // Add your casts here (e.g., 'is_active' => 'boolean')
- ];
- // Relationships
- public function applicantUnit()
- {
- return $this->belongsTo(\App\Models\Unit::class, 'applicant_unit_id');
- }
- public function targetUnit()
- {
- return $this->belongsTo(\App\Models\Unit::class, 'target_unit_id');
- }
- public function applicantUser()
- {
- return $this->belongsTo(\App\Models\User::class, 'applicant_user_id');
- }
- public function responsableUser()
- {
- return $this->belongsTo(\App\Models\User::class, 'responsable_user_id');
- }
- // Query Scopes
- public function scopeVisibleToUnit($query, int $unitId)
- {
- return $query->where(function ($q) use ($unitId) {
- $q->where('target_unit_id', $unitId)
- ->orWhere('applicant_unit_id', $unitId);
- });
- }
- }
|