mirror of
https://github.com/HDInnovations/UNIT3D-Community-Edition.git
synced 2026-02-05 03:00:52 -06:00
Merge pull request #2389 from Roardom/fix-wrong-director
(Fix) Wrong director
This commit is contained in:
@@ -97,7 +97,12 @@ class ProcessMovieJob implements ShouldQueue
|
||||
|
||||
if (isset($this->movie['credits']['crew'])) {
|
||||
foreach ($this->movie['credits']['crew'] as $crew) {
|
||||
Crew::updateOrCreate(['id' => $crew['id']], $tmdb->person_array($crew))->movie()->syncWithoutDetaching([$this->movie['id']]);
|
||||
Crew::updateOrCreate(['id' => $crew['id']], $tmdb->person_array($crew))
|
||||
->movie()
|
||||
->syncWithoutDetaching([$this->movie['id'] => [
|
||||
'department' => $crew['department'] ?? null,
|
||||
'job' => $crew['job'] ?? null,
|
||||
]]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -107,7 +107,12 @@ class ProcessTvJob implements ShouldQueue
|
||||
|
||||
if (isset($this->tv['credits']['crew'])) {
|
||||
foreach ($this->tv['credits']['crew'] as $crew) {
|
||||
Crew::updateOrCreate(['id' => $crew['id']], $tmdb->person_array($crew))->tv()->syncWithoutDetaching([$this->tv['id']]);
|
||||
Crew::updateOrCreate(['id' => $crew['id']], $tmdb->person_array($crew))
|
||||
->tv()
|
||||
->syncWithoutDetaching([$this->tv['id'] => [
|
||||
'department' => $crew['department'] ?? null,
|
||||
'job' => $crew['job'] ?? null,
|
||||
]]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -168,7 +173,12 @@ class ProcessTvJob implements ShouldQueue
|
||||
|
||||
foreach ($season['credits']['crew'] as $crew) {
|
||||
if (isset($crew['id'])) {
|
||||
Crew::updateOrCreate(['id' => $crew['id']], $tmdb->person_array($crew))->season()->syncWithoutDetaching([$season['id']]);
|
||||
Crew::updateOrCreate(['id' => $crew['id']], $tmdb->person_array($crew))
|
||||
->season()
|
||||
->syncWithoutDetaching([$season['id'] => [
|
||||
'department' => $season['department'] ?? null,
|
||||
'job' => $season['job'] ?? null,
|
||||
]]);
|
||||
Person::updateOrCreate(['id' => $crew['id']], $tmdb->person_array($crew))->tv()->syncWithoutDetaching([$this->id]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,6 +56,6 @@ class Season extends Model
|
||||
|
||||
public function crew(): \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Crew::class);
|
||||
return $this->belongsToMany(Crew::class, 'crew_season', 'person_id', 'season_id');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
use App\Models\Movie;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class() extends Migration {
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('crew_movie', function (Blueprint $table) {
|
||||
$table->string('department')->nullable();
|
||||
$table->string('job')->nullable();
|
||||
});
|
||||
|
||||
foreach (Movie::all() as $movie) {
|
||||
$crew = (new \App\Services\Tmdb\Client\Movie($movie->id))->get_crew();
|
||||
|
||||
if (isset($crew)) {
|
||||
foreach ($crew as $crewMember) {
|
||||
$movie->crew()->updateExistingPivot($crewMember['id'], [
|
||||
'department' => $crewMember['department'],
|
||||
'job' => $crewMember['job'],
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
use App\Models\Tv;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class() extends Migration {
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('crew_tv', function (Blueprint $table) {
|
||||
$table->string('department')->nullable();
|
||||
$table->string('job')->nullable();
|
||||
});
|
||||
|
||||
foreach (Tv::all() as $tv) {
|
||||
$data = (new \App\Services\Tmdb\Client\TV($tv->id))->getData();
|
||||
|
||||
if (isset($data['credits']['crew'])) {
|
||||
foreach ($data['credits']['crew'] as $crewMember) {
|
||||
$tv->crew()->updateExistingPivot($crewMember['id'], [
|
||||
'department' => $crewMember['department'],
|
||||
'job' => $crewMember['job'],
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
use App\Models\Season;
|
||||
use App\Models\Tv;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class() extends Migration {
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('crew_season', function (Blueprint $table) {
|
||||
$table->string('department')->nullable();
|
||||
$table->string('job')->nullable();
|
||||
});
|
||||
|
||||
foreach (Tv::all() as $tv) {
|
||||
$data = (new \App\Services\Tmdb\Client\TV($tv->id))->getData();
|
||||
|
||||
foreach ($data['seasons'] as $season) {
|
||||
$season = (new \App\Services\Tmdb\Client\Season($tv->id, \sprintf('%02d', $season['season_number'])))->getData();
|
||||
$seasonModel = Season::find($season['id']);
|
||||
|
||||
if (isset($season['credits']['crew'])) {
|
||||
foreach ($season['credits']['crew'] as $crewMember) {
|
||||
$seasonModel->crew()->updateExistingPivot($crewMember['id'], [
|
||||
'department' => $crewMember['department'],
|
||||
'job' => $crewMember['job'],
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -49,7 +49,7 @@
|
||||
<div class="movie-bottom">
|
||||
<div class="movie-details">
|
||||
@if(isset($meta->crew))
|
||||
@if(!empty($directors = $meta->crew()->where('known_for_department' ,'=', 'Directing')->take(1)->get()))
|
||||
@if(!empty($directors = $meta->crew()->wherePivot('department' ,'=', 'Directing')->take(1)->get()))
|
||||
<span class="badge-user text-bold text-purple">
|
||||
<i class="{{ config('other.font-awesome') }} fa-camera-movie"></i> Directors:
|
||||
@foreach($directors as $director)
|
||||
|
||||
Reference in New Issue
Block a user