122 lines
3.1 KiB
PHP
122 lines
3.1 KiB
PHP
<?php
|
|
|
|
namespace App\Nova;
|
|
|
|
use App\Nova\Actions\Participer;
|
|
use Illuminate\Http\Request;
|
|
use Laravel\Nova\Fields\Boolean;
|
|
use Laravel\Nova\Fields\Date;
|
|
use Laravel\Nova\Fields\DateTime;
|
|
use Laravel\Nova\Fields\ID;
|
|
use Laravel\Nova\Fields\Image;
|
|
use Laravel\Nova\Fields\Text;
|
|
use Laravel\Nova\Fields\Textarea;
|
|
use Laravel\Nova\Fields\URL;
|
|
use Laravel\Nova\Http\Requests\NovaRequest;
|
|
|
|
class Contest extends Resource
|
|
{
|
|
/**
|
|
* The model the resource corresponds to.
|
|
*
|
|
* @var class-string<\App\Models\Contest>
|
|
*/
|
|
public static $model = \App\Models\Contest::class;
|
|
|
|
/**
|
|
* The single value that should be used to represent the resource when being displayed.
|
|
*
|
|
* @var string
|
|
*/
|
|
public static $title = 'name';
|
|
|
|
/**
|
|
* The columns that should be searched.
|
|
*
|
|
* @var array
|
|
*/
|
|
public static $search = [
|
|
'name',
|
|
];
|
|
|
|
public static function indexQuery(NovaRequest $request, $query): \Illuminate\Database\Eloquent\Builder
|
|
{
|
|
return $query->where('fin', '>=', now())->where('participated', '!=', true);
|
|
}
|
|
/**
|
|
* Get the fields displayed by the resource.
|
|
*
|
|
* @param \Laravel\Nova\Http\Requests\NovaRequest $request
|
|
* @return array
|
|
*/
|
|
public function fields(NovaRequest $request)
|
|
{
|
|
return [
|
|
Boolean::make('Participate', 'participated'),
|
|
Text::make('Name')->readonly(),
|
|
Text::make('Screen')->readonly(),
|
|
Text::make('Description')->readonly(),
|
|
Text::make('Nb Like', 'nblike')->readonly(),
|
|
Text::make('Nb Reply', 'nbreply')->readonly(),
|
|
Image::make('Image', 'picture')
|
|
->thumbnail(function ($value) {
|
|
return $value;
|
|
})
|
|
->preview(function ($value) {
|
|
return $value;
|
|
})
|
|
->disableDownload(),
|
|
URL::make('URL')->readonly(),
|
|
Date::make('Fin')->readonly()->sortable(),
|
|
Text::make('Tweet ID', 'tweetid')->hideFromIndex()->readonly(),
|
|
Text::make('Nb Tweet', 'nbtweet')->readonly(),
|
|
];
|
|
}
|
|
|
|
/**
|
|
* Get the cards available for the request.
|
|
*
|
|
* @param \Laravel\Nova\Http\Requests\NovaRequest $request
|
|
* @return array
|
|
*/
|
|
public function cards(NovaRequest $request)
|
|
{
|
|
return [];
|
|
}
|
|
|
|
/**
|
|
* Get the filters available for the resource.
|
|
*
|
|
* @param \Laravel\Nova\Http\Requests\NovaRequest $request
|
|
* @return array
|
|
*/
|
|
public function filters(NovaRequest $request)
|
|
{
|
|
return [];
|
|
}
|
|
|
|
/**
|
|
* Get the lenses available for the resource.
|
|
*
|
|
* @param \Laravel\Nova\Http\Requests\NovaRequest $request
|
|
* @return array
|
|
*/
|
|
public function lenses(NovaRequest $request)
|
|
{
|
|
return [];
|
|
}
|
|
|
|
/**
|
|
* Get the actions available for the resource.
|
|
*
|
|
* @param \Laravel\Nova\Http\Requests\NovaRequest $request
|
|
* @return array
|
|
*/
|
|
public function actions(NovaRequest $request)
|
|
{
|
|
return [
|
|
Participer::make(),
|
|
];
|
|
}
|
|
}
|