本文整理汇总了PHP中app\Department::all方法的典型用法代码示例。如果您正苦于以下问题:PHP Department::all方法的具体用法?PHP Department::all怎么用?PHP Department::all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Department
的用法示例。
在下文中一共展示了Department::all方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
/**
* Display the list of Unassigned works !!!
*/
$unAssignedWorks = DB::table('works as w')->leftJoin('department_works as dw', 'dw.id', '=', 'w.last_department_work_id')->leftJoin('user_works as uw', 'uw.id', '=', 'dw.last_user_work_id')->leftJoin('users as u', 'uw.assigned_to', '=', 'u.id')->leftJoin('users as us', 'w.created_by', '=', 'us.id')->leftJoin('departments as d', 'd.id', '=', 'dw.department_id');
if ($this->userWithDepartment->department[0]->pivot->is_senior == 1) {
$unAssignedWorks = $unAssignedWorks->where(['dw.department_id' => $this->userWithDepartment->department[0]->id, 'dw.accepted' => 0]);
$unAssignedWorks = $unAssignedWorks->orWhere(['uw.accepted' => -1, 'dw.department_id' => $this->userWithDepartment->department[0]->id, 'dw.accepted' => 0, 'dw.accepted' => 1]);
}
$unAssignedWorks = $unAssignedWorks->orWhere(['w.created_by' => $this->currentUser->getId(), 'w.last_department_work_id' => null]);
$unAssignedWorks = $unAssignedWorks->orWhere(['w.created_by' => $this->currentUser->getId(), 'dw.accepted' => -1])->select(['w.id', 'w.deadline as deadline', 'w.deadline as deadline', 'w.slug', 'w.title', 'w.description', 'w.importance', DB::raw('CONCAT(us.first_name," ",us.last_name) as created_by'), 'd.name as department_name', DB::raw('CONCAT(u.first_name," ",u.last_name) as assigned_to'), 'uw.accepted as user_work_accepted', 'dw.accepted as department_work_accepted', 'dw.department_id as department_id', 'w.created_by as created_by', 'uw.accepted as user_work_accepted'])->orderBy('w.created_at', 'desc')->paginate(15, ['*'], 'unAssignedWorks');
/**
* Display the list of Assigned works !!!
*/
$assignedWorks = DB::table('works as w')->leftJoin('department_works as dw', 'dw.id', '=', 'w.last_department_work_id')->leftJoin('user_works as uw', 'uw.id', '=', 'dw.last_user_work_id')->leftJoin('users as u', 'uw.assigned_to', '=', 'u.id')->leftJoin('users as us', 'w.created_by', '=', 'us.id')->leftJoin('departments as d', 'd.id', '=', 'dw.department_id');
if ($this->userWithDepartment->department[0]->pivot->is_senior == 1) {
$assignedWorks = $assignedWorks->where(function ($query) {
$query->where('dw.department_id', '=', $this->userWithDepartment->department[0]->id)->where('uw.accepted', '!=', -1)->where('uw.situation', '=', 0);
});
}
$assignedWorks = $assignedWorks->orWhere(function ($query) {
$query->where('w.created_by', '=', $this->currentUser->getId())->where('dw.accepted', '!=', -1)->where('dw.situation', '=', 0);
})->select(['w.id', 'w.deadline as deadline', 'w.slug', 'w.title', 'w.description', 'w.importance', DB::raw('CONCAT(us.first_name," ",us.last_name) as created_by'), 'd.name as department_name', DB::raw('CONCAT(u.first_name," ",u.last_name) as assigned_to'), 'uw.accepted as user_work_accepted', 'dw.accepted as department_work_accepted'])->orderBy('w.created_at', 'desc')->paginate(15, ['*'], 'assignedWorks');
$finishedWorks = DB::table('works as w')->leftJoin('department_works as dw', 'dw.id', '=', 'w.last_department_work_id')->leftJoin('user_works as uw', 'uw.id', '=', 'dw.last_user_work_id')->leftJoin('users as u', 'uw.assigned_to', '=', 'u.id')->leftJoin('users as us', 'w.created_by', '=', 'us.id')->leftJoin('departments as d', 'd.id', '=', 'dw.department_id')->where(function ($query) {
$query->where('dw.department_id', '=', $this->userWithDepartment->department[0]->id)->where('uw.accepted', '=', 1)->where('uw.situation', '=', 1);
})->orWhere(function ($query) {
$query->where('w.created_by', '=', $this->currentUser->getId())->where('dw.accepted', '=', 1)->where('dw.situation', '=', 1);
})->select(['w.id', 'w.deadline as deadline', 'w.slug', 'w.title', 'w.description', 'w.importance', DB::raw('CONCAT(us.first_name," ",us.last_name) as created_by'), 'd.name as department_name', DB::raw('CONCAT(u.first_name," ",u.last_name) as assigned_to'), 'uw.accepted as user_work_accepted', 'dw.accepted as department_work_accepted'])->orderBy('w.created_at', 'desc')->paginate(15, ['*'], 'finishedWorks');
$departments = Department::all(['id', 'name as text']);
$departmentWorkers = DB::table('department_worker as dw')->join('users as u', 'u.id', '=', 'dw.user_id')->join('departments as d', 'd.id', '=', 'dw.department_id')->where('dw.department_id', '=', $this->userWithDepartment->department[0]->id)->get(['u.id as id', DB::raw('CONCAT(u.first_name," ",u.last_name) as text')]);
$data = ['unAssignedWorks' => $unAssignedWorks, 'assignedWorks' => $assignedWorks, 'finishedWorks' => $finishedWorks, 'departments' => $departments, 'departmentWorkers' => json_encode($departmentWorkers), 'menu' => 'works', 'page_title' => 'İşler', 'page_description' => 'Şirket İşlerinin Listelendiği Sayfadır'];
return view('admin.work.index', $data);
}
示例2: up
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('delegations', function (Blueprint $table) {
$table->increments('id');
$table->integer('delegate_to_id')->unsigned();
$table->integer('delegate_from_id')->unsigned();
$table->integer('department_id')->unsigned();
$table->boolean('user_set')->default(0);
$table->timestamps();
});
Schema::table('delegations', function ($table) {
$table->unique(array('department_id', 'delegate_from_id'));
//A user can only vote once on a motion
$table->foreign('delegate_to_id')->references('id')->on('users');
$table->foreign('delegate_from_id')->references('id')->on('users');
$table->foreign('department_id')->references('id')->on('departments');
});
$validUsers = User::notCouncillor()->get();
$departments = Department::all();
$numberOfCouncilors = User::councillor()->count();
if ($numberOfCouncilors) {
foreach ($validUsers as $user) {
foreach ($departments as $department) {
$councillors = User::councillor()->get();
$leastDelegatedToCouncillor = $councillors->sortBy('totalDelegationsTo')->first();
$newDelegation = new Delegation();
$newDelegation->department_id = $department->id;
$newDelegation->delegate_from_id = $user->id;
$newDelegation->delegate_to_id = $leastDelegatedToCouncillor->id;
$newDelegation->save();
}
}
}
}
示例3: edit
/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function edit($id)
{
$departments = Department::all();
$subjects = Subject::all();
$department_subject = DepartmentSubject::find($id);
return view('admin.department_subject.department_subject_edit', compact('departments', 'subjects', 'department_subject'));
}
示例4: index
public function index(Request $request)
{
$query = $request->input();
$changes = Change::select('*');
if ($request->input('user')) {
$changes = $changes->where('user_id', $request->input('user'));
}
if ($request->input('start')) {
$changes = $changes->where('changes.created_at', '>=', $request->input('start'));
}
if ($request->input('end')) {
$changes = $changes->where('changes.created_at', '<=', $request->input('end'));
}
if ($request->input('goat')) {
$changes = $changes->where('goat_id', $request->input('goat'));
}
if ($request->input('type')) {
$changes = $changes->where('change_type', $request->input('type'));
}
$changes = $changes->join('goats', 'goats.id', '=', 'changes.goat_id')->select('changes.description as description', 'changes.created_at as created_at', 'changes.change_type as change_type', 'changes.user_id as user_id', 'changes.goat_id as goat_id');
if ($request->input('dept')) {
$changes = $changes->where('department_id', $request->input('dept'));
}
return view('changelog')->with(['changes' => $changes->orderBy('created_at', 'desc')->paginate(20), 'users' => \App\User::all(), 'depts' => \App\Department::all(), 'query' => $query]);
}
示例5: showUpdateInfoForm
/**
* Show information update form. Please note
* that a departmentStaff can only update
* his name, email and password
*
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function showUpdateInfoForm()
{
// Get the logged in departmentStaff
$departmentStaff = DepartmentStaff::find(Auth::guard('departmentStaff')->user()->id);
// Get the list of departments present in databse
$departments = Department::all();
return view($this->updateInfoView, ['departmentStaff' => $departmentStaff, 'departments' => $departments]);
}
示例6: showRegistrationForm
/**
* Show the application registration form.
*
* @return \Illuminate\Http\Response
*/
public function showRegistrationForm()
{
// Get the list of departments
$departmentArr = Department::all();
// Get the list of sections
$sectionArr = Section::all();
return view($this->registerView)->with(['departments' => $departmentArr, 'sections' => $sectionArr]);
}
示例7: index
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
if ($this->systemAdmin) {
$departments = Department::all();
} else {
$departments = Collection::make([Auth::user()->department]);
}
return view('admin.department.index', ['departments' => $departments, 'title' => trans('admin.departments'), 'url' => $this->systemAdmin ? action('Admin\\DepartmentController@create') : '']);
}
示例8: index
/**
* 부서를 가져옴
*
* @return \Illuminate\Http\Response
*/
public function index()
{
$deptList = Department::all();
$retArr = [];
foreach ($deptList as $dept) {
$retArr[] = ['id' => "{$dept->id}", 'parent' => $dept->p_id == null ? '#' : "{$dept->p_id}", 'text' => $dept->dept_name];
}
return Response()->json($retArr);
}
示例9: index
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
$estimates = Estimate::orderBy('id', 'DESC')->get();
$customers = Customer::all();
$vehicles = Vehicle::all();
$departments = Department::all();
$users = User::all();
return view('estimates.estimates', compact('estimates', 'customers', 'vehicles', 'departments', 'users'));
}
示例10: handle
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
Delegation::where('user_set', 0)->delete();
$users = User::with('delegatedFrom')->validVoter()->get();
$departments = Department::all();
$councillors = User::councillor()->get();
foreach ($users as $user) {
$user->createDefaultDelegations($departments, $councillors);
}
}
示例11: index
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index()
{
// if (Auth::user()->can('create-motions')) { //An admin able to see all users
// $departments = Department::all();
// return $departments;
// }
//Other people can see a list of the public users
$departments = Department::all();
return $departments;
}
示例12: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
// If a guest redirect
if ($this->auth->guest()) {
if ($request->ajax()) {
return response('Unauthorized.', 401);
} else {
return redirect()->guest('login');
}
}
// TODO put somewhere else!!!!!
// Get users departments and privilages
$user = Auth::user()->with('departments')->where('user.id', Auth::id())->first();
$allowed_departments = [];
$admin_departments = [];
$super_user = $user->is_super_user;
// If super user allow access to all departments
if ($super_user) {
$user_departments = Department::all();
// transfer collection to array
foreach ($user_departments as $department) {
$user->setAdmin(true);
// TODO DISABLE
$department->setAdmin(true);
// Note user is admin of this department
array_push($allowed_departments, $department);
}
} else {
$user_departments = $user->Departments;
// transfer collection to array
foreach ($user_departments as $department) {
// Check if the user is an admin in the department
if ($user->isAdmin($department->id)) {
$user->setAdmin(true);
// User can access admin settings
$department->setAdmin(true);
// Note user is admin of this department
}
array_push($allowed_departments, $department);
}
}
// Get an array of id's of all departments this user can access
$match_departments = [];
foreach ($allowed_departments as $department) {
array_push($match_departments, $department->id);
}
// Save until next request
Session::flash('user', $user);
Session::flash('allowed_departments', $allowed_departments);
Session::flash('match_departments', $match_departments);
Session::flash('super_user', $super_user);
// TODO CHNAGE TO MIDDLEWEAR ON LOCATION
//dd($user);
return $next($request);
}
示例13: index
public function index(Request $request)
{
if ($request->get('department')) {
$services = \App\Service::filterByDepartment($request->get('department'))->get();
$departments = \App\Department::where('id', $request->get('department'))->get();
} elseif ($request->get('domain')) {
$domain = \App\Domain::findOrfail($request->get('domain'));
$services = $domain->services()->get();
$departments = $domain->departments()->get();
} else {
$services = $this->services;
$departments = \App\Department::all();
}
return view('services.index', ['services' => $services, 'departments' => $departments]);
}
示例14: create
/**
* Show the form for creating a new resource.
*
* @return Response
*/
public function create()
{
$pageTitle = 'Add New Department';
// Initiate
$existedDepartments = array();
// All departments are available if user is administrator but only departments that assigned below if user is department manager.
if (Auth::user()->hasRole(['administrator'])) {
$existedDepartments = Department::all();
}
if (Auth::user()->hasRole(['department_manager'])) {
$managedDepartment = DB::table('departments')->where('manager', Auth::user()->id)->first();
array_push($existedDepartments, $managedDepartment);
$subDepartments = DB::table('departments')->where('parent_department', $managedDepartment->id)->get();
foreach ($subDepartments as $department) {
array_push($existedDepartments, $department);
}
}
return view('home.departments.create', compact('pageTitle', 'existedDepartments'));
}
示例15: create
/**
* Show the form for creating a new resource.
*
* @return Response
*/
public function create()
{
$pageTitle = 'Add New Category';
// If user is administrator
if (Auth::user()->hasRole(['administrator'])) {
$departments = Department::all()->toArray();
}
// If user is department manager
if (Auth::user()->hasRole(['department_manager'])) {
$managedDepartment = Auth::user()->departments->first();
$allDepartments = Department::all();
foreach ($allDepartments as $oneDepartment) {
if (isManageableDepartment($managedDepartment->id, $oneDepartment->id)) {
array_push($departments, $oneDepartment->toArray());
}
}
}
// If user is category manager
if (Auth::user()->hasRole(['category_manager'])) {
$departments = Auth::user()->departments->toArray();
}
return view('home.categories.create', compact('pageTitle', 'departments'));
}