Skip to main content

Black Friday 2025! Only until December 1st: coupon FRIDAY25 for 40% off Yearly/Lifetime membership!

Read more here

ammannbe/RecipeManager

37 stars
3 code files
View ammannbe/RecipeManager on GitHub

database/migrations/2019_12_08_091942_create_recipes_table.php

Open in GitHub
use 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 GitHub
use Illuminate\Database\Eloquent\Model;
 
class Recipe extends Model
{
//
public const COMPLEXITY_TYPES = [
'simple',
'normal',
'difficult',
];
//
}

app/Http/Requests/Recipes/Recipe/Store.php

Open in GitHub
use 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;
}
}

We'd Love Your Feedback

Tell us what you like or what we can improve

Feel free to share anything you like or dislike about this page or the platform in general.