aboutsummaryrefslogtreecommitdiffstats
path: root/source/app/Models/Message.php
blob: 8664b01f48643deb73eb030f9a71f1a469b1b4b1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class Message extends Model
{
    // Toegestane velden bij mass-assignment
    protected $fillable = [
        'sender_id',
        'receiver_id',
        'content',
        'timestamp',
    ];

    // Een bericht is verzonden door een gebruiker (student of bedrijf)
    public function sender(): BelongsTo
    {
        return $this->belongsTo(User::class, 'sender_id');
    }

    // Een bericht is ontvangen door een gebruiker (student of bedrijf)
    public function receiver(): BelongsTo
    {
        return $this->belongsTo(User::class, 'receiver_id');
    }
}