本文整理汇总了PHP中app\Employee::query方法的典型用法代码示例。如果您正苦于以下问题:PHP Employee::query方法的具体用法?PHP Employee::query怎么用?PHP Employee::query使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Employee
的用法示例。
在下文中一共展示了Employee::query方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: create
/**
* Display a salary create form
* @param $id
* @return \Illuminate\View\View
*/
public function create($id)
{
$title = 'Create Salary';
$employee = Employee::query()->findOrFail($id);
$paid = Salary::all()->where('eid', $employee['eid'])->sum('paid');
$due = Salary::all()->where('eid', $employee['eid'])->sum('total');
//$advance = $paid > $due ? $paid - $due : 0;
$advance = Advance::all()->where('eid', $employee['eid'])->where('effect_month', Carbon::now()->subMonths(1)->format('F Y'))->pluck('deduction_rate')->first();
//dd($advance);
//dd(Carbon::now()->subMonths(1)->format('F Y'));
$due = $due > $paid ? $due - $paid : 0;
$repository = $this->repository;
return view('salary.create', compact('title', 'repository', 'employee', 'advance', 'due'));
}
示例2: search
public function search()
{
//helpers
$rating_date = mktime(0, 0, 0, date('n', time()), date('j', time()), date('Y', time()));
//get form select options and quality radio buttons
$brands = Brand::companyBrands()->get()->lists('name', 'id');
$residences = Residence::companyResidences()->get()->lists('name', 'id');
$companies = Company::userCompanies()->get()->lists('name', 'id');
$companies_ids = Company::userCompanies()->get()->lists('id');
foreach ($companies_ids as $company_id) {
$company_ids[] = $company_id;
}
$languages = Language::all()->lists('name', 'id');
array_unshift($languages, "Choose other language");
$qualities = Qualities::CompanyQualities()->get();
$inputs = Input::all();
$employees = Employee::query();
$employees->whereIn('company_id', $company_ids)->with('company', 'residence', 'phone', 'qualities', 'language')->with(['dates' => function ($query) {
$query->whereRaw('(? BETWEEN dates.start AND dates.end OR dates.start>?) AND dates.type IN("day_off", "annual_leave")', array(mktime(0, 0, 0, date('n', time()), date('j', time()), date('Y', time())), mktime(0, 0, 0, date('n', time()), date('j', time()), date('Y', time()))));
}]);
//dd($inputs);
if (Input::has('company_id') && is_array($inputs['company_id'])) {
$employees->whereIn('company_id', $inputs['company_id']);
}
if (Input::has('nickname')) {
$employees->where('nickname', 'like', '%' . $inputs['nickname'] . '%');
}
if (Input::has('name')) {
$employees->where('name', 'like', '%' . $inputs['name'] . '%');
}
if (Input::has('brand_id') && is_array($inputs['brand_id'])) {
$employees->join('brand_employee', 'employees.id', '=', 'brand_employee.employee_id')->whereIn('brand_employee.brand_id', $inputs['brand_id']);
}
if (Input::has('residences_id') && is_array($inputs['residences_id'])) {
$employees->whereIn('residences_id', $inputs['residences_id']);
}
if (Input::has('address')) {
$employees->where('address', 'like', '%' . $inputs['address'] . '%');
}
if (Input::has('phone')) {
$employees->join('phones', 'employees.id', '=', 'phones.employee_id')->where('phones.number', 'like', '%' . $inputs['phone'] . '%');
}
if (Input::has('email')) {
$employees->where('email', 'like', '%' . $inputs['email'] . '%');
}
if (Input::has('agreement')) {
$employees->where('agreement', 'like', '%' . $inputs['agreement'] . '%');
}
if (Input::has('no_agreement') && $inputs['agreement'] == '') {
$employees->where('agreement', '=', '');
}
if (Input::has('signed_agreement')) {
$employees->where('signed_agreement', '=', $inputs['signed_agreement']);
}
if (Input::has('working_days')) {
$all_work = array_fill(0, 7, 0);
foreach ($inputs['working_days'] as $work_day) {
$all_work[$work_day] = 1;
}
$employees->where('working_days', 'like', implode('', $all_work));
}
if (Input::has('start_from')) {
$employees->where('start_from', '<=', $inputs['start_from']);
}
if (Input::has('early_finish')) {
$employees->where('early_finish', '>=', $inputs['early_finish']);
}
if (Input::has('birth_date') && $inputs['birth_date']['from'] != '') {
$birth_date_start = strtotime($inputs['birth_date']['from']);
$birth_date_end = strtotime($inputs['birth_date']['to']);
if ($inputs['birth_date']['to'] == '') {
$birth_date_end = strtotime($inputs['birth_date']['from']) + 60 * 60 * 24;
}
$employees->whereBetween('birth_date', [$birth_date_start, $birth_date_end]);
}
if (Input::has('start_date') && $inputs['start_date']['start'] != '') {
$start_date_start = strtotime($inputs['start_date']['start']);
$start_date_end = strtotime($inputs['start_date']['end']);
if ($inputs['start_date']['end'] == '') {
$start_date_end = $rating_date;
}
$employees->whereBetween('start_date', [$start_date_start, $start_date_end]);
}
if (Input::has('annual_leave') && $inputs['annual_leave']['start'] != '') {
$leave_start = strtotime($inputs['annual_leave']['start']);
$leave_end = strtotime($inputs['annual_leave']['end']);
if ($inputs['annual_leave']['end'] == '') {
$leave_end = $leave_start + 60 * 60 * 24;
}
$employees->join('dates', 'employees.id', '=', 'dates.employees_id')->where('dates.type', 'like', 'annual_leave')->whereBetween('dates.start', [$leave_start, $leave_end])->orWhere(function ($query) use($leave_start, $leave_end) {
$query->whereBetween('dates.end', [$leave_start, $leave_end]);
});
}
if (Input::has('day_off') && $inputs['day_off']['start'] != '') {
$dayoff_start = strtotime($inputs['day_off']['start']);
$dayoff_end = strtotime($inputs['day_off']['end']);
if ($inputs['day_off']['end'] == '') {
$dayoff_end = $dayoff_start + 60 * 60 * 24;
}
$employees->join('dates', 'employees.id', '=', 'dates.employees_id')->where('dates.type', 'like', 'day_off')->whereBetween('dates.start', [$dayoff_start, $dayoff_end])->orWhere(function ($query) use($dayoff_start, $dayoff_end) {
//.........这里部分代码省略.........
示例3: employeeLog
public function employeeLog($id)
{
$title = 'Employee Log';
$employee = Employee::query()->findOrFail($id);
$logs = Log::where('eid', $id)->orderBy('id', 'desc')->orderBy('id', 'desc')->get();
$repository = $this->repository;
return view('employee.employeeLog', compact('title', 'logs', 'employee', 'repository'));
}
示例4: logDriver
/**
* @param $id
* @return string
*/
public function logDriver($id)
{
return $id == 999999999 ? 'Client Driver' : ($id == 0 ? '' : Employee::query()->FindOrFail($id)->name);
}
示例5: index
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index()
{
$employees = Employee::query()->orderBy('last_name', 'asc')->orderBy('first_name', 'asc')->get();
return view('employees.index', compact('employees'));
}