-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: created the models and added relationships for the reporting fu…
…nctionality
- Loading branch information
1 parent
a0c6ddd
commit b4f4b77
Showing
5 changed files
with
97 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<?php | ||
|
||
namespace App\Models; | ||
|
||
use Illuminate\Database\Eloquent\Factories\HasFactory; | ||
use Illuminate\Database\Eloquent\Model; | ||
use Illuminate\Database\Eloquent\Relations\BelongsTo; | ||
use Illuminate\Database\Eloquent\Relations\BelongsToMany; | ||
use Illuminate\Database\Eloquent\Relations\HasMany; | ||
use Illuminate\Database\Eloquent\Relations\HasOne; | ||
use Illuminate\Database\Eloquent\Relations\MorphToMany; | ||
use OwenIt\Auditing\Contracts\Auditable; | ||
|
||
class Report extends Model implements Auditable | ||
{ | ||
use HasFactory; | ||
use \OwenIt\Auditing\Auditable; | ||
|
||
/** | ||
* The attributes that are mass assignable. | ||
* | ||
* @var array<int, string> | ||
*/ | ||
protected $fillable = [ | ||
'title', | ||
'evidence', | ||
'url', | ||
'status', | ||
'comment', | ||
|
||
]; | ||
|
||
/** | ||
* Get all of the collections that are assigned this report. | ||
*/ | ||
public function collections(): MorphToMany | ||
{ | ||
return $this->morphedByMany(Collection::class, 'reportable'); | ||
} | ||
|
||
/** | ||
* Get all of the molecules that are assigned this repot. | ||
*/ | ||
public function molecules(): MorphToMany | ||
{ | ||
return $this->morphedByMany(Molecule::class, 'reportable'); | ||
} | ||
|
||
/** | ||
* Get all of the citations that are assigned this report. | ||
*/ | ||
public function citations(): MorphToMany | ||
{ | ||
return $this->morphedByMany(Citation::class, 'reportable'); | ||
} | ||
|
||
/** | ||
* Get all of the users that are assigned this report. | ||
*/ | ||
public function users(): MorphToMany | ||
{ | ||
return $this->morphedByMany(User::class, 'reportable'); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters