本文整理汇总了PHP中app\User::findorfail方法的典型用法代码示例。如果您正苦于以下问题:PHP User::findorfail方法的具体用法?PHP User::findorfail怎么用?PHP User::findorfail使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\User
的用法示例。
在下文中一共展示了User::findorfail方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: update
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @return \Illuminate\Http\Response
*/
public function update(Request $request, $id)
{
$user = User::findorfail($id);
$input = Request::all();
$form = User::where('id', $id)->update(['status' => $input['number']]);
return redirect(url('/admin/user/info', $user->id));
}
示例2: updateInfo
public function updateInfo($id, Request $request)
{
//get data for table
$info = \App\User::findorfail($id);
$info->name = $request->name;
$info->language = $request->language;
$info->class = $request->class;
$info->teamstyle = $request->teamstyle;
//redirect to info
return redirect('auth.info');
}
示例3: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store()
{
$input = Request::all();
$summonername = str_replace(' ', '', $input['name']);
$result = file_get_contents('https://euw.api.pvp.net/api/lol/euw/v1.4/summoner/by-name/' . $summonername . '?api_key=6cabd680-61d0-48d5-9ee5-271f19c45624');
$input['summoner_id'] = json_decode($result)->{$summonername}->id;
$input['user_id'] = Auth::user()->id;
Summoners::create($input);
$summoner_id = Summoners::where('user_id', '=', Auth::user()->id)->get();
foreach ($summoner_id as $value) {
$user['summoner_id'] = $value->id;
}
$user = User::findorfail(Auth::user()->id);
$user->summoner_id = $value->id;
$user->save();
return redirect('home');
}
示例4: compose
/**
* Bind data to the view.
*
* @param View $view
* @return void
*/
public function compose(View $view)
{
$categories = Category::with('children', 'products')->where('parent_id', '=', 0)->orderBy('did')->get();
$hotpros_id = Salesstats::groupBy('product_id')->take(16)->get();
$hotpros_id = $hotpros_id->lists('product_id');
$hotpros = Product::with('images')->has('images')->has('prices')->wherein('id', $hotpros_id)->take(16)->get();
$globals = DB::table('globalsettings')->get();
$dts = DB::table('deliverytimes')->where('active', true)->get();
foreach ($dts as $dt) {
$dt->start = Carbon::parse($dt->start)->format('h:ia');
$dt->stop = Carbon::parse($dt->stop)->format('h:ia');
}
$settings = [];
foreach ($globals as $global) {
$name = $global->name;
$value = $global->value;
$settings[$name] = $value;
}
$offers = Offer::with(['categories', 'categories.products' => function ($q) {
$q->has('images');
}, 'brands', 'brands.products' => function ($q) {
$q->has('images');
}, 'products' => function ($q) {
$q->has('images');
}, 'products.images', 'products.prices'])->where('active', true)->where('start', '<=', Carbon::today()->toDateString())->where('end', '>=', Carbon::today()->toDateString())->take(16)->get();
//dd($offers);
$feedbacks = Feedback::with('user')->take(8)->get();
if ($user = Sentinel::check()) {
$user = User::findorfail($user->id);
$flashes = Flashtext::where('active', '1')->get();
$areas = Area::where('deliverable', '1')->get();
$viewpros_id = Viewstats::where('user_id', $user->id)->take(16)->get();
//dd($viewpros_id);
$viewpros_id = $viewpros_id->lists('product_id');
$viewpros = Product::with('images')->has('images')->has('prices')->wherein('id', $viewpros_id)->take(16)->get();
$view->with(['user' => $user, 'flashes' => $flashes, 'areas' => $areas, 'hotpros' => $hotpros, 'viewpros' => $viewpros, 'offers' => $offers, 'settings' => $settings, 'dts' => $dts, 'feedbacks' => $feedbacks, 'categories' => $categories]);
} else {
$flashes = Flashtext::where('active', '1')->get();
$areas = Area::where('deliverable', '1')->get();
$viewpros_id = Viewstats::where('user_id', 0)->take(16)->get();
$viewpros_id = $viewpros_id->lists('product_id');
$viewpros = Product::with('images')->has('images')->has('prices')->wherein('id', $viewpros_id)->take(16)->get();
$view->with(['flashes' => $flashes, 'areas' => $areas, 'hotpros' => $hotpros, 'viewpros' => $viewpros, 'offers' => $offers, 'settings' => $settings, 'dts' => $dts, 'feedbacks' => $feedbacks, 'categories' => $categories]);
}
}
示例5: newfeedback
public function newfeedback(Request $request)
{
$this->validate($request, ['feedback' => 'required|min:10']);
$user = Sentinel::check();
$user = User::findorfail($user->id);
if ($request->ajax()) {
$feedback = ['user_id' => $user->id, 'feedback' => $request->feedback];
$hasfeedback = Feedback::where('user_id', $user->id)->first();
if ($hasfeedback) {
$hasfeedback->feedback = $request->feedback;
$hasfeedback->save();
} else {
Feedback::create($feedback);
}
return response()->json(['success' => 'posted feedback']);
}
return redirect()->route('home');
}
示例6: update
public function update(Request $request, $id)
{
$validator = \Validator::make($request->all(), ['id' => 'required', 'email' => 'required|email|unique:users', 'name' => 'required', 'password' => 'min:6']);
if ($validator->fails()) {
throw new StoreResourceFailedException('Could not able to update user.', $validator->errors());
}
$user = User::findorfail($id);
$user->email = $request->get('email');
$user->name = $request->get('name');
if ($request->get('password')) {
$user->password = Hash::make($request->get('password'));
}
if ($user->save()) {
return $this->response->array(['message' => 'User has been updated successfully', 'status' => 200]);
} else {
return $this->response->array(['message' => 'Unable to update user. Please try again', 'status' => 200]);
}
}
示例7: update
function update($id)
{
$user = User::findorfail($id);
$user->name = Input::get('name');
$user->email = Input::get('email');
//$user->password = Input::get('password');
//$user_info = DB::table('users_info')->where('user_id', $id)->get();
$user_info = UserInfo::where('user_id', $id)->first();
$user_info->style = Input::get('style');
$user_info->lang_one = Input::get('lang_one');
$user_info->lang_two = Input::get('lang_two');
$user_info->lang_three = Input::get('lang_three');
$user_info->csci_261 = Input::get('csci_261');
$user_info->csci_262 = Input::get('csci_262');
$user_info->csci_306 = Input::get('csci_306');
$user_info->csci_406 = Input::get('csci_406');
// save new updated information
$user->save();
$user_info->save();
// redirect to /users/{id}
return redirect('/users/' . $id);
}
示例8: update
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @return \Illuminate\Http\Response
*/
public function update(Request $request, $id)
{
//$input = $request->all();
$input = $request->all();
$data = User::findorfail($id);
$data->update($input);
if (Input::hasFile('image')) {
if (Input::file('image')->isValid()) {
$destinationPath = base_path() . '/public/images/';
$extension = Input::file('image')->getClientOriginalExtension();
// getting image extension
$fileName = rand(11111, 99999) . '.' . $extension;
// renameing image
$file_input = $request->image_name;
if ($file_input) {
unlink(public_path('images/' . $file_input));
}
Input::file('image')->move($destinationPath, $fileName);
// uploading file to given path
$user1 = User::find($id);
$user1->name = $request->name;
$user1->email = $request->email;
//$user1->password = bcrypt($request->password);
$user1->address = $request->address;
$user1->gender = $request->gender;
$user1->image = $fileName;
$user1->save();
}
}
return redirect('udetails');
}
示例9: invite
public function invite($user_id)
{
$user = User::findorfail($user_id);
if ($user->team_id == 0) {
$input['alert_id'] = 1;
$input['user_id'] = $user_id;
$input['team_id'] = Auth::User()->team_id;
user_alert::create($input);
}
return redirect('home');
}
示例10: redirect
return redirect()->back();
// redirect back if current user tries to access another user
}
$user_info = UserInfo::where('user_id', $id)->first();
$user = User::findorfail($id);
return view('pages/edit', compact('user', 'user_info'));
});
Route::post('/users/{id}/edit', 'UserController@update');
// Password routes
Route::controllers(['password' => 'Auth\\PasswordController']);
// Admin routes - only accessible by admin user
Route::group(['middleware' => 'App\\Http\\Middleware\\AdminMiddleware'], function () {
Route::get('/admin', function () {
$users = User::all();
$users_info = UserInfo::all();
$numTeams = count(Team::all());
$nullteam = UserInfo::where('team_id', null)->first();
return view('admin.teams', compact('users_info', 'users', 'numTeams', 'nullteam'));
});
Route::post('/admin', 'AdminController@generate');
Route::get('/admin/generate', function () {
return view('admin.generate');
});
Route::get('/admin/users/{id}', function ($id) {
$user = User::findorfail($id);
$userinfo = UserInfo::findorfail($id);
$numTeams = count(Team::all());
return view('admin.user', compact('user', 'userinfo', 'numTeams'));
});
Route::post('/admin/users/{id}', 'AdminController@edit');
});
示例11: updateAdmin
public function updateAdmin(Request $request, $id)
{
//dd('goind to update');
$this->validate($request, ['email' => 'required|email|max:255']);
//dd($request);
$user = User::findorfail($id);
if ($user) {
$user->name = $request->name;
$user->email = $request->email;
$user->mobile = $request->mobile;
$user->save();
}
return redirect()->route('admin.user');
}
示例12: edit
/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function edit($id)
{
$user = User::findorfail($id);
return view('users.edit')->with('user', $user);
}
示例13: processreturn
public function processreturn(Request $request)
{
$this->validate($request, ['products' => 'required', 'name' => 'required', 'email' => 'required|email', 'mobile' => 'required|digits:10', 'address' => 'required', 'reason' => 'required']);
$order_ids = $request->get('products');
$orders = Order::whereIn('id', $order_ids)->get();
$user = Sentinel::check();
$user = User::findorfail($user->id);
$return_inputs = ['user_id' => $user->id, 'name' => $request->get('name'), 'email' => $request->get('email'), 'mobile' => $request->get('mobile'), 'address' => $request->get('address'), 'area_id' => $user->area_id, 'reason' => $request->get('reason'), 'status' => 'Booked'];
//dd($return_inputs);
$return = Orderreturn::Create($return_inputs);
if ($return) {
$returns = [];
foreach ($orders as $order) {
array_push($returns, ['order_id' => $order->id, 'return_id' => $return->id]);
}
DB::table('order_return')->insert($returns);
}
$notification = "Sorry! We regret you did not like these products.These products you have selected has been registered for return. Our staff will reach to you and receive those products. Kindly dont not consume the product and make it ready for pickup. Thank you.";
return view('site.notification', compact('notification'));
}
示例14: tempcart
public function tempcart(Requset $request)
{
if (Request::ajax()) {
$user = Sentinel::check();
$user = User::findorfail($user->id);
return response()->json('tempcart');
}
return back();
}
示例15: savemobile
public function savemobile(Request $request)
{
Sentinel::logout();
$this->validate($request, ['mobile' => 'required | digits:10']);
$user = User::findorfail($request->id);
$user->mobile = $request->mobile;
$user->save();
return redirect()->route('resendpin', ['id' => $user->id]);
}