<?php

namespace Database\Seeders;

use Illuminate\Database\Seeder;
use App\User;
use App\Recipe;
use App\RecipeIngredient;

class RecipeSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        $first_user = User::orderBy('id')->first();

        $recipe=Recipe::updateOrCreate(['name'=>'Test','user_id'=>$first_user['id'],'author'=>'Jayne','servings'=>1,'serving_size'=>'1 cup','date_entered'=>now(),'date_modified'=>now(),'instructions'=>'These are instructions']);
        RecipeIngredient::updateOrCreate(['recipe_id'=>$recipe['id'],'order'=>0,'alternative'=>false,'name'=>'hamburger','quantity'=>1.0,'measurement'=>'lb','special_notes'=>'']);
        RecipeIngredient::updateOrCreate(['recipe_id'=>$recipe['id'],'order'=>0,'alternative'=>true,'name'=>'sausage','quantity'=>1.0,'measurement'=>'lb','special_notes'=>'']);
        RecipeIngredient::updateOrCreate(['recipe_id'=>$recipe['id'],'order'=>0,'alternative'=>false,'name'=>'carrot','quantity'=>1.0,'measurement'=>'lb','special_notes'=>'']);


        $recipe=Recipe::updateOrCreate(['name'=>'Test2','user_id'=>$first_user['id'],'author'=>'Karen','servings'=>1,'serving_size'=>'1 cup','date_entered'=>now(),'date_modified'=>now(),'instructions'=>'These are instructions']);

        RecipeIngredient::updateOrCreate(['recipe_id'=>$recipe['id'],'order'=>0,'alternative'=>false,'name'=>'chicken','quantity'=>1.0,'measurement'=>'lb','special_notes'=>'']);
        RecipeIngredient::updateOrCreate(['recipe_id'=>$recipe['id'],'order'=>0,'alternative'=>false,'name'=>'carrot','quantity'=>1.0,'measurement'=>'lb','special_notes'=>'']);

        $jayne=User::updateOrCreate(['name'=>'Jayne','email'=>'jayne.passmore@actcur.com','password'=>bcrypt('temp'),'created_at'=>NOW()]);

        $recipe=Recipe::updateOrCreate(['name'=>'Test3','user_id'=>$jayne['id'],'author'=>'Jayne','servings'=>1,'serving_size'=>'1 cup','date_entered'=>now(),'date_modified'=>now(),'instructions'=>'These are instructions']);

        RecipeIngredient::updateOrCreate(['recipe_id'=>$recipe['id'],'order'=>0,'alternative'=>false,'name'=>'chicken','quantity'=>1.0,'measurement'=>'lb','special_notes'=>'']);
        RecipeIngredient::updateOrCreate(['recipe_id'=>$recipe['id'],'order'=>0,'alternative'=>false,'name'=>'carrot','quantity'=>1.0,'measurement'=>'lb','special_notes'=>'']);
    }
}
