我想创建一个if语句,仅让role_id 2,3,4查看所有call_center数据,否则,我只希望具有正确身份验证的用户在我的仪表板中查看他们自己的呼叫中心数据。我有一个开始,但可以使用一些帮助使其正常工作。以下是我目前正在尝试的if语句。我知道这可能是不正确的,如果这样的话,朝正确方向的一点将不胜感激。
if($role_id['id'] == '2' || $role_id['id'] == '3' || $role_id['id'] == '4') {
if ($user_id != Auth::user()->id)
{
$user_id != $call_center
}
}
这是我的dashboardcontroller.php中的全部功能
public function index()
{
$input = Input::all();
$user_id = Auth::user()->id;
$role_id = User::UserRoleData()->where('user_id', '=', $user_id)->first();
$call_center = Auth::user()->call_center;
$call_center = ($call_center == null ? '' : $call_center);
$call_center = !empty($input['call_center']) ? $input['call_center'] : $call_center;
$month = !empty($input['month']) ? $input['month'] : 'twentyfour';
$sellertype = !empty($input['sellertype']) ? $input['sellertype'] : 'seller';
$companies = Company::DistinctCompanies()->orderby('name')->get();
$date = date('Y-m-d', strtotime('now -24 months'));
if($role_id['id'] == '2' || $role_id['id'] == '3' || $role_id['id'] == '4') {
if ($user_id != Auth::user()->id)
{
}
}
// } else {
// $user_id->$call_center = Auth::user()->call_center;
// }
$pending = Contract::GetData()
->select(DB::raw('count(*) as total'))
->where('system_status', '=', 'Pending')
->where('hold', '=', '0');
$active = Contract::GetData()
->select(DB::raw('count(*) as total'))
->where('system_status', '=', 'Active')
->where('hold', '=', '0');
$cancelled_contracts = Contract::GetData()
->select(DB::raw('count(*) as total'))
->where('system_status', '=', 'Cancelled')
->where('hold', '=', '0');
$late_contracts = Contract::GetData()
->select(DB::raw('count(*) as total'))
->where('system_status', '=', 'Late')
->where('hold', '=', '0');
$back_out_contracts = Contract::GetData()
->select(DB::raw('count(*) as total'))
->where('system_status', '=', 'Back Out')
->where('hold', '=', '0');
$pending_late = Contract::GetData()
->select(DB::raw('count(*) as total'))
->where('system_status', '=', 'Pending Late')
->where('hold', '=', '0');
$pending_cancellation = Contract::GetData()
->select(DB::raw('count(*) as total'))
->where('system_status', '=', 'Awaiting Cancellation')
->where('hold', '=', '0');
if($sellertype == 'dealership')
{
$pending->where("type", "=", 'dealership');
$active->where("type", "=", 'dealership');
$cancelled_contracts->where("type", "=", 'dealership');
$late_contracts->where("type", "=", 'dealership');
$back_out_contracts->where("type", "=", 'dealership');
$pending_late->where("type", "=", 'dealership');
$pending_cancellation->where("type", "=", 'dealership');
}
if($month == 'twentyfour' || $month != 'all')
{
$pending->where("sold_date", ">=", $date);
$active->where("sold_date", ">=", $date);
$cancelled_contracts->where("sold_date", ">=", $date);
$late_contracts->where("sold_date", ">=", $date);
$back_out_contracts->where("sold_date", ">=", $date);
$pending_late->where("sold_date", ">=", $date);
$pending_cancellation->where("sold_date", ">=", $date);
}
if($call_center == '52')
{
$asi_contracts = array('26', '35', '4', '42', '45', '46', '47', '49', '50', '51');
$pending
->where('contracts.moxy_contract_id', 'not like', 'EACP%')
->where('contracts.moxy_contract_id', 'not like', '9466%')
->where('contracts.moxy_contract_id', 'not like', '9836%');
$active
->where('contracts.moxy_contract_id', 'not like', 'EACP%')
->where('contracts.moxy_contract_id', 'not like', '9466%')
->where('contracts.moxy_contract_id', 'not like', '9836%');
$cancelled_contracts
->where('contracts.moxy_contract_id', 'not like', 'EACP%')
->where('contracts.moxy_contract_id', 'not like', '9466%')
->where('contracts.moxy_contract_id', 'not like', '9836%');
$late_contracts
->where('contracts.moxy_contract_id', 'not like', 'EACP%')
->where('contracts.moxy_contract_id', 'not like', '9466%')
->where('contracts.moxy_contract_id', 'not like', '9836%');
$back_out_contracts
->where('contracts.moxy_contract_id', 'not like', 'EACP%')
->where('contracts.moxy_contract_id', 'not like', '9466%')
->where('contracts.moxy_contract_id', 'not like', '9836%');
$pending_late
->where('contracts.moxy_contract_id', 'not like', 'EACP%')
->where('contracts.moxy_contract_id', 'not like', '9466%')
->where('contracts.moxy_contract_id', 'not like', '9836%');
$pending_cancellation
->where('contracts.moxy_contract_id', 'not like', 'EACP%')
->where('contracts.moxy_contract_id', 'not like', '9466%')
->where('contracts.moxy_contract_id', 'not like', '9836%');
}
if($role_id['id'] == '5' || $role_id['id'] == '6' || $role_id['id'] == '7' || $role_id['id'] == '8' || $role_id['id'] == '9' || $role_id['id'] == '10')
{
{
$pending->where('contracts.call_center', '=', $call_center);
$active->where('contracts.call_center', '=', $call_center);
$cancelled_contracts->where('contracts.call_center', '=', $call_center);
$late_contracts->where('contracts.call_center', '=', $call_center);
$back_out_contracts->where('contracts.call_center', '=', $call_center);
$pending_late->where('contracts.call_center', '=', $call_center);
$pending_cancellation->where('contracts.call_center', '=', $call_center);
}
}
else
{
if($role_id['id'] == '2' && !empty($input['call_center']))
{
$call_center = $input['call_center'];
{
$pending->where('contracts.call_center', '=', $call_center);
$active->where('contracts.call_center', '=', $call_center);
$cancelled_contracts->where('contracts.call_center', '=', $call_center);
$late_contracts->where('contracts.call_center', '=', $call_center);
$back_out_contracts->where('contracts.call_center', '=', $call_center);
$pending_late->where('contracts.call_center', '=', $call_center);
$pending_cancellation->where('contracts.call_center', '=', $call_center);
}
}
}
$pending = $pending->get()->first();
$active = $active->get()->first();
$cancelled_contracts = $cancelled_contracts->get()->first();
$late_contracts = $late_contracts->get()->first();
$back_out_contracts = $back_out_contracts->get()->first();
$pending_late = $pending_late->get()->first();
$pending_cancellation = $pending_cancellation->get()->first();
View::share('active_nav', 'Dashboard');
return view('dash.dash')
->with('pending_contracts', number_format($pending->total))
->with('month', $month)
->with('sellertype', $sellertype)
->with('active', number_format($active->total))
->with('companies', $companies)
->with('call_center', $call_center)
->with('year', date("Y"))
->with('cancelled_contracts', number_format($cancelled_contracts->total))
->with('late_contracts', number_format($late_contracts->total))
->with('back_out_contracts', number_format($back_out_contracts->total))
->with('pending_late', number_format($pending_late->total))
->with('pending_cancellation', number_format($pending_cancellation->total));
}