Ejemplo n.º 1
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::table('bottle_sizes')->delete();
     $sizes = json_decode(File::get(dirname(__FILE__) . '/bottle_sizes.json'), true);
     foreach ($sizes as $size) {
         BottleSize::create($size);
     }
 }
Ejemplo n.º 2
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $bottle_sizes = BottleSize::with('translations')->get();
     $output = [];
     foreach ($bottle_sizes as $data) {
         $row = ['capacity' => $data['capacity'], 'is_common' => $data['is_common']];
         foreach ($data->translations as $translation) {
             foreach ($data->translatedAttributes as $attribute) {
                 $row[$translation->locale][$attribute] = $translation->{$attribute};
             }
         }
         $output[] = $row;
     }
     $output = json_encode($output, JSON_PRETTY_PRINT);
     File::put(dirname(__FILE__) . '/bottle_sizes.json', $output);
 }
Ejemplo n.º 3
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $bottle_size = BottleSize::findOrFail($id);
     $this->authorize('destroy', $bottle_size);
     if ($bottle_size->delete()) {
         return redirect(action('BottleSizesController@index'))->with('success', trans('messages.deleted_success'));
     }
     return redirect(action('BottleSizesController@edit', $bottle_size->id))->with('error', trans('messages.deleted_error'));
 }