本文整理汇总了PHP中Profile::where方法的典型用法代码示例。如果您正苦于以下问题:PHP Profile::where方法的具体用法?PHP Profile::where怎么用?PHP Profile::where使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Profile
的用法示例。
在下文中一共展示了Profile::where方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testSearchUserSuccess
public function testSearchUserSuccess()
{
$data = array();
$user_id = $this->_user_id;
$_params = $this->_params;
$_params['user_id'] = $user_id;
$response = $this->_getAuth($_params);
$text = $_params['text'];
//get created login information
$user = Profile::where('first_name', 'LIKE', '%' . $text . '%')->orWhere('last_name', 'LIKE', '%' . $text . '%')->whereNotIn('user_id', [$user_id])->get();
if ($user) {
foreach ($user as $users) {
$follow = Follow::where('from_id', $user_id)->where('to_id', $users->user_id)->first();
if ($follow) {
$users->is_follow = true;
} else {
$users->is_follow = false;
}
if ($users->image != null) {
$users->image = URL::asset($users->image);
}
}
$data = $user->toArray();
}
$this->assertNotNull($data);
$this->assertEquals(array("code" => ApiResponse::OK, "data" => $data), json_decode($response->getContent(), true));
}
示例2: update
public function update($id)
{
$data = array("first_name" => Input::get("first_name"), "last_name" => Input::get("last_name"), "email" => Input::get("email"), "phone" => Input::get("phone"), "picture" => Input::file("picture"), "specialty_id" => Input::get("specialty_id"), "dating_duration" => Input::get("dating_duration"));
$rules = array("first_name" => 'required|min:1|max:255', "last_name" => 'required|min:1|max:100', "email" => 'required|min:1', "phone" => 'required|min:1|max:100', "specialty_id" => 'required|min:3|max:255', "dating_duration" => 'required|min:1|max:3', "picture" => 'mimes:jpeg,gif,png');
$messages = array('required' => 'El campo :attribute es obligatorio.', 'min' => 'El campo :attribute no puede tener menos de :min carácteres.', 'email' => 'El campo :attribute debe ser un email válido.', 'max' => 'El campo :attribute no puede tener más de :max carácteres.', 'numeric' => 'El campo :attribute debe contener solo numeros', 'mimes' => 'El formato de la imagen logo debe ser jpg, git, png');
$validation = Validator::make(Input::all(), $rules, $messages);
//si la validación falla redirigimos al formulario de registro con los errores
//y con los campos que nos habia llenado el usuario
if ($validation->fails()) {
return Redirect::to('/doctor/profile')->withErrors($validation)->withInput();
} else {
$doctor = Doctor::find($id);
$agenda = Agenda::where('doctor_id', $doctor->id)->first();
$agenda->dating_duration = Input::get("dating_duration");
$agenda->save();
$espes = explode(',', Input::get("specialty_id"));
$espeuok = '';
foreach ($espes as $espe) {
$very = Specialty::where('name_es', $espe)->first();
if ($very) {
$espeuok = $espeuok . ',' . $very->id;
}
}
$doctor->specialty_id = $espeuok;
$doctor->save();
$user = User::find($doctor->user_id);
$user->first_name = $data['first_name'];
$user->last_name = $data['last_name'];
$user->save();
$profile = Profile::where('user_id', $doctor->user_id)->first();
if (Input::file('picture') != NULL) {
//agrega imagen de logo
$file_logo = Input::file('picture');
$ext = Input::file('picture')->getClientOriginalExtension();
$nameIMG = date('YmdHis');
$logo = $nameIMG . '.' . $ext;
$logo = 'assets/doctor/images/profile_pic/profile_' . $logo;
$profile->picture = $logo;
}
$profile->phone = Input::get("phone");
$profile->save();
if ($profile) {
if (Input::file('picture') != NULL) {
$file_logo->move("assets/doctor/images/profile_pic/", $logo);
}
return Redirect::to('/doctor/profile')->withFlash_message("Guardado Exitosamente");
} else {
return Redirect::to('/doctor/profile')->withErrors("Error")->withInput();
}
}
}
示例3: post_manage
public function post_manage()
{
$user_fullname = Input::get('user');
$year_id = Input::get('year_id');
$executive_id = Input::get('executive_id');
$profile = Profile::where('full_name', '=', $user_fullname)->first();
if (!$profile) {
return Redirect::to('rms/executives/manage/' . $executive_id)->with('warning', 'Please enter a member');
}
$user = $profile->user;
if (!$user->is_part_of_exec($year_id, $executive_id)) {
$user->executives()->attach($executive_id, array('non_executive' => Input::get('non_executive', 0), 'year_id' => $year_id));
return Redirect::to('rms/executives/manage/' . $executive_id)->with('success', 'Successfully added member to executive');
} else {
return Redirect::to('rms/executives/manage/' . $executive_id)->with('warning', 'They are already a member of that executive');
}
}
示例4: allUserData
/**
* @param $id
*/
public function allUserData($id, $mode = 'show')
{
if (!($user = User::find($id))) {
abort(404);
}
$name = $user->full_name;
if (!($fullProfile = Profile::where('user_id', '=', $id)->first())) {
$fullProfile = new Profile();
}
$cityLiving = $this->placeLiving($fullProfile->place_living_id);
$cityFrom = $this->placeFrom($fullProfile->place_from_id);
$languages_high = Language::where('profile_id', '=', $fullProfile->id)->where('level', '=', 'advanced')->get();
$languages_med = Language::where('profile_id', '=', $fullProfile->id)->where('level', '=', 'intermediate')->get();
$languages_low = Language::where('profile_id', '=', $fullProfile->id)->where('level', '=', 'basic')->get();
//Avatar is optional
if ($user->avatar) {
$avatar = $user->avatar;
}
if ($mode == 'show' || $mode == 'references') {
$references = Reference::where('profile_user_id', '=', $id)->with(['user'])->orderBy('updated_at', 'DES')->get();
$age = $user->age;
$owner = \Auth::id() == $id;
$gender = $user->gender;
$places = $user->placesWanted;
$placesVisited = $user->placesVisited;
$avg = Reference::where('profile_user_id', '=', $id)->avg('grade');
$ref = false;
$fav = boolval(Favorites::where('owner_id', \Auth::id())->where('user_id', $id)->first());
if ($mode == 'references') {
$ref = true;
}
return compact('fullProfile', 'references', 'name', 'avatar', 'ref', 'avg', 'cityFrom', 'cityLiving', 'age', 'gender', 'id', 'owner', 'fav', 'languages_high', 'languages_med', 'languages_low', 'places', 'placesVisited');
} else {
if ($mode == 'edit') {
return compact('fullProfile', 'cityFrom', 'cityLiving', 'name', 'avatar', 'id', 'languages_high', 'languages_med', 'languages_low');
} else {
return abort(404);
}
}
}
示例5: getProfile
public static function getProfile($user_id, $title, $id, $rating_id, $updated_at)
{
$profile = Profile::where('user_id', $user_id)->first();
$data = array('first_name' => $profile->first_name, 'last_name' => $profile->last_name, 'avatar' => URL::asset($profile->image), 'title' => $title, 'id' => $id, 'rating_id' => $rating_id, 'updated_at' => $updated_at);
return $data;
}
示例6:
<form>
<table class="table table-striped" id="table-example">
<thead>
<tr>
<th class="text-center">Imagen</th>
<th class="text-center">Name</th>
<th class="text-center">Email</th>
<th class="text-center">Phone</th>
<th class="text-center">Citas pendientes/Historia de citas</th>
</tr>
</thead>
<tbody align="center">
@foreach($patients as $d)
<?php
$user = User::find($d->user_id);
$profile = Profile::where('user_id', $user->id)->first();
?>
<tr class="odd gradeX">
<td><img class="circle profile-table" src="@if($profile->picture!="") {{url($profile->picture)}} @else http://agenda.dev/assets/doctor/images/profile_pic/default.png @endif" alt=""></td>
<td>{{$user->getFullName()}}</td>
<td>{{$user->email}}</td>
<td>{{$profile->phone}}</td>
<td><a href="{{url('/doctor/agenda/'.$d->agenda_id.'/patient/'.$d->patient_id.'/appointments-pending')}}" type="button" class="btn btn-info btn-transparent" data-toggle="tooltip" data-placement="left" title="Citas Pendientes"><i class="fa fa-clock-o"></i> Pendientes</a>
<a href="{{url('/doctor/agenda/'.$d->agenda_id.'/patient/'.$d->patient_id.'/appointments-history')}}" type="button" class="btn btn-info btn-transparent" data-toggle="tooltip" data-placement="left" title="Historia de citas"><i class="fa fa-clock-o"></i> Historia</a></td>
</tr>
@endforeach
</tbody>
</table>
</form>
</div>
</section>
示例7: loginWithGithub
public function loginWithGithub()
{
$code = Input::get('code');
$githubService = OAuth::consumer('Github');
if (!empty($code)) {
try {
$token = $githubService->requestAccessToken($code);
$result = json_decode($githubService->request('user'), true);
} catch (Exception $e) {
die("Too many requests, access denied by Github. Please wait a while.");
}
$profile = Profile::where('uid', '=', $result['id'])->first();
if (empty($profile)) {
$user = new User();
$user->name = $result['name'];
$user->email = $result['email'];
$user->photo = $result['avatar_url'];
$user->save();
$profile = new Profile();
$profile->uid = $result['id'];
// $profile->access_token = $fb->requestAccessToken( $code );
$profile->username = $result['login'];
$profile->gender = $result['bio'];
$profile = $user->profiles()->save($profile);
}
$profile->save();
$user = $profile->user;
Auth::login($user);
return Redirect::to('/')->with('message', 'Logged in with Facebook');
} else {
// get githubService authorization
$url = $githubService->getAuthorizationUri();
return Redirect::to((string) $url);
}
}
示例8: destroy
public function destroy($id)
{
$doctor = Doctor::find($id);
$userId = $doctor->user_id;
$doctor->delete();
$profile = Profile::where('user_id', $userId)->first();
$profile->delete();
$user = User::find($userId);
$user->delete();
if ($user) {
return Redirect::back()->withConfirm("Eliminado Exitosamente");
} else {
return Redirect::back()->withErrors("Error");
}
}
示例9: picture
public static function picture()
{
$user = Sentry::getUser();
$profile = Profile::where('user_id', $user->id)->first();
return $profile->picture;
}
示例10: storeLogin
public function storeLogin()
{
$inputs = array('identity' => Input::get('identity'), 'password' => Input::get('password'));
//Since user can enter username,email we cannot have email validator
$rules = array('identity' => 'required|min:4|max:32', 'password' => 'required|min:6');
//Find is that username or password and change identity validation rules
//Lets use regular expressions
if (filter_var(Input::get('identity'), FILTER_VALIDATE_EMAIL)) {
//It is email
$rules['identity'] = 'required|min:4|max:32|email';
} else {
//It is username . Check if username exist in profile table
if (Profile::where('username', Input::get('identity'))->count() > 0) {
//User exist so get email address
$user = Profile::where('username', Input::get('identity'))->first();
$inputs['identity'] = $user->email;
} else {
Session::flash('error_msg', 'User does not exist');
return Redirect::to('/login')->withInput(Input::except('password'));
}
}
$v = Validator::make($inputs, $rules);
if ($v->fails()) {
return Redirect::to('/login')->withErrors($v)->withInput(Input::except('password'));
} else {
try {
//Try to authenticate user
$user = Sentry::getUserProvider()->findByLogin(Input::get('identity'));
$throttle = Sentry::getThrottleProvider()->findByUserId($user->id);
$throttle->check();
//Authenticate user
$credentials = array('email' => Input::get('identity'), 'password' => Input::get('password'));
//For now auto activate users
$user = Sentry::authenticate($credentials, false);
//At this point we may get many exceptions lets handle all user management and throttle exceptions
} catch (Cartalyst\Sentry\Users\LoginRequiredException $e) {
Session::flash('error_msg', 'Login field is required.');
return Redirect::to('/login');
} catch (Cartalyst\Sentry\Users\PasswordRequiredException $e) {
Session::flash('error_msg', 'Password field is required.');
return Redirect::to('/login');
} catch (Cartalyst\Sentry\Users\WrongPasswordException $e) {
Session::flash('error_msg', 'Wrong password, try again.');
return Redirect::to('/login');
} catch (Cartalyst\Sentry\Users\UserNotFoundException $e) {
Session::flash('error_msg', 'User was not found.');
return Redirect::to('/login');
} catch (Cartalyst\Sentry\Users\UserNotActivatedException $e) {
Session::flash('error_msg', 'User is not activated.');
return Redirect::to('/login');
} catch (Cartalyst\Sentry\Throttling\UserSuspendedException $e) {
Session::flash('error_msg', 'User is suspended ');
return Redirect::to('/login');
} catch (Cartalyst\Sentry\Throttling\UserBannedException $e) {
Session::flash('error_msg', 'User is banned.');
return Redirect::to('/login');
}
Session::flash('success_msg', 'Loggedin Successfully');
return Redirect::to('/');
}
}
示例11: update
public function update($id)
{
$data = array("first_name" => Input::get("first_name"), "last_name" => Input::get("last_name"), "email" => Input::get("email"), "phone" => Input::get("phone"), "picture" => Input::file("picture"), "password" => Input::get("password"), "password_confirmation" => Input::get("password_confirmation"));
if (Input::get("password") != "") {
$rules = array("first_name" => 'required|min:1|max:255', "last_name" => 'required|min:1|max:100', "email" => 'required|email', "phone" => 'required|min:1|max:100', "picture" => 'mimes:jpeg,gif,png', 'password' => 'confirmed|min:6');
} else {
$rules = array("first_name" => 'required|min:1|max:255', "last_name" => 'required|min:1|max:100', "email" => 'required|email', "phone" => 'required|min:1|max:100', "picture" => 'mimes:jpeg,gif,png');
}
$messages = array('required' => 'El campo :attribute es obligatorio.', 'min' => 'El campo :attribute no puede tener menos de :min carácteres.', 'email' => 'El campo :attribute debe ser un email válido.', 'max' => 'El campo :attribute no puede tener más de :max carácteres.', 'numeric' => 'El campo :attribute debe contener solo numeros', 'mimes' => 'El formato de la imagen logo debe ser jpg, git, png', 'unique' => 'El :attribute ingresado ya esta siendo usaddo por otro usuario.', 'confirmed' => 'La confirmación del :attribute no coincide');
$validation = Validator::make(Input::all(), $rules, $messages);
//si la validación falla redirigimos al formulario de registro con los errores
//y con los campos que nos habia llenado el usuario
if ($validation->fails()) {
return Redirect::to('/clinic/users/' . $id . '/edit')->withErrors($validation)->withInput();
} else {
$user = User::find($id);
$user->first_name = Input::get("first_name");
$user->last_name = Input::get("last_name");
$user->email = Input::get("email");
if (Input::get("password") != "") {
$user->password = Input::get("password");
}
$user->save();
$profile = Profile::where('user_id', $id)->first();
if (Input::file('picture') != NULL) {
//agrega imagen de logo
$file_logo = Input::file('picture');
$ext = Input::file('picture')->getClientOriginalExtension();
$nameIMG = date('YmdHis');
$logo = $nameIMG . '.' . $ext;
$logo = 'assets/doctor/images/profile_pic/profile_' . $logo;
$file_logo->move("assets/doctor/images/profile_pic/", $logo);
$profile->picture = $logo;
}
$profile->lang = Input::get("lang");
$profile->phone = Input::get("phone");
$profile->save();
if ($profile) {
return Redirect::to('/clinic/users/')->withFlash_message("Guardado Exitosamente");
} else {
return Redirect::to('/clinic/users/' . $id . '/edit')->withErrors("Error")->withInput();
}
}
}
示例12: member
function member($id) {
if (!is_numeric($id))
return false;
if ($this->tank_auth->get_user_id() == $id && $this->uri->segment(3) != 'you')
redirect('/admin/members/you/');
if ($this->tank_auth->is_admin() || $this->tank_auth->is_group('mod'))
$can_edit = true;
else
$can_edit = false;
if ($this->tank_auth->get_user_id() == $id)
$can_edit_limited = true;
else
$can_edit_limited = false;
if ($this->input->post() && ( $can_edit || $can_edit_limited)) {
$profile = new Profile($id);
$profile->from_array($this->input->post(), array('display_name', 'twitter', 'bio'), TRUE);
}
$this->viewdata["function_title"] = _("Member");
$user = new User($id);
if ($user->result_count() == 0)
return false;
if($this->tank_auth->is_allowed())
{
$table = ormer($user);
//$table = tabler($table, TRUE, $can_edit); not even admins should edit
$table = tabler($table, TRUE, FALSE);
$data['table'] = $table;
}
else {
$data["table"] = "";
}
$data['user'] = $user;
$profile = new Profile();
$profile->where('user_id', $id)->get();
$profile_table = ormer($profile);
$data['profile'] = tabler($profile_table, TRUE, $can_edit);
$data['can_edit'] = $can_edit;
$this->viewdata["main_content_view"] = $this->load->view('auth/user', $data, TRUE);
$this->load->view("admin/default", $this->viewdata);
}
示例13: testGetProfileWishlishSucsses
public function testGetProfileWishlishSucsses()
{
$this->setUpWishlist();
$user_id = $this->_user_id;
$response = $this->action('GET', 'ProfileController@get_profile_wishlist_user', array('user_id' => $user_id));
$page = 1;
$limit = 10;
$profile = Profile::where('user_id', $user_id)->first();
if ($profile->image != null) {
$profile->image = URL::asset($profile->image);
}
$wishlist = Wishlist::where('user_id', $user_id)->with('wine')->forPage($page, $limit)->get();
foreach ($wishlist as $wishlists) {
$wishlists->winery = Winery::where('id', $wishlists->wine->winery_id)->first()->toArray();
if ($wishlists->wine->image_url != null) {
$wishlists->wine->image_url = URL::asset($wishlists->wine->image_url);
}
if ($wishlists->wine->wine_flag != null) {
$wishlists->wine->wine_flag = URL::asset($wishlists->wine->wine_flag);
}
}
$data = $wishlist;
$this->assertEquals(array("code" => ApiResponse::OK, "data" => $data->toArray()), json_decode($response->getContent(), true));
}
示例14: testCreateCommentSuccess
public function testCreateCommentSuccess()
{
$_params = $this->_params;
$_params['user_id'] = $this->_user_id;
$response = $this->_getAuth($_params);
//get created login information
$comment_infor = Comment::get(array('user_id', 'rating_id', 'content', 'updated_at', 'created_at', 'id'))->last();
$profile = Profile::where('user_id', $comment_infor->user_id)->first();
if ($profile->image != null) {
$comment_infor->avatar_user = URL::asset($profile->image);
} else {
$comment_infor->avatar_user = $profile->image;
}
$comment_infor->first_name = $profile->first_name;
$comment_infor->last_name = $profile->last_name;
$this->assertNotNull($comment_infor);
$this->assertEquals(array("code" => ApiResponse::OK, "data" => $comment_infor->toArray()), json_decode($response->getContent(), true));
}
示例15: member
function member($id)
{
// don't troll us with other than numbers as ID, throw 404 in case
if (!is_numeric($id)) {
show_404();
}
// if the user doesn't exist throw 404
$user = new User($id);
if ($user->result_count() != 1) {
show_404();
}
// if the user is clicking on himself, send him to the you page.
// the you method sends back here, so the user will still see the rest.
// the second part of the if makes sure that if "member" method is called from "you"
// the user is not redirected to "you" again
if ($this->tank_auth->get_user_id() == $id && $this->uri->segment(3) != 'you') {
redirect('/account/profile/');
}
// give admins and mods ability to edit user profiles
if ($this->input->post() && $this->tank_auth->is_allowed()) {
$profile = new Profile($id);
if ($profile->result_count() == 1) {
$profile->from_array($this->input->post(), array('display_name', 'twitter', 'bio'), TRUE);
}
}
// set the subtitle
$this->viewdata["function_title"] = '<a href="' . site_url("admin/members") . '">' . _('Members') . '</a>';
// create a table with user login name and email
$table = ormer($user);
$table = tabler($table, TRUE, FALSE);
$data['table'] = $table;
// let's give the user object to the view
$data['user'] = $user;
// grab the profile and put it in a table
$profile = new Profile();
$profile->where('user_id', $id)->get();
$profile_table = ormer($profile);
$data['profile'] = tabler($profile_table, TRUE, $this->tank_auth->is_allowed() || $this->uri->segment(3) != 'you');
$this->viewdata["extra_title"][] = $user->username;
// print out
$this->viewdata["main_content_view"] = $this->load->view('admin/members/user', $data, TRUE);
$this->load->view("admin/default", $this->viewdata);
}