1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- <?php
- namespace App\Repositories\Models\Note;
- use App\Repositories\Models\Course\Course;
- use App\Repositories\Models\Course\Video;
- use App\Repositories\Models\Model;
- use App\Repositories\Models\User\User;
- use Prettus\Repository\Contracts\Transformable;
- use Prettus\Repository\Traits\TransformableTrait;
- /**
- * Class Note.
- *
- * @package namespace App\Repositories\Models\Note;
- */
- class Note extends Model implements Transformable
- {
- use TransformableTrait;
- const RELEASED_RAFT = 0;
- const RELEASED_ISSUE = 1;
- protected $table = 'node_notes';
- /**
- * The attributes that are mass assignable.
- *
- * @var array
- */
- protected $guarded = [];
- protected static function booted()
- {
- self::language();
- }
- public function user()
- {
- return $this->belongsTo(User::class)->select(['id', 'name', 'headimg']);
- }
- public function setTagsAttribute($val)
- {
- if (count($val) == 0) return '';
- $this->attributes['tags'] = '-' . arr2str($val, '-') . '-';
- }
- public function getTagsAttribute($val)
- {
- return str2arr(trim($val, '-'), '-');
- }
- public function course()
- {
- return $this->belongsTo(Course::class)->select(['title', 'id']);
- }
- public function video()
- {
- return $this->belongsTo(Video::class, 'course_video_id', 'id')->select(['title', 'id']);
- }
- }
|