MessagesRequests.php 609 Bytes
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class MessagesRequests extends Model
{
    use HasFactory;

    protected $fillable = [
        'user_id',
        'job_titles',
        'text',
        'is_rejected',
        'is_sent'
    ];

    public function getJobsAttribute()
    {
        $job_titles_ids = json_decode($this->attributes['job_titles'], true);
        return Job_title::whereIn('id', $job_titles_ids)->get();
    }

    public function user() {
        return $this->belongsTo(User::class, 'user_id');
    }
}