12345678910111213141516171819202122232425262728293031323334353637383940 |
- <?php
- /**
- * Created by PhpStorm.
- * User: Administrator
- * Date: 2019/6/5
- * Time: 16:24
- */
- namespace App\Models;
- use Illuminate\Database\Eloquent\Model;
- use Illuminate\Database\Eloquent\SoftDeletes;
- class Post extends Model
- {
- //
- use SoftDeletes;
- protected $table = 'post';
- protected $guarded = [];
- public function imgs()
- {
- return $this->hasMany('App\Models\PostImgs', 'post_id', 'id');
- }
- public function data()
- {
- return $this->hasOne('App\Models\PostData', 'post_id', 'id');
- }
- public function topic()
- {
- return Topic::whereIn('id', explode(',', $this->topic_ids))->pluck('name', 'id');
- }
- public function comment(){
- return $this->hasOne('App\Models\PostComment', 'post_id', 'id');
- }
- }
|