本文整理匯總了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'));
}
}