You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and dots ('.'), can be up to 35 characters long. Letters must be lowercase.
30 lines
568 B
30 lines
568 B
<?php |
|
|
|
namespace App\Models; |
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory; |
|
use Illuminate\Database\Eloquent\Model; |
|
|
|
class Album extends Model |
|
{ |
|
use HasFactory; |
|
|
|
protected $fillable = [ |
|
"name", |
|
"description", |
|
"created_at", |
|
"updated_at" |
|
]; |
|
|
|
public function articles() |
|
{ |
|
return $this->hasMany(Article::class); |
|
} |
|
|
|
public function images() |
|
{ |
|
$images = []; |
|
foreach($this->articles as $article) $images = array_merge($images, $article->images); |
|
return $images; |
|
} |
|
}
|
|
|