return $this->crew()->where('confirmed', true);
}
+ public function confirmedCrewOfChannel(Channel $channel) {
+ return $this->confirmedCrew()->where('channel_id', '=', $channel->id);
+ }
+
public function event() {
return $this->belongsTo(Event::class);
}
$episode = $this->channel->getCurrentEpisode();
if (!$episode) return;
$links = [];
- foreach ($episode->confirmedCrew as $crew) {
+ foreach ($episode->confirmedCrewOfChannel($this->channel)->get() as $crew) {
$link = $crew->getStreamLink();
if (empty($link)) {
$link = $crew->getName();
export const compareCrew = (a, b) => {
+ return compareCrewConfirmed(a, b) || compareCrewChannel(a, b) || compareCrewName(a, b);
+};
+
+export const compareCrewChannel = (a, b) => {
+ const a_channel = (a && a.channel_id) || null;
+ const b_channel = (b && b.channel_id) || null;
+ if (a_channel === b_channel) return 0;
+ if (!a_channel) return -1;
+ if (!b_channel) return 1;
+ return a_channel - b_channel;
+};
+
+export const compareCrewConfirmed = (a, b) => {
const a_confirmed = !!(a && a.confirmed);
const b_confirmed = !!(b && b.confirmed);
if (a_confirmed === b_confirmed) {
- return getName(a).localeCompare(getName(b));
+ return 0;
}
return a_confirmed ? -1 : 1;
};
+export const compareCrewName = (a, b) => {
+ return getName(a).localeCompare(getName(b));
+};
+
export const getName = crew => {
if (!crew) return '';
if (crew.name_override) {