123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- <?php
- namespace App\Repositories\Models\Note;
- use App\Repositories\Models\Course\Category;
- 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(['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 category()
- {
- return $this->belongsTo(Category::class, 'course_category_id', 'id')->select(['name']);
- }
- }
|