本文整理汇总了PHP中app\Employee::findOrFail方法的典型用法代码示例。如果您正苦于以下问题:PHP Employee::findOrFail方法的具体用法?PHP Employee::findOrFail怎么用?PHP Employee::findOrFail使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Employee
的用法示例。
在下文中一共展示了Employee::findOrFail方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: single
public function single($mr, $currentMonth)
{
$actualVisits = [];
$MonthlyCustomerProducts = [];
$MRLine = [];
$doctors = Customer::where('mr_id', $mr)->get();
foreach ($doctors as $singleDoctor) {
$actualVisits[$singleDoctor->id] = Report::where('mr_id', $mr)->where('month', $currentMonth)->where('doctor_id', $singleDoctor->id)->count();
$MonthlyCustomerProducts[$singleDoctor->id] = Customer::monthlyProductsBought([$singleDoctor->id])->toArray();
}
$products = Product::where('line_id', Employee::findOrFail($mr)->line_id)->get();
$coverageStats = Employee::coverageStats($mr, $currentMonth);
$allManagers = Employee::yourManagers($mr);
$totalProducts = Employee::monthlyDirectSales($mr, $currentMonth);
$totalSoldProductsSales = $totalProducts['totalSoldProductsSales'];
$totalSoldProductsSalesPrice = $totalProducts['totalSoldProductsSalesPrice'];
$currentMonth = \Carbon\Carbon::parse($currentMonth);
$lines = MrLines::select('line_id', 'from', 'to')->where('mr_id', $mr)->get();
foreach ($lines as $line) {
$lineFrom = \Carbon\Carbon::parse($line->from);
$lineTo = \Carbon\Carbon::parse($line->to);
if (!$currentMonth->lte($lineTo) && $currentMonth->gte($lineFrom)) {
$MRLine = MrLines::where('mr_id', $mr)->where('line_id', $line->line_id)->get();
}
}
$dataView = ['doctors' => $doctors, 'MonthlyCustomerProducts' => $MonthlyCustomerProducts, 'actualVisits' => $actualVisits, 'products' => $products, 'totalVisitsCount' => $coverageStats['totalVisitsCount'], 'actualVisitsCount' => $coverageStats['actualVisitsCount'], 'totalMonthlyCoverage' => $coverageStats['totalMonthlyCoverage'], 'allManagers' => $allManagers, 'totalSoldProductsSales' => $totalSoldProductsSales, 'totalSoldProductsSalesPrice' => $totalSoldProductsSalesPrice, 'MRLines' => $MRLine];
return view('am.line.single', $dataView);
}
示例2: update
/**
* Update the specified resource in storage.
*
* @param Request $request
* @param int $id
* @return Response
*/
public function update(EmployeeRequest $request, $id)
{
$employee = Employee::findOrFail($id);
$employee->update($request->all());
flash()->success('Success!', 'Employee details saved successfully!');
return redirect('employees');
}
示例3: destroy
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function destroy($id)
{
$employee = Employee::findOrFail($id);
$name = $employee->name . " " . $employee->lastname;
Employee::destroy($id);
return redirect(route('employees.index'))->with('message', 'Empleado ' . $name . ' eliminado corectamente');
}
示例4: update
/**
* Update the specified resource in storage.
*
* @param int $id
* @return Response
*/
public function update($id)
{
$employee = Employee::findOrFail(Input::get('id'));
$employee->first_name = Input::get('first_name');
$employee->last_name = Input::get('last_name');
$employee->name = Input::get('first_name') . ' ' . Input::get('last_name');
$employee->email = Input::get('email');
$employee->position = Input::get('position');
$employee->phone = Input::get('phone');
$employee->location_id = Input::get('location');
$employee->status = 1;
$employee->role_id = 5;
$employee->department = Input::get('department');
$employee->extension_no = Input::get('extension_no');
$employee->vehicle_no = Input::get('vehicle_no');
$employee->save();
return Response::json(array('success' => 'Employee has been updated!'));
}
示例5: doCreate
public function doCreate(CreateMessageRequest $request)
{
$uploaded = false;
foreach ($request->employees as $key => $singleEmployee) {
$user = Employee::findOrFail($singleEmployee);
$message = new Message();
$message->sender = \Auth::user()->id;
$message->receiver = $singleEmployee;
$message->subject = $request->subject;
$message->time = \Carbon\Carbon::now()->toTimeString();
if ($message->save()) {
$messageReply = new MessageReply();
$messageReply->sender = \Auth::user()->id;
$messageReply->msg_id = $message->id;
$messageReply->text = $request->message;
$messageReply->time = \Carbon\Carbon::now()->toTimeString();
\File::makeDirectory(public_path('uploads/inbox/') . $message->id);
if ($messageReply->save()) {
if ($request->file('attachment')) {
$file = $request->file('attachment');
$messageReply->is_attachment = 1;
$messageReply->save();
$extension = $file->getClientOriginalExtension();
if ($file->isValid()) {
if ($uploaded) {
copy($uploaded, public_path('uploads/inbox/' . $this->originalDir));
} else {
if ($file->move(public_path('uploads/inbox/' . $message->id), $messageReply->id . '.' . $extension)) {
$uploaded = public_path('uploads/inbox/' . $message->id) . '/' . $messageReply->id . '.' . $extension;
$this->originalDir = $message->id;
}
}
}
}
}
\Mail::send('admin.emails.new_message', ['user' => $user], function ($m) use($user) {
$m->from('info@cloudscrm.info', 'CloudsCRM');
$m->to($user->email, $user->name)->subject('New Message!');
});
}
}
return redirect()->back()->with('message', 'Message has been sent successfully !');
}
示例6: logDriver
public function logDriver($id)
{
return $id == 999999999 ? 'Client Driver' : ($id == 0 ? '' : Employee::findOrFail($id)->name);
}
示例7: postEditSMProfile
public function postEditSMProfile(SMRequest $request)
{
$employee = Employee::findOrFail(\Auth::user()->id);
$employee->name = $request->name;
$employee->email = $request->email;
$employee->password = \Hash::make($request->password);
try {
$employee->save();
return redirect()->back()->with('message', 'Your Profile has been updated successfully !');
} catch (ParseException $ex) {
echo 'Failed to update your profile , with error message: ' . $ex->getMessage();
}
}
示例8: destroy
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return Response
*/
public function destroy($id)
{
$employee = Employee::findOrFail($id);
$employee->delete();
return Redirect::action('EmployeeController@index');
}
示例9: update
public function update(Request $request, $id)
{
$employee = Employee::findOrFail($id);
$employee->update($request::all());
return $employee;
}
示例10: destroy
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return Response
*/
public function destroy($id)
{
$employee = Employee::findOrFail($id)->delete();
return Redirect::route('admin.employee.list.index')->withFlashSuccess('Employee data was successfully deleted.');
}
示例11: changeClient
/**
* Store client information associated with driver
* @param Request $request
* Created by smartrahat Date: 04.11.2015 Time: 02:39PM
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
*/
public function changeClient(Request $request)
{
$request['action'] = 'Add';
$request['c_description'] = 'Add driver';
$request['e_description'] = 'Assign to client';
$employee = Employee::findOrFail($request['eid']);
$employee->update($request->only('cid'));
Log::create($request->all());
return redirect('employee/' . $request['eid']);
}
示例12: handleDeleteEmployee
public function handleDeleteEmployee()
{
// Handle the delete confirmation.
$id = Input::get('employee');
$employee = Employee::findOrFail($id);
$employee->delete();
return Redirect::action('CommonController@employees');
}
示例13: removeDriver
public function removeDriver(Request $request)
{
$redirect = $request['cid'];
$request['c_description'] = 'Driver removed';
$request['e_description'] = 'Removed form client';
$request['action'] = 'Remove';
Log::create($request->all());
// update log
$driver = Employee::findOrFail($request['eid']);
$request['cid'] = 0;
$driver->update($request->only(['cid']));
// update driver's foreign key
return redirect('client/' . $redirect);
}
示例14: doDelete
public function doDelete($id)
{
$employee = Employee::findOrFail($id);
try {
$this->deletAvatar($id);
$employee->delete();
return redirect()->back()->with('message', 'Employee has been deleted successfully !');
} catch (ParseException $ex) {
echo 'Failed to delete this employee , with error message: ' . $ex->getMessage();
}
}
示例15: search
public function search()
{
$doctors = Customer::where('mr_id', \Auth::user()->id)->get();
$MRLine = Employee::findOrFail(\Auth::user()->id)->line_id;
$products = Product::where('line_id', $MRLine)->get();
$gifts = Gift::all();
$dataView = ['doctors' => $doctors, 'products' => $products, 'gifts' => $gifts];
return view('mr.search.reports.search', $dataView);
}