本文整理汇总了PHP中app\Branch::findOrFail方法的典型用法代码示例。如果您正苦于以下问题:PHP Branch::findOrFail方法的具体用法?PHP Branch::findOrFail怎么用?PHP Branch::findOrFail使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Branch
的用法示例。
在下文中一共展示了Branch::findOrFail方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: showWaitingRoom
public function showWaitingRoom(Request $request)
{
if ($request->session()->get('global_branch') == 'all') {
$branches = Branch::all();
} else {
$branches[] = Branch::findOrFail($request->session()->get('global_branch'));
}
$vars = array('branches' => $branches);
return view('backend.page.waiting-room')->with($vars);
}
示例2: doAddStockItem
public function doAddStockItem(Request $request)
{
if (count($request->input('branches')) > 0) {
$stock_item = Stock::addNew(["name" => $request->input('name'), "ean" => $request->input('ean'), "low_stock_notification_level" => $request->input('low-stock-number')]);
foreach ($request->input('branches') as $branch_id) {
$branch = Branch::findOrFail($branch_id);
$stock_item->attachToBranch($branch);
}
}
return redirect()->back()->with('stock-item-added', true);
}
示例3: getWaitingRoomCount
public static function getWaitingRoomCount()
{
if (session('global_branch') == 'all') {
$branches = Branch::all();
} else {
$branches[] = Branch::findOrFail(session('global_branch'));
}
$waiting_room_total = 0;
foreach ($branches as $b) {
$waiting_room_total += $b->appointments()->where('status_id', 3)->count();
}
return $waiting_room_total;
}
示例4: showWaitingRoom
public function showWaitingRoom(Request $request)
{
if ($request->session()->get('global_branch') == 'all') {
$branches = Branch::all();
} else {
$branches[] = Branch::findOrFail($request->session()->get('global_branch'));
}
view()->share('branches', $branches);
}
示例5: destroy
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function destroy($id)
{
if (Auth::user()->role === 'superadmin') {
$data = Branch::findOrFail($id);
$data->delete();
return redirect('branch');
} else {
return redirect('auth/login');
}
}
示例6: doRemoveStaffFromBranch
public function doRemoveStaffFromBranch($staff_id, $branch_id)
{
$branch = Branch::findOrFail($branch_id);
$branch->staff()->detach($staff_id);
return back()->with('staff-detached', true);
}
示例7: postAddroleindex
/**
* @param AddRoleRequest $request
* @return \Illuminate\View\View
*/
public function postAddroleindex(AddRoleRequest $request)
{
$branch = Branch::findOrFail($request->get('branch_id'));
$people = People::where('document', $request->get('document'))->get();
if (!$branch->worker->isEmpty()) {
$worker = $branch->worker;
$int = 0;
foreach ($worker as $w) {
if ($w->people_id == $people[0]->id) {
$int++;
}
}
if ($int != 0) {
flash()->overlay('No se pudo realizar la operación debido a que ya está registrada la persona ' . $people[0]->names . ' como empleado de esta sucursal.', 'Notificación de errores');
$people = People::all();
return redirect(url('/admin/role'));
} else {
$branch->worker()->save(new Worker(['people_id' => $people[0]->id]));
$user = $people[0]->user;
$user->roles()->sync($request->get('role_ids'));
flash()->success('Se realizó la asignación de roles con éxito.');
return redirect(url('/admin/role'));
}
} else {
$branch->worker()->save(new Worker(['people_id' => $people[0]->id]));
$user = $people[0]->user;
$user->roles()->sync($request->get('role_ids'));
flash()->success('Se realizó la asignación de roles con éxito.');
return redirect(url('/admin/role'));
}
}