public function index()
 {
     //
     $title = "Departments";
     $data = Department::orderBy('id', 'desc')->get();
     return view('html.department.list', compact('data', 'title'));
 }
Example #2
0
 /**
  * Show the application registration form.
  *
  * @return \Illuminate\Http\Response
  */
 public function getRegister()
 {
     $departmentList = Department::orderBy('created_at')->get();
     $deptSelectValues = [];
     foreach ($departmentList as $dept) {
         $deptSelectValues[$dept['id']] = $dept['dept_name'];
     }
     return view('auth.register')->with(compact('deptSelectValues'));
 }
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     //::orderBy('orderByColumn')->
     $departments = Department::orderBy('name')->get();
     foreach ($departments as $dept) {
         $fac = Faculty::where('id', '=', $dept->faculty_id)->firstOrFail();
         $dept['faculty_name'] = $fac->name;
     }
     return view('department.index', compact('departments'));
 }
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     if ($id == 1) {
         Flash::error('Il est interdit de modifier ce département.');
         return Redirect::back();
     }
     $departments = Department::orderBy('name')->paginate(20);
     $depToEdit = Department::where('id', $id)->first();
     return view('admin.departments.edit', compact('departments', 'depToEdit'));
 }
 public function filter()
 {
     $city_id = Input::get('city');
     $departments = Department::orderBy('city_id')->get();
     if (isset($city_id)) {
         if ($city_id == 0) {
             $departments = Department::orderBy('city_id')->get();
         } else {
             $departments = Department::where('city_id', $city_id)->get();
         }
     }
     return View::make('department.all', ['category' => 1, 'departments' => $departments, 'selectedCity' => $city_id]);
 }
 public function index(Request $request)
 {
     if ($request->bp) {
         $currentBp = BusinessPlan::find($request->bp);
     } else {
         $currentBp = BusinessPlan::where('start', '<=', Carbon::now())->where('end', '>=', Carbon::now())->first();
         if (!$currentBp) {
             $currentBp = BusinessPlan::all()->last();
         }
     }
     $sorted = Goat::where('bid', $currentBp->id)->where('type', 'G')->orderBy('goal_type')->orderBy('description')->get();
     $bp = Goat::where('bid', $currentBp->id)->where('type', '<>', 'G')->orderByRaw("FIELD(type, 'O', 'A', 'T')")->orderBy('description', 'desc')->get();
     foreach ($bp as $goat) {
         if ($goat->type === 'G') {
             $sorted->push($goat);
             continue;
         }
         for ($i = 0, $len = $sorted->count(); $i < $len; $i++) {
             if ($sorted[$i]->id == $goat->parent_id) {
                 // Hacky fix since when you splice $goat into $sorted,
                 // it converts the $goat into an array instead of
                 // keeping it as a Model object...
                 $sorted->splice($i + 1, 0, "temp");
                 $sorted->put($i + 1, $goat);
                 break;
             }
         }
     }
     $leadOf = array();
     if (Auth::user()) {
         foreach (Auth::user()->leadOf as $dept) {
             array_push($leadOf, $dept->id);
         }
     }
     $collaboratorGoals = array();
     foreach ($leadOf as $dept_id) {
         foreach (Department::find($dept_id)->collaboratorOn as $goat) {
             array_push($collaboratorGoals, $goat->id);
         }
     }
     return view('view_plan')->with(['bp' => $sorted, 'users' => User::orderBy('first_name')->get(), 'depts' => Department::orderBy('name')->get(), 'leadOf' => $leadOf, 'plans' => BusinessPlan::orderBy('id', 'desc')->get(), 'query' => $request, 'bp_id' => $currentBp->id, 'is_bplead' => Auth::user() && Auth::user()->is_bplead, 'collaboratorGoals' => $collaboratorGoals]);
 }
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function edit($id)
 {
     $this->AuthorizeAndRedirect('admin');
     $departments = Department::orderBy('name')->lists('name', 'id');
     $student = User::findOrFail($id);
     return view('student.edit', compact('student', 'departments'));
 }
 /**
  * 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);
         }
     });
 }
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $departments = Department::orderBy('created_at', 'desc')->paginate(10);
     return view('admin.department.department', compact('departments'));
 }