mirror of
https://github.com/Kovah/LinkAce.git
synced 2025-02-24 19:22:35 +01:00
75 lines
1.8 KiB
PHP
75 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
/**
|
|
* Class Note
|
|
*
|
|
* @package App\Models
|
|
* @property int $id
|
|
* @property int $user_id
|
|
* @property int $link_id
|
|
* @property string $note
|
|
* @property int $is_private
|
|
* @property \Carbon\Carbon|null $created_at
|
|
* @property \Carbon\Carbon|null $updated_at
|
|
* @property string|null $deleted_at
|
|
* @property-read \App\Models\Link $link
|
|
* @property-read \App\Models\User $user
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Link byUser($user_id)
|
|
*/
|
|
class Note extends Model
|
|
{
|
|
use SoftDeletes;
|
|
|
|
public $table = 'notes';
|
|
|
|
public $fillable = [
|
|
'user_id',
|
|
'link_id',
|
|
'note',
|
|
'is_private',
|
|
];
|
|
|
|
/*
|
|
| ========================================================================
|
|
| SCOPES
|
|
*/
|
|
|
|
/**
|
|
* Scope for the user relation
|
|
*
|
|
* @param \Illuminate\Database\Eloquent\Builder $query
|
|
* @param int $user_id
|
|
* @return mixed
|
|
*/
|
|
public function scopeByUser($query, $user_id)
|
|
{
|
|
return $query->where('user_id', $user_id);
|
|
}
|
|
|
|
/*
|
|
| ========================================================================
|
|
| RELATIONSHIPS
|
|
*/
|
|
|
|
/**
|
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
|
*/
|
|
public function user()
|
|
{
|
|
return $this->belongsTo('App\Models\User', 'user_id');
|
|
}
|
|
|
|
/**
|
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
|
*/
|
|
public function link()
|
|
{
|
|
return $this->belongsTo('App\Models\Link', 'link_id');
|
|
}
|
|
}
|