You've already forked lubo_comment_query
补充亿点内容,顺便立Flag
This commit is contained in:
10
app/Models/ProgramAppends.php
Normal file
10
app/Models/ProgramAppends.php
Normal file
@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class ProgramAppends extends Model
|
||||
{
|
||||
|
||||
}
|
18
app/Models/ProgramTags.php
Normal file
18
app/Models/ProgramTags.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class ProgramTags extends Model
|
||||
{
|
||||
public function tag(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Tags::class, "tag_id", "id");
|
||||
}
|
||||
|
||||
public function program(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Programs::class, "program_id", "id");
|
||||
}
|
||||
}
|
27
app/Models/ProgramVideos.php
Normal file
27
app/Models/ProgramVideos.php
Normal file
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Carbon;
|
||||
|
||||
class ProgramVideos extends Model
|
||||
{
|
||||
public function program(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Programs::class, "program_id", "id");
|
||||
}
|
||||
|
||||
public function video(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Videos::class, "video_bvid", "bvid");
|
||||
}
|
||||
|
||||
public function startSec(): Attribute
|
||||
{
|
||||
return Attribute::get(function ($_, $attributes) {
|
||||
return Carbon::createFromFormat("H:i:s", $attributes['start_time'])->secondsSinceMidnight();
|
||||
});
|
||||
}
|
||||
}
|
28
app/Models/Programs.php
Normal file
28
app/Models/Programs.php
Normal file
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Programs extends Model
|
||||
{
|
||||
public function appends(): \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
{
|
||||
return $this->hasMany(ProgramAppends::class, "program_id", "id")->orderByDesc("is_original");
|
||||
}
|
||||
|
||||
public function tags(): \Illuminate\Database\Eloquent\Relations\HasManyThrough
|
||||
{
|
||||
return $this->hasManyThrough(Tags::class, ProgramTags::class, "program_id", "id", "id", "tag_id");
|
||||
}
|
||||
|
||||
public function video_pivots(): \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
{
|
||||
return $this->hasMany(ProgramVideos::class, "program_id", "id");
|
||||
}
|
||||
|
||||
public function videos(): \Illuminate\Database\Eloquent\Relations\HasManyThrough
|
||||
{
|
||||
return $this->hasManyThrough(Videos::class, ProgramVideos::class, "program_id", "bvid", "id", "video_bvid");
|
||||
}
|
||||
}
|
13
app/Models/Tags.php
Normal file
13
app/Models/Tags.php
Normal file
@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Tags extends Model
|
||||
{
|
||||
public function programs(): \Illuminate\Database\Eloquent\Relations\HasManyThrough
|
||||
{
|
||||
return $this->hasManyThrough(Programs::class, ProgramTags::class, "tag_id", "id", "id", "program_id");
|
||||
}
|
||||
}
|
@ -10,4 +10,9 @@ class Videos extends Model
|
||||
{
|
||||
return $this->hasMany(VideoComments::class, "aid", "id");
|
||||
}
|
||||
|
||||
public function programs(): \Illuminate\Database\Eloquent\Relations\HasManyThrough
|
||||
{
|
||||
return $this->hasManyThrough(Programs::class, ProgramVideos::class, "video_bvid", "bvid", "id", "program_id");
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user