Exemplo n.º 1
0
 public function run()
 {
     \Illuminate\Database\Eloquent\Model::unguard();
     DB::statement('set foreign_key_checks = 0');
     DB::table('shipping')->truncate();
     $faker = Faker::create();
     $shippingMethod = ['UPS', 'USPS', 'FeDex', 'DHL'];
     $orderItemsId = \App\Models\OrderItems::all()->lists('id');
     foreach (range(1, 200) as $index) {
         $id = $faker->randomElement($orderItemsId);
         if (DB::table('shipping')->where('orderitem_id', $id)->first()) {
             continue;
         } else {
             DB::table('shipping')->insert(['shipping_method' => $faker->randomElement($shippingMethod), 'orderitem_id' => $orderItemsId, 'track_number' => $faker->randomAscii . $faker->randomNumber()]);
         }
     }
     DB::statement('set foreign_key_checks = 1');
 }
Exemplo n.º 2
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $orderitems = OrderItems::paginate(\Config::get('fzbconfig.order_paginate'));
     return view('orders.orderitem_index', array('orderitems' => $orderitems));
 }
Exemplo n.º 3
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     if (Sentinel::check()) {
         if ($id) {
             $category = Categories::find($id);
             $OrderItemshasCat = OrderItems::where('category_id', $category->id)->count();
             if (!$OrderItemshasCat) {
                 if ($category->delete()) {
                     return Redirect::to('admin/categories')->with('message', sprintf(trans('message.msg_category_delete_success'), $category->name));
                 }
             }
         }
     } else {
         return redirect('login');
     }
     return Redirect::to('admin/categories')->withErrors(array('errors' => trans('message.msg_category_delete_fail')));
 }