public function edit($id)
 {
     $view = Auth::user()->getView();
     $provinces = Province::all();
     $cantons = Canton::all();
     $districts = District::all();
     $viability = Viability::findOrFail($id);
     return view('viabilities.edit', compact('viability', 'provinces', 'cantons', 'districts', 'view'));
 }
Exemplo n.º 2
0
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, $id)
 {
     $object = UserType::find($id);
     if ($object) {
         $params = $request->only('name', 'phone', 'email', 'type_id');
         $filter = $object->validator($params, ['email' => 'required|email|unique:users,email,' . $id]);
         if ($filter->fails()) {
             $error = $filter->errors()->toArray();
             $params['id'] = $id;
             return view('admin.trader.edit', ['input' => $params, 'error' => $error, 'options' => Option::where('user_id', $id)->get(), 'districts' => District::all(), 'brands' => Brand::all(), 'types' => UserType::all()]);
         }
         $object->fill($params);
         $object->save();
         return redirect('admin/trader/' . $id . '/edit');
     }
     if ($request->ajax()) {
         return $this->responseAnswer(false, null, null, trans('user.badUser'));
     } else {
         return redirect('admin/traders');
     }
 }
Exemplo n.º 3
0
 public function search()
 {
     $sectors = Sector::all(['id', 'sector_name']);
     $districts = District::all(['id', 'district_name']);
     return view('clients.search')->with('sectors', $sectors)->with('districts', $districts);
 }
Exemplo n.º 4
0
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, $id)
 {
     $object = Model::find($id);
     if ($object) {
         $params = $request->only('ru_title', 'en_title', 'ua_title', 'ru_address', 'en_address', 'ua_address', 'district_id', 'img');
         $filter = $object->validator($params, ['ru_title' => 'required|min:2|max:150|unique:portfolios,ru_title,' . $id, 'en_title' => 'required|min:2|max:150|unique:portfolios,en_title,' . $id, 'ua_title' => 'required|min:2|max:150|unique:portfolios,ua_title,' . $id]);
         if ($filter->fails()) {
             $error = $filter->errors()->toArray();
             $params['id'] = $id;
             $params['img'] = $object->img;
             $districts = District::all();
             return view('admin.portfolio.edit', ['input' => $params, 'error' => $error, 'districts' => $districts]);
         }
         if ($request->hasFile('img')) {
             $params['img'] = $this->upload('img');
             if ($object->img && file_exists(public_path() . DS . 'uploads' . DS . 'portfolios' . DS . $object->img)) {
                 unlink(public_path() . DS . 'uploads' . DS . 'portfolios' . DS . $object->img);
             }
         } else {
             unset($params['img']);
         }
         $params['alias'] = $this->makeAlias($params['ru_title']);
         $object->fill($params);
         $object->save();
         return redirect('admin/portfolio/' . $object->id . '/edit');
     }
     return false;
 }
 /**
  * Bootstrap any application services.
  *
  * @return void
  */
 public function boot()
 {
     if (\Schema::hasTable('positions')) {
         $positions = Position::all();
         $selectPositions = array();
         $selectPositions[0] = "Select / All";
         foreach ($positions as $position) {
             $selectPositions[$position->slug] = $position->name;
         }
         \View::share('selectPositions', $selectPositions);
     }
     if (\Schema::hasTable('cases_priorities')) {
         $priorities = CasePriority::all();
         $selectPriorities = array();
         $selectPriorities[0] = "Select / All";
         foreach ($priorities as $priority) {
             $selectPriorities[$priority->slug] = $priority->name;
         }
         \View::share('selectPriorities', $selectPriorities);
     }
     if (\Schema::hasTable('titles')) {
         $titles = Title::all();
         $selectTitles = array();
         $selectTitles[0] = "Select / All";
         foreach ($titles as $title) {
             $selectTitles[$title->slug] = $title->name;
         }
         \View::share('selectTitles', $selectTitles);
     }
     if (\Schema::hasTable('languages')) {
         $languages = Language::all();
         $selectLanguages = array();
         $selectLanguages[0] = "Select / All";
         foreach ($languages as $language) {
             $selectLanguages[$language->slug] = $language->name;
         }
         \View::share('selectLanguages', $selectLanguages);
     }
     if (\Schema::hasTable('departments')) {
         $departments = Department::all();
         $selectDepartments = array();
         $selectDepartments[0] = "Select / All";
         foreach ($departments as $department) {
             $selectDepartments[$department->slug] = $department->name;
         }
         \View::share('selectDepartments', $selectDepartments);
     }
     if (\Schema::hasTable('users_roles')) {
         $roles = UserRole::all();
         $selectRoles = array();
         $selectRoles[0] = "Select / All";
         foreach ($roles as $role) {
             $selectRoles[$role->slug] = $role->name;
         }
         \View::share('selectRoles', $selectRoles);
     }
     if (\Schema::hasTable('provinces')) {
         $provinces = Province::all();
         $selectProvinces = array();
         $selectProvinces[0] = "Select / All";
         foreach ($provinces as $Province) {
             $selectProvinces[$Province->slug] = $Province->name;
         }
         \View::share('selectProvinces', $selectProvinces);
     }
     if (\Schema::hasTable('districts')) {
         $districts = District::all();
         $selectDistrict = array();
         $selectDistricts[0] = "Select / All";
         foreach ($districts as $district) {
             $selectDistricts[$district->slug] = $district->name;
         }
         \View::share('selectDistricts', $selectDistricts);
     }
     if (\Schema::hasTable('municipalities')) {
         $municipalities = Municipality::all();
         $selectMunicipalities = array();
         $selectMunicipalities[0] = "Select / All";
         foreach ($municipalities as $municipality) {
             $selectMunicipalities[$municipality->slug] = $municipality->name;
         }
         \View::share('selectMunicipalities', $selectMunicipalities);
     }
     if (\Schema::hasTable('wards')) {
         $wards = Ward::all();
         $selectWards = array();
         $selectWards[0] = "Select / All";
         foreach ($wards as $ward) {
             $selectWards[$ward->slug] = $ward->name;
         }
         \View::share('selectWards', $selectWards);
     }
     if (\Schema::hasTable('categories')) {
         $categories = Category::all();
         $selectCategories = array();
         $selectCategories[0] = "Select / All";
         foreach ($categories as $category) {
             $selectCategories[$category->slug] = $category->name;
         }
         \View::share('selectCategories', $selectCategories);
     }
     if (\Schema::hasTable('sub_categories')) {
         $subCategories = SubCategory::all();
         $selectSubCategories = array();
         $selectSubCategories[0] = "Select / All";
         foreach ($subCategories as $subCategory) {
             $selectSubCategories[$subCategory->slug] = $subCategory->name;
         }
         \View::share('selectSubCategories', $selectSubCategories);
     }
     if (\Schema::hasTable('sub_sub_categories')) {
         $subSubCategories = SubSubCategory::all();
         $selectSubSubCategories = array();
         $selectSubSubCategories[0] = "Select / All";
         foreach ($subSubCategories as $subSubCategory) {
             $selectSubSubCategories[$subSubCategory->slug] = $subSubCategory->name;
         }
         \View::share('selectSubSubCategories', $selectSubSubCategories);
     }
     if (\Schema::hasTable('relationships')) {
         $relationships = Relationship::all();
         $selectRelationships = array();
         $selectRelationships[0] = "Select / All";
         foreach ($relationships as $relationship) {
             $selectRelationships[$relationship->id] = $relationship->name;
         }
         \View::share('selectRelationships', $selectRelationships);
     }
     if (\Schema::hasTable('cases')) {
         $cases = \DB::table('cases')->join('users', 'cases.reporter', '=', 'users.id')->select(\DB::raw("\n                                                    IF(`cases`.`addressbook` = 1,(SELECT CONCAT(`first_name`, ' ', `surname`) FROM `addressbook` WHERE `addressbook`.`id`= `cases`.`reporter`), (SELECT CONCAT(users.`name`, ' ', users.`surname`) FROM `users` WHERE `users`.`id`= `cases`.`reporter`)) as reporterName\n\n                                                "))->get();
         $reporters = array();
         $reporters[0] = "Select / All";
         foreach ($cases as $case) {
             $reporters[$case->reporterName] = $case->reporterName;
         }
         \View::share('selectReporters', $reporters);
     }
     View()->composer('master', function ($view) {
         $view->with('addressBookNumber', addressbook::all());
         if (\Auth::check()) {
             $number = addressbook::where('user', '=', \Auth::user()->id)->get();
             $view->with('addressBookNumber', $number);
             $allUsers = User::where('id', '<>', \Auth::user()->id)->get();
             $view->with('loggedInUsers', $allUsers);
             $noPrivateMessages = Message::where('to', '=', \Auth::user()->id)->where('read', '=', 0)->where('message_type', '=', 0)->get();
             $view->with('noPrivateMessages', $noPrivateMessages);
             $noInboxMessages = Message::where('to', '=', \Auth::user()->id)->where('message_type', '=', 0)->get();
             $view->with('noInboxMessages', $noInboxMessages);
             $noDepartments = Department::all();
             $view->with('noDepartments', $noDepartments);
             $noUsers = User::all();
             $view->with('noUsers', $noUsers);
             $noRoles = UserRole::all();
             $view->with('noRoles', $noRoles);
             $noPositions = Position::all();
             $view->with('noPositions', $noPositions);
             $noRelationships = Relationship::all();
             $view->with('noRelationships', $noRelationships);
             $noProvinces = Province::all();
             $view->with('noProvinces', $noProvinces);
             $noCaseStatuses = CaseStatus::all();
             $view->with('noCaseStatuses', $noCaseStatuses);
             $userRole = UserRole::where('id', '=', \Auth::user()->role)->first();
             $view->with('systemRole', $userRole);
             $noCasesPriorities = CasePriority::all();
             $view->with('noCasesPriorities', $noCasesPriorities);
         }
     });
 }
Exemplo n.º 6
0
 /**
  * Display a listing of the resource.
  *
  * @param Request $request
  *
  * @return Response
  */
 public function index(Request $request)
 {
     $districts = District::all();
     return $this->respond(fractal()->collection($districts, new DistrictTransformer())->parseIncludes($request->input('include', []))->toArray());
 }
 /**
  * Bootstrap any application services.
  *
  * @return void
  */
 public function boot()
 {
     if (\Schema::hasTable('positions')) {
         $positions = Position::orderBy('name', 'ASC')->get();
         $selectPositions = array();
         $selectPositions[0] = "Select / All";
         foreach ($positions as $position) {
             $selectPositions[$position->slug] = $position->name;
         }
         \View::share('selectPositions', $selectPositions);
     }
     if (\Schema::hasTable('departments')) {
         $departments = Department::orderBy('name', 'ASC')->get();
         $selectDepartments = array();
         $selectDepartments[0] = "Select / All";
         foreach ($departments as $department) {
             $selectDepartments[$department->slug] = $department->name;
         }
         \View::share('selectDepartments', $selectDepartments);
     }
     if (\Schema::hasTable('provinces')) {
         $provinces = Province::all();
         $selectProvinces = array();
         $selectProvinces[0] = "Select / All";
         foreach ($provinces as $Province) {
             $selectProvinces[$Province->slug] = $Province->name;
         }
         \View::share('selectProvinces', $selectProvinces);
     }
     if (\Schema::hasTable('districts')) {
         $districts = District::all();
         $selectDistrict = array();
         $selectDistricts[0] = "Select / All";
         foreach ($districts as $district) {
             $selectDistricts[$district->slug] = $district->name;
         }
         \View::share('selectDistricts', $selectDistricts);
     }
     if (\Schema::hasTable('municipalities')) {
         $municipalities = Municipality::all();
         $selectMunicipalities = array();
         $selectMunicipalities[0] = "Select / All";
         foreach ($municipalities as $municipality) {
             $selectMunicipalities[$municipality->slug] = $municipality->name;
         }
         \View::share('selectMunicipalities', $selectMunicipalities);
     }
     if (\Schema::hasTable('categories')) {
         $categories = Category::all();
         $selectCategories = array();
         $selectCategories[0] = "Select / All";
         foreach ($categories as $category) {
             $selectCategories[$category->slug] = $category->name;
         }
         \View::share('selectCategories', $selectCategories);
     }
     if (\Schema::hasTable('sub-categories')) {
         $subCategories = SubCategory::all();
         $selectSubCategories = array();
         $selectSubCategories[0] = "Select / All";
         foreach ($subCategories as $subCategory) {
             $selectSubCategories[$subCategory->slug] = $subCategory->name;
         }
         \View::share('selectSubCategories', $selectSubCategories);
     }
     if (\Schema::hasTable('sub-sub-categories')) {
         $subSubCategories = SubSubCategory::all();
         $selectSubSubCategories = array();
         $selectSubSubCategories[0] = "Select / All";
         foreach ($subSubCategories as $subSubCategory) {
             $selectSubSubCategories[$subSubCategory->slug] = $subSubCategory->name;
         }
         \View::share('selectSubSubCategories', $selectSubSubCategories);
     }
     if (\Schema::hasTable('relationships')) {
         $relationships = Relationship::all();
         $selectRelationships = array();
         $selectRelationships[0] = "Select / All";
         foreach ($relationships as $relationship) {
             $selectRelationships[$relationship->id] = $relationship->name;
         }
         \View::share('selectRelationships', $selectRelationships);
     }
     if (\Schema::hasTable('cases')) {
         $cases = \DB::table('cases')->join('users', 'cases.reporter', '=', 'users.id')->select(\DB::raw("\n                                                    IF(`cases`.`addressbook` = 1,(SELECT CONCAT(`FirstName`, ' ', `Surname`) FROM `addressbook` WHERE `addressbook`.`id`= `cases`.`reporter`), (SELECT CONCAT(users.`name`, ' ', users.`surname`) FROM `users` WHERE `users`.`id`= `cases`.`reporter`)) as reporterName\n\n                                                "))->get();
         $reporters = array();
         $reporters[0] = "Select / All";
         foreach ($cases as $case) {
             $reporters[$case->reporterName] = $case->reporterName;
         }
         \View::share('selectReporters', $reporters);
     }
     View()->composer('master', function ($view) {
         $view->with('addressBookNumber', addressbook::all());
         if (\Auth::check()) {
             $number = addressbook::where('user', '=', \Auth::user()->id)->get();
             $view->with('addressBookNumber', $number);
             $allUsers = User::where('id', '<>', \Auth::user()->id)->get();
             $view->with('loggedInUsers', $allUsers);
             $noPrivateMessages = Message::where('to', '=', \Auth::user()->id)->where('read', '=', 0)->where('online', '=', 0)->get();
             $view->with('noPrivateMessages', $noPrivateMessages);
             $noInboxMessages = Message::where('to', '=', \Auth::user()->id)->where('online', '=', 0)->get();
             $view->with('noInboxMessages', $noInboxMessages);
         }
     });
 }