}
public function getRandomQuoteAttribute() {
- return $this->results()
+ $result = $this->results()
->where('comment', '!=', '')
- ->whereHas('round', function(Builder $query) {
+ ->whereHas('round', function (Builder $query) {
$query->where('locked', true);
})
->inRandomOrder()
->first();
+ if ($result) {
+ $result->load(['round', 'round.tournament']);
+ }
+ return $result;
}
import Participation from './Participation';
import EpisodesList from '../episodes/List';
import Icon from '../common/Icon';
+import { getIcon, getTime } from '../../helpers/Result';
+
+const getQuoteSource = (result) => {
+ if (!result || !result.round) return '';
+ const roundTitle = result.round.title || `Seed #${result.round.number}`;
+ if (result.round.tournament) {
+ return `${result.round.tournament.title} ${roundTitle}`;
+ }
+ return roundTitle;
+};
const Profile = ({ user }) => {
const [activeEpisodes, setActiveEpisodes] = React.useState('runner');
</h1>
{user.random_quote && user.random_quote.comment ?
<Alert className="quote-alert" variant="dark">
- <blockquote className="blockquote mb-0">
- {user.random_quote.comment}
- </blockquote>
+ <figure className="mb-0">
+ <blockquote className="blockquote">
+ {user.random_quote.comment}
+ </blockquote>
+ <figcaption className="blockquote-footer mb-0">
+ {t('users.randomQuoteSource', {
+ date: new Date(user.random_quote.created_at),
+ result: getTime(user.random_quote, true),
+ source: getQuoteSource(user.random_quote),
+ })}
+ </figcaption>
+ </figure>
</Alert>
: null}
<Row>
})),
random_quote: PropTypes.shape({
comment: PropTypes.string,
+ created_at: PropTypes.string,
}),
round_first_count: PropTypes.number,
round_second_count: PropTypes.number,
nickname: 'Name',
noStream: 'Kein Stream gesetzt',
participationEmpty: 'Hat noch an keinen Turnieren teilgenommen.',
+ randomQuoteSource: '{{ date, L }}, {{ source }}, {{ result }}',
roundRecords: 'Renn-Platzierungen',
setNicknameError: 'Konnte Namen nicht speichern',
setNicknameSuccess: 'Name geƤndert',
nickname: 'Name',
noStream: 'No stream set',
participationEmpty: 'Has not participated in any tourneys yet.',
+ randomQuoteSource: '{{ date, L }}, {{ source }}, {{ result }}',
roundRecords: 'Race records',
setNicknameError: 'Could not save name',
setNicknameSuccess: 'Name changed',