| 123456789101112131415 | 
							- <?php
 
- namespace App\Models;
 
- use Illuminate\Database\Eloquent\Model;
 
- class Moderate extends Model
 
- {
 
-   protected $casts = [ 'user_id' => 'integer', 'post_type' => 'string', 'post_id' => 'integer' ];
 
-   public function user() { return $this->hasMany(User::class, 'id', 'user_id'); }
 
-   public function comment() { return $this->hasMany(Comment::class, 'id', 'post_id'); }
 
-   public function post() { return $this->hasMany(Post::class, 'id', 'post_id'); }
 
-   public function scopeAllPost($query, $id){ return $query->where('post_type', "App\Models\Post")->where('post_id', $id)->with('user')->orderBy('created_at', 'desc')->get(); }
 
-   public function scopeAllComment($query, $id){ return $query->where('post_type', "App\Models\Comment")->where('post_id', $id)->with('user')->orderBy('created_at', 'desc')->get(); }
 
- }
 
 
  |