2018-08-23 00:01:54 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Models;
|
|
|
|
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
|
2018-08-23 13:33:56 +02:00
|
|
|
/**
|
|
|
|
* 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
|
2018-08-31 12:09:56 +02:00
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Link byUser($user_id)
|
2018-08-23 13:33:56 +02:00
|
|
|
*/
|
2018-08-23 00:01:54 +02:00
|
|
|
class Note extends Model
|
|
|
|
{
|
|
|
|
use SoftDeletes;
|
|
|
|
|
|
|
|
public $table = 'notes';
|
|
|
|
|
|
|
|
public $fillable = [
|
|
|
|
'user_id',
|
2018-08-23 10:39:03 +02:00
|
|
|
'link_id',
|
2018-08-23 00:01:54 +02:00
|
|
|
'note',
|
|
|
|
'is_private',
|
|
|
|
];
|
|
|
|
|
|
|
|
/*
|
|
|
|
| ========================================================================
|
|
|
|
| SCOPES
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Scope for the user relation
|
|
|
|
*
|
2018-08-31 12:09:56 +02:00
|
|
|
* @param \Illuminate\Database\Eloquent\Builder $query
|
|
|
|
* @param int $user_id
|
2018-08-23 00:01:54 +02:00
|
|
|
* @return mixed
|
|
|
|
*/
|
2018-08-23 01:09:31 +02:00
|
|
|
public function scopeByUser($query, $user_id)
|
2018-08-23 00:01:54 +02:00
|
|
|
{
|
|
|
|
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');
|
|
|
|
}
|
|
|
|
}
|