public function edit($id) { $param['pageNo'] = 3; $param['agent'] = AgentModel::find($id); $param['stores'] = StoreModel::where('company_id', Session::get('company_id'))->get(); return View::make('company.agent.edit')->with($param); }
public function index() { $param['stores'] = StoreModel::where('company_id', Session::get('company_id'))->paginate(10); $param['pageNo'] = 2; if ($alert = Session::get('alert')) { $param['alert'] = $alert; } return View::make('company.store.index')->with($param); }
| Application Routes |-------------------------------------------------------------------------- | | Here is where you can register all of the routes for an application. | It's a breeze. Simply tell Laravel the URIs it should respond to | and give it the Closure to execute when that URI is requested. | */ Route::get('/', ['before' => 'auth', function () { $store = Auth::user(); $api = new TiendaNube\API($store->tiendanube_id, $store->access_token, 'Awesome App (contact@awesome.com)'); $response = $api->get("products"); return View::make('hello')->with('products', $response->body)->with('lang', $response->main_language); }]); Route::get('/auth', function () { //Obtain access token $code = Input::get('code'); $auth = new TiendaNube\Auth(Config::get('tiendanube.client_id'), Config::get('tiendanube.client_secret')); $store_info = $auth->request_access_token($code); //Create or edit existing store with the provided access token $store = Store::where('tiendanube_id', $store_info['store_id'])->first(); if ($store == null) { $store = new Store(); $store->tiendanube_id = $store_info['store_id']; } $store->access_token = $store_info['access_token']; $store->save(); //Login and redirect to homepage Auth::login($store); return Redirect::to('/'); });
public function delete_store() { $id = Request::segment(4); Store::where('id', $id)->delete(); Department::where('store_id', $id)->delete(); Shelf::where('store_id', $id)->delete(); Product::where('store_id', $id)->delete(); StoreLocation::where('store_id', $id)->delete(); $message = "Successfully deleted the store"; $type = "success"; return Redirect::to('/admin/stores')->with('type', $type)->with('message', $message); }
public function agent() { $param['pageNo'] = 9; $startDate = Input::has('startDate') ? Input::get('startDate') : ''; $endDate = Input::has('endDate') ? Input::get('endDate') : ''; if ($startDate == '' || $endDate == '') { $endDate = date('Y-m-d'); $startDate = substr($endDate, 0, 8) . "01"; } $storeId = Input::has('storeId') ? Input::get('storeId') : ''; $companyId = Session::get('company_id'); $prefix = DB::getTablePrefix(); $sqlGroup = "SELECT agent_id, COUNT(*) AS cnt, SUM(TIME_TO_SEC(TIMEDIFF(end_time, start_time))) AS activeTime\n FROM " . $prefix . "process\n WHERE end_time != ''\n AND (DATE(created_at) BETWEEN DATE('{$startDate}') AND DATE('{$endDate}'))\n GROUP BY agent_id"; $sql = "SELECT t1.id, t1.name, t1.email, t1.phone\n FROM " . $prefix . "agent t1, " . $prefix . "store t2\n WHERE t1.store_id = t2.id\n AND t2.company_id = {$companyId}"; if ($storeId != '') { $sql .= " AND t1.store_id = {$storeId}"; } $sql = "SELECT t1.*, IFNULL(t2.cnt, 0) AS cnt, IFNULL(t2.activeTime, 0) as activeTime \n FROM ({$sql}) t1\n LEFT JOIN ({$sqlGroup}) t2 ON t1.id = t2.agent_id"; $param['agents'] = DB::select($sql); $param['storeId'] = $storeId; $param['startDate'] = $startDate; $param['endDate'] = $endDate; $param['stores'] = StoreModel::where('company_id', Session::get('company_id'))->get(); return View::make('company.dashboard.agent')->with($param); }
private function storeExists($store) { return Store::where('name', '=', $store->name)->get()->count() > 0; }