-
database/migrations/2019_12_08_091942_create_recipes_table.php
Open in GitHubuse Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; class CreateRecipesTable extends Migration { public function up() { Schema::create('recipes', function (Blueprint $table) { // $table->enum('complexity', ['simple', 'normal', 'difficult'])->default('normal'); // }); } // }
-
app/Models/Recipes/Recipe.php
Open in GitHubuse Illuminate\Database\Eloquent\Model; class Recipe extends Model { // public const COMPLEXITY_TYPES = [ 'simple', 'normal', 'difficult', ]; // }
-
app/Http/Requests/Recipes/Recipe/Store.php
Open in GitHubuse App\Models\Recipes\Recipe; use Illuminate\Validation\Rule; use Illuminate\Foundation\Http\FormRequest; class Store extends FormRequest { public function rules() { $rules = [ 'category_id' => ['required', 'nullable', 'exists:categories,id'], 'name' => ['required', 'string', 'max:100', 'unique:recipes,name'], 'yield_amount' => ['required', 'nullable', 'numeric', 'max:999'], 'complexity' => ['required', 'string', Rule::in(Recipe::COMPLEXITY_TYPES)], 'instructions' => ['required', 'string', 'max:16000000'], 'preparation_time' => ['nullable', 'string', 'date_format:H:i'], ]; // return $rules; } }