Skip to content

Instantly share code, notes, and snippets.

@czemu

czemu/Recipe.php Secret

Last active Mar 4, 2020
Embed
What would you like to do?
<?php
namespace App\Nova;
use Illuminate\Http\Request;
use Laravel\Nova\Fields\ID;
use Laravel\Nova\Fields\Text;
use Laravel\Nova\Fields\Textarea;
use Laravel\Nova\Fields\Markdown;
use Laravel\Nova\Fields\DateTime;
use Laravel\Nova\Fields\Boolean;
use Laravel\Nova\Fields\HasMany;
use Laravel\Nova\Http\Requests\NovaRequest;
class Recipe extends Resource
{
/**
* The model the resource corresponds to.
*
* @var string
*/
public static $model = 'App\Recipe';
/**
* 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('Name')->rules('required,max:255')->sortable(),
Textarea::make('Ingredients'),
Markdown::make('Preparation description'),
DateTime::make('Published at'),
Boolean::make('Is featured'),
HasMany::make('Categories'),
HasMany::make('Comments')
];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment