Пример #1
0
 /**
  * Show a list of all the retailers formatted for Datatables.
  *
  * @return Datatables JSON
  */
 public function getData()
 {
     $retailers = Retailer::select(array('retailers.name', 'retailers.id', 'addresses.address', 'company_register_id', 'business_categories.name AS category', 'retailers.website', 'retailers.created_at'))->leftJoin('addresses', 'addresses.id', '=', 'retailers.address_id')->leftJoin('business_categories', 'business_categories.id', '=', 'retailers.category_id');
     return Datatables::of($retailers)->add_column('actions', '<a href="{{{ URL::to(\'admin/retailers/\' . $id . \'/edit\' ) }}}" class="iframe btn btn-xs btn-default">{{{ Lang::get(\'button.edit\') }}}</a>
                             <a href="{{{ URL::to(\'admin/retailers/\' . $id . \'/delete\' ) }}}" class="iframe btn btn-xs btn-danger">{{{ Lang::get(\'button.delete\') }}}</a>
         ')->remove_column('id')->make();
 }
Пример #2
0
 public function run()
 {
     DB::statement("TRUNCATE TABLE outlets");
     $adminId = User::select('id')->where('username', 'dungho')->first()->id;
     $retailerMT = Retailer::select('id')->where('company_register_id', 'MT00001')->first()->id;
     $retailerPL = Retailer::select('id')->where('company_register_id', 'PL00001')->first()->id;
     $outlets = array(array('name' => 'Minh Toan Graxy - Spa Beauty', 'outlet_register_id' => 'MTID001', 'website' => 'www.minhtoan.com.vn', 'retailer_id' => $retailerMT), array('name' => 'Minh Toan Graxy - Spa One', 'outlet_register_id' => 'MTID002', 'website' => 'www.minhtoan.com.vn', 'retailer_id' => $retailerMT), array('name' => 'Minh Toan Graxy - Spa Two', 'outlet_register_id' => 'MTID003', 'website' => 'www.minhtoan.com.vn', 'retailer_id' => $retailerMT), array('name' => 'Phi Lu - Spa Beauty', 'outlet_register_id' => 'PLID001', 'website' => 'www.philu.com.vn', 'retailer_id' => $retailerPL));
     foreach ($outlets as $key => $value) {
         $outlet = new Outlet();
         $outlet->name = $value['name'];
         $outlet->address_id = rand(1, 5);
         $outlet->outlet_register_id = $value['outlet_register_id'];
         $outlet->website = $value['website'];
         $outlet->admin_id = $adminId;
         $outlet->description_id = 1;
         $outlet->status = 'active';
         $outlet->retailer_id = $value['retailer_id'];
         $outlet->save();
     }
 }
Пример #3
0
 public static function findOne($id)
 {
     $retailer = Retailer::select(array('retailers.id', 'admin_id', 'category_id', 'address_id', 'company_register_id', 'retailers.name', 'website', 'retailers.created_at', 'retailers.updated_at', 'cities.id AS city_id', 'cities.country_id'))->leftJoin('addresses', 'addresses.id', '=', 'retailers.address_id')->leftJoin('cities', 'cities.id', '=', 'addresses.city_id')->where('retailers.id', $id)->first();
     return $retailer;
 }