2021-01-15 14:47:59 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Models;
|
|
|
|
|
|
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
|
|
|
|
|
|
class Contacts extends Model
|
|
|
|
|
{
|
|
|
|
|
public $incrementing = false;
|
|
|
|
|
protected $appends = ['owner_name'];
|
|
|
|
|
|
|
|
|
|
public function getOwnerNameAttribute() {
|
2022-05-11 17:32:50 +02:00
|
|
|
$owner = AppUser::find($this->user_id);
|
2021-01-15 14:47:59 +01:00
|
|
|
return $owner->surname . " " . $owner->firstname;
|
|
|
|
|
}
|
2022-05-11 17:32:50 +02:00
|
|
|
|
|
|
|
|
public function app_user()
|
|
|
|
|
{
|
|
|
|
|
return $this->belongsTo(AppUser::class, 'id', 'user_id');
|
|
|
|
|
}
|
2021-01-15 14:47:59 +01:00
|
|
|
}
|