2020-06-30 06:48:51 +00:00
|
|
|
<?php
|
|
|
|
|
2020-07-27 08:43:22 +00:00
|
|
|
//The Model to a certain Controller, should contain a class with Controller name to which it belongs.
|
2020-07-27 10:40:45 +00:00
|
|
|
// Allows needed strings to passed onto the database. if there is none needed. the class should appear empty.
|
2020-07-27 08:43:22 +00:00
|
|
|
|
|
|
|
//Reference to where the file belongs.
|
2020-06-30 06:48:51 +00:00
|
|
|
namespace App;
|
|
|
|
|
2020-07-27 08:43:22 +00:00
|
|
|
//allows the use of Model library
|
2020-06-30 06:48:51 +00:00
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
|
2020-07-27 08:43:22 +00:00
|
|
|
//Class of which should extend Model Library
|
2020-06-30 06:48:51 +00:00
|
|
|
class Album extends Model
|
|
|
|
{
|
2020-07-27 10:40:45 +00:00
|
|
|
//protected variable which contains name of database field(s) to be filled.
|
2020-06-30 07:19:35 +00:00
|
|
|
protected $fillable = [
|
|
|
|
'name'
|
|
|
|
];
|
|
|
|
|
|
|
|
public function parentAlbum()
|
|
|
|
{
|
|
|
|
return $this->belongsTo('App\Album');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function images()
|
|
|
|
{
|
|
|
|
return $this->hasMany('App\Image');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function videos()
|
|
|
|
{
|
|
|
|
return $this->hasMany('App\Video');
|
|
|
|
}
|
2020-06-30 06:48:51 +00:00
|
|
|
}
|