Skip to content

Instantly share code, notes, and snippets.

@czemu

czemu/Recipe.php Secret

Last active March 4, 2020 19:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save czemu/dd00cd9f2a488df51c7979e79d9dd0ba to your computer and use it in GitHub Desktop.
Save czemu/dd00cd9f2a488df51c7979e79d9dd0ba to your computer and use it in GitHub Desktop.
<?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