/ app / Models / Review.php
Review.php
 1  <?php
 2  
 3  namespace App\Models;
 4  
 5  use Illuminate\Database\Eloquent\Factories\HasFactory;
 6  use Illuminate\Database\Eloquent\Model;
 7  use Illuminate\Database\Eloquent\Relations\BelongsTo;
 8  
 9  class Review extends Model
10  {
11      use HasFactory;
12  
13      const APPROVAL = 'approval';
14  
15  
16      protected $fillable = ['author_id', 'role_id', 'has_passed', 'comment', 'type'];
17  
18  
19      public function revision(): BelongsTo
20      {
21          return $this->belongsTo(Revision::class);
22      }
23  
24      public function author(): BelongsTo
25      {
26          return $this->belongsTo(User::class, 'author_id');
27      }
28  
29      public function role()
30      {
31          return $this->belongsTo(Role::class);
32      }
33  
34      public function isApproval(): bool
35      {
36          return $this->type === self::APPROVAL;
37      }
38  
39      public function document()
40      {
41          //
42      }
43  
44      public static function reviewers()
45      {
46          return self::with('author')->get()->pluck('author')->unique('id');
47      }
48  }