Anonymous Anonymous - 9 days ago
159 0

No description

PHP

Casts

<?php

namespace App\Nova;

use Laravel\Nova\Fields\ID;
use Illuminate\Http\Request;
use Laravel\Nova\Fields\Select;
use Laravel\Nova\Fields\Text;
use Laravel\Nova\Fields\HasOne;
use Laravel\Nova\Fields\Number;
use Laravel\Nova\Fields\DateTime;
use Laravel\Nova\Http\Requests\NovaRequest;

class Cast extends Resource
{
    /**
     * The relationships that should be eager loaded on index queries.
     *
     * @var array
     */
    public static $with = ['home_team', 'away_team'];

    /*
     * Resources Grouping
     */
    public static $category = "Caster";

    /**
     * The model the resource corresponds to.
     *
     * @var string
     */
    public static $model = 'App\Cast';

    /**
     * The single value that should be used to represent the resource when being displayed.
     *
     * @var string
     */
    public static $title = 'title';

    /**
     * The columns that should be searched.
     *
     * @var array
     */
    public static $search = [
        'id',
        'title',
        'competition',
        'venue',
        'eventdate',
        'hometeam_id',
        'awayteam_id',
        'hometeam_score',
        'awayteam_score',
        'status',
    ];

    /**
     * Get the fields displayed by the resource.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return array
     */
    public function fields(Request $request)
    {
        return [
            ID::make()->sortable(),
            Text::make('Title','title')
                ->rules('required')
                ->sortable(),
            Text::make('Competition','competition')
                ->rules('required')
                ->sortable(),
            Text::make('Venue','venue')
                ->rules('required')
                ->sortable(),
            Select::make('Home Team', 'hometeam_id')
                ->options(\App\Team::all()->pluck('name','id')),
            Select::make('Away Team', 'awayteam_id')
                ->options(\App\Team::all()->pluck('name','id')),
            HasOne::make('Home Team', 'home_team', Team::class),
            HasOne::make('Away Team', 'away_team', Team::class),
            Number::make('Hometeam Score','hometeam_score'),
            Number::make('Awayteam Score','awayteam_score'),
            DateTime::make('Event Date','eventdate')
                ->rules('required')
                ->sortable(),
            //enum('LIVE','SCHEDULED','FINISHED','POSTPONED')::make('status','status')->rules('required')->sortable(),
        ];
    }

    /**
     * Get the cards available for the request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return array
     */
    public function cards(Request $request)
    {
        return [];
    }

    /**
     * Get the filters available for the resource.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return array
     */
    public function filters(Request $request)
    {
        return [];
    }

    /**
     * Get the lenses available for the resource.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return array
     */
    public function lenses(Request $request)
    {
        return [];
    }

    /**
     * Get the actions available for the resource.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return array
     */
    public function actions(Request $request)
    {
        return [];
    }
}
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download