first commit
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Package extends Model
|
||||
{
|
||||
protected $table = 'store_packages';
|
||||
|
||||
protected $fillable = [
|
||||
'type',
|
||||
'slug',
|
||||
'name',
|
||||
'summary',
|
||||
'description',
|
||||
'author',
|
||||
'homepage',
|
||||
'icon_url',
|
||||
'license',
|
||||
'status',
|
||||
'is_featured',
|
||||
'sort_order',
|
||||
'download_count',
|
||||
'latest_version',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'is_featured' => 'boolean',
|
||||
];
|
||||
|
||||
public function versions()
|
||||
{
|
||||
return $this->hasMany(Version::class, 'package_id');
|
||||
}
|
||||
|
||||
public function latestStableVersion()
|
||||
{
|
||||
return $this->hasOne(Version::class, 'package_id')
|
||||
->where('is_stable', 1)
|
||||
->where('is_latest', 1);
|
||||
}
|
||||
|
||||
public function latestVersion()
|
||||
{
|
||||
return $this->hasOne(Version::class, 'package_id')
|
||||
->where('is_latest', 1);
|
||||
}
|
||||
|
||||
public function screenshots()
|
||||
{
|
||||
return $this->hasMany(Screenshot::class, 'package_id')->orderBy('sort_order')->orderBy('id');
|
||||
}
|
||||
|
||||
public function categories()
|
||||
{
|
||||
return $this->belongsToMany(Category::class, 'store_package_categories', 'package_id', 'category_id');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user