Tag顺序问题
This commit is contained in:
parent
9075fd29b8
commit
710a9f44a5
@ -10,7 +10,7 @@ class ProgramQueryController extends BaseController
|
|||||||
{
|
{
|
||||||
public function index() {
|
public function index() {
|
||||||
$keyword = request()->get("keyword", "");
|
$keyword = request()->get("keyword", "");
|
||||||
$programs = Programs::query()->with(["appends", "tags", "video_pivots.video"])->limit(15)->orderByDesc("created_at")->get();
|
$programs = Programs::query()->with(["appends", "tag_pivots.tag", "video_pivots.video"])->limit(15)->orderByDesc("created_at")->get();
|
||||||
return view("program", [
|
return view("program", [
|
||||||
"keyword" => $keyword,
|
"keyword" => $keyword,
|
||||||
"programs"=>$programs,
|
"programs"=>$programs,
|
||||||
|
@ -11,6 +11,11 @@ class Programs extends Model
|
|||||||
return $this->hasMany(ProgramAppends::class, "program_id", "id")->orderByDesc("is_original");
|
return $this->hasMany(ProgramAppends::class, "program_id", "id")->orderByDesc("is_original");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function tag_pivots(): \Illuminate\Database\Eloquent\Relations\HasMany
|
||||||
|
{
|
||||||
|
return $this->hasMany(ProgramTags::class, "program_id", "id")->orderBy("id");
|
||||||
|
}
|
||||||
|
|
||||||
public function tags(): \Illuminate\Database\Eloquent\Relations\HasManyThrough
|
public function tags(): \Illuminate\Database\Eloquent\Relations\HasManyThrough
|
||||||
{
|
{
|
||||||
return $this->hasManyThrough(Tags::class, ProgramTags::class, "program_id", "id", "id", "tag_id");
|
return $this->hasManyThrough(Tags::class, ProgramTags::class, "program_id", "id", "id", "tag_id");
|
||||||
|
@ -26,8 +26,8 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td>{{$program->name}}</td>
|
<td>{{$program->name}}</td>
|
||||||
<td>
|
<td>
|
||||||
@foreach($program->tags as $tag)
|
@foreach($program->tag_pivots as $tag_pivot)
|
||||||
<div title="{{$tag->comment}}">{{$tag->name}}</div>
|
<div title="{{$tag_pivot->tag->comment}}">{{$tag_pivot->tag->name}}</div>
|
||||||
@endforeach
|
@endforeach
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user