コード例 #1
0
 public function create(Request $request)
 {
     if ($request->isMethod('get')) {
         return view('koki.create');
     } elseif ($request->isMethod('post')) {
         $item = array('nama' => Input::get('nama'), 'kode' => Input::get('kode'));
         Koki::create($item);
         return redirect('koki');
     }
 }
コード例 #2
0
ファイル: KokiController.php プロジェクト: riomabox/laravel
 /**
  * Show the form for creating a new resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function create()
 {
     //
     //Cara 1
     // $item = new Koki();
     // $item->nama = "tepung maizena";
     // $item->kode = "BHN01";
     // $item->save();
     // return redirect('koki');
     //        cara 2
     // $item = array('nama' => "telur ayam",'kode' => "BHN02");
     // Koki::create($item);
     if (Request::isMethod('get')) {
         return view('create');
     } elseif (Request::isMethod('post')) {
         $item = array('nama' => Input::get('nama'), 'kode' => Input::get('kode'));
         Koki::create($item);
         return redirect('koki');
     }
 }
コード例 #3
0
ファイル: routes.php プロジェクト: sansanbgl/mylaravel
Route::get('/resep', 'ResepController@index');
Route::get('/resep/create', 'ResepController@create');
Route::post('/resep/create', array('before' => 'csrf', 'uses' => 'ResepController@create'));
Route::get('/resep/update/{id}', 'ResepController@update');
Route::post('/resep/update/{id}', array('before' => 'csrf', 'uses' => 'ResepController@update'));
Route::get('/resep/delete/{id}', 'ResepController@delete');
Route::get('/resep/detail/{id}', 'ResepController@detail');
Route::get('/somerouteshere', 'ResepController@index');
Route::get('/somerouteshere/create', 'ResepController@create');
Route::post('/somerouteshere/create', array('before' => 'csrf', 'uses' => 'ResepController@create'));
Route::get('/somerouteshere/update/{id}', 'ResepController@update');
Route::post('/somerouteshere/update/{id}', array('before' => 'csrf', 'uses' => 'ResepController@update'));
Route::get('/somerouteshere/delete/{id}', 'ResepController@delete');
Route::get('/koki-auto-create', function () {
    for ($i = 0; $i < 10; $i++) {
        \App\Models\Koki::create(['nama' => 'koki' . $i, 'kode' => 'ko' . $i]);
    }
});
Route::get('/koki-resep-auto', function () {
    for ($i = 0; $i < 10; $i++) {
        for ($j = 0; $j < 5; $j++) {
            \App\Models\Resep::create(['koki_id' => $i + 1, 'nama' => 'resepmilikkoki_' . $i . 'nomer' . $j]);
        }
    }
});
Route::get('/generate-bahan', function () {
    $bahans = ['tepung', 'gula', 'telur', 'garam', 'mentega', 'ayam'];
    foreach ($bahans as $bahan) {
        \App\Models\Bahan::create(['nama' => $bahan]);
    }
});