示例#1
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Farm::create(['name' => 'papa', 'farm_category_id' => 1]);
     Farm::create(['name' => 'yuca', 'farm_category_id' => 1]);
     Farm::create(['name' => 'piña', 'farm_category_id' => 2]);
     Farm::create(['name' => 'papaya', 'farm_category_id' => 2]);
     Farm::create(['name' => 'banano', 'farm_category_id' => 2]);
     /*Farm::create(['name' => 'caña panelera', 'farm_category_id' => '']);
             Farm::create(['name' => 'caña de azucar', 'description' => '']);
             Farm::create(['name' => 'café', 'description' => '']);
             Farm::create(['name' => 'palma de aceite', 'description' => '']);
             Farm::create(['name' => 'cacao', 'description' => '']);
             Farm::create(['name' => 'platano', 'description' => '']);
             Farm::create(['name' => 'arroz', 'description' => '']);
             Farm::create(['name' => 'maiz blanco', 'description' => '']);
             Farm::create(['name' => 'maiz amarillo', 'description' => '']);
     
             Farm::create(['name' => 'aguacate', 'description' => '']);
             Farm::create(['name' => 'Hortalizas verduras y legunbre', 'description' => '']);
             Farm::create(['name' => 'plantas aromáticas condimentarias y medicinales', 'description' => '']);
             Farm::create(['name' => 'Plantaciones  forestales', 'description' => '']);
             Farm::create(['name' => 'cultivo de flores', 'description' => '']);
             Farm::create(['name' => 'producción de leche', 'description' => '']);
             Farm::create(['name' => 'producción de cerdos', 'description' => '']);
             Farm::create(['name' => 'producción bovina', 'description' => '']);
             Farm::create(['name' => 'equinos', 'description' => '']);
             Farm::create(['name' => 'porcinos', 'description' => '']);
             Farm::create(['name' => 'acuicola', 'description' => '']);
             Farm::create(['name' => 'Caña panelera', 'description' => '']);*/
 }
示例#2
0
 public function farmCreate(Request $request)
 {
     $validator = Validator::make($request->all(), ['farm' => 'required']);
     if ($validator->fails()) {
         return redirect()->back()->withInput()->withErrors($validator);
     }
     Farm::create(['name' => $request->get('farm'), 'farm_category_id' => $request->get('farmCategory')]);
     return redirect()->back();
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $client = Client::create(['user_id' => auth()->user()->id, 'location' => $request->location]);
     foreach ($request->all() as $key => $data) {
         if (strstr($key, 'farm')) {
             $farm = Farm::where('name', $data)->first();
             $client->farms()->save($farm);
         }
     }
     return redirect()->route('admin');
 }