aswi2020merlot-gitlab/app/Artefact.php @ dc0fb924
1 |
<?php
|
---|---|
2 |
|
3 |
namespace App; |
4 |
|
5 |
use Illuminate\Database\Eloquent\Model; |
6 |
|
7 |
class Artefact extends Model |
8 |
{
|
9 |
// Table Name
|
10 |
protected $table = 'artafacts';//unnecessery? |
11 |
// Primary Key
|
12 |
public $primaryKey = 'id';//unnecessery? |
13 |
|
14 |
/**
|
15 |
* The model's default values for attributes.
|
16 |
*
|
17 |
* @var array
|
18 |
*/
|
19 |
protected $attributes = [ |
20 |
'likes' => 0, |
21 |
];
|
22 |
|
23 |
/**
|
24 |
* Indicates if the model should be timestamped.
|
25 |
*
|
26 |
* @var bool
|
27 |
*/
|
28 |
public $timestamps = false; |
29 |
|
30 |
/**
|
31 |
* Get the metadata for the artefact.
|
32 |
*/
|
33 |
public function metadata() |
34 |
{
|
35 |
return $this->hasMany('App\Metadata'); |
36 |
}
|
37 |
|
38 |
/**
|
39 |
* Get the main category for the artefact.
|
40 |
*/
|
41 |
public function main_category() |
42 |
{
|
43 |
return $this->hasOne('App\Category', 'main_category_id'); |
44 |
}
|
45 |
|
46 |
/**
|
47 |
* Get the categories for the artefact.
|
48 |
*/
|
49 |
public function categories() |
50 |
{
|
51 |
return $this->belongsToMany('App\Category'); |
52 |
}
|
53 |
|
54 |
|
55 |
|
56 |
|
57 |
}
|