public function single(Request $request, $id) {
$user = User::findOrFail($id);
$this->authorize('view', $user);
+ $user->append('random_quote');
$user->load('participation');
$user->load('participation.tournament');
$user->loadCount('round_first');
namespace App\Models;
+use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
return $this->username;
}
+ public function getRandomQuoteAttribute() {
+ return $this->results()
+ ->where('comment', '!=', '')
+ ->whereHas('round', function(Builder $query) {
+ $query->where('locked', true);
+ })
+ ->inRandomOrder()
+ ->first();
+ }
+
public function isAdmin() {
return $this->role === 'admin';
import PropTypes from 'prop-types';
import React from 'react';
-import { Button, Col, Container, Row } from 'react-bootstrap';
+import { Alert, Button, Col, Container, Row } from 'react-bootstrap';
import { withTranslation } from 'react-i18next';
import Box from './Box';
{' '}
<EditNicknameButton user={user} />
</h1>
+ {user.random_quote && user.random_quote.comment ?
+ <Alert className="quote-alert" variant="dark">
+ <blockquote className="blockquote mb-0">
+ {user.random_quote.comment}
+ </blockquote>
+ </Alert>
+ : null}
<Row>
<Col md={6} className="mb-5">
<h2>{i18n.t('users.discordTag')}</h2>
nickname: PropTypes.string,
participation: PropTypes.arrayOf(PropTypes.shape({
})),
+ random_quote: PropTypes.shape({
+ comment: PropTypes.string,
+ }),
round_first_count: PropTypes.number,
round_second_count: PropTypes.number,
round_third_count: PropTypes.number,