本文整理汇总了PHP中User::findOrFail方法的典型用法代码示例。如果您正苦于以下问题:PHP User::findOrFail方法的具体用法?PHP User::findOrFail怎么用?PHP User::findOrFail使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类User
的用法示例。
在下文中一共展示了User::findOrFail方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: show
/**
* Display the specified resource.
*
* @param int $id
* @return Response
*/
public function show($id)
{
error_log("calle");
$user = $this->user->findOrFail($id);
return $user;
//return View::make('users.show', compact('user'));
}
示例2: usuariopuedereservartodo
public function usuariopuedereservartodo($id)
{
if (User::findOrFail($id)->isUser() || $this->tipo != Config::get('options.equipo')) {
return false;
}
return true;
}
示例3: store
public function store()
{
$user = User::findOrFail(Input::get('cliente_id'));
$input = Input::all();
$pedido = new Pedido();
$pedido->cliente_id = $user->id;
$pedido->nome = $user->nome;
$pedido->email = $user->email;
$pedido->pedido_status_id = $input['status'];
$produtos = $input['produtos'];
foreach ($produtos as $id => $produto) {
$pedido_itens[][63] = array('nome_br' => $produto['nome'], 'nome_en' => $produto['nome'], 'preco' => $produto['preco'], 'tipo' => '', 'quantidade' => $produto['quantidade']);
$pedido->total += $produto['preco'] * $produto['quantidade'];
}
$pedido->save();
$historico = new PedidoHistorico();
$historico->pedido_id = $pedido->id;
$historico->pedido_status_id = 12;
$historico->save();
if (isset($pedido_itens)) {
foreach ($pedido_itens as $key => $iten) {
$pedido->produtos()->attach($iten);
}
}
return Redirect::to("admin/pedido/{$pedido->id}/edit")->with('success', array('Pedido gerado com produtos personalizados.'));
}
示例4: getPosts
public function getPosts($id)
{
try {
// find user by username
$user = User::where('username', $id)->first();
// else find by id
if (is_null($user)) {
$user = User::findOrFail($id);
}
$posts = $user->posts()->paginate(Request::ajax() ? 4 : 8);
$i = 0;
foreach ($posts as $post) {
if (!PrivacyHelper::checkPermission(Auth::user(), $post)) {
unset($posts[$i]);
$i++;
continue;
}
$i++;
$post->makrdown = str_limit($post->makrdown, $limit = 500, $end = '...');
$Parsedown = new Parsedown();
$post->HTML = $Parsedown->text($post->makrdown);
}
if (Request::ajax()) {
return View::make('posts._list')->with('data', $posts);
} else {
if (count($posts) == 0) {
return Redirect::intended(URL::action('ProfileController@getProfile', array($id)));
}
$this->layout->content = View::make('posts.list')->with('data', $posts);
}
} catch (Exception $e) {
throw $e;
}
}
示例5: destroy
/**
* Delete a book
*
* @param $book_id
* @return Response
*/
public function destroy($book_id)
{
$book = User::findOrFail($book_id);
$book->users()->sync([]);
$book->delete();
return Response::json(['success' => true]);
}
示例6: index
public function index()
{
$folderName = Input::get('folder');
$groupName = Input::has('group') ? shadow(Input::get('group')) : 'all';
$className = 'Strimoid\\Models\\Folders\\' . studly_case($folderName ?: $groupName);
if (Input::has('folder') && !class_exists('Folders\\' . studly_case($folderName))) {
$user = Input::has('user') ? User::findOrFail(Input::get('user')) : Auth::user();
$folder = Folder::findUserFolderOrFail($user->getKey(), Input::get('folder'));
if (!$folder->public && (Auth::guest() || $user->getKey() != Auth::id())) {
App::abort(404);
}
$builder = $folder->entries();
} elseif (class_exists($className)) {
$fakeGroup = new $className();
$builder = $fakeGroup->entries();
$builder->orderBy('sticky_global', 'desc');
} else {
$group = Group::name($groupName)->firstOrFail();
$group->checkAccess();
$builder = $group->entries();
// Allow group moderators to stick contents
$builder->orderBy('sticky_group', 'desc');
}
$builder->with(['user', 'group', 'replies', 'replies.user'])->orderBy('created_at', 'desc');
$perPage = Input::has('per_page') ? between(Input::get('per_page'), 1, 100) : 20;
return $builder->paginate($perPage);
}
示例7: update
/**
* Update the specified karyawan in storage.
*
* @param int $id
* @return Response
*/
public function update($id)
{
$rules = array('first_name' => 'required', 'unit_kerja' => 'required|exists:unitkerjas,id', 'unit' => 'required|exists:units,id', 'jabatan' => 'required|exists:jabatans,id');
$karyawan = User::findOrFail($id);
$validator = Validator::make($data = Input::only('first_name', 'last_name', 'nip', 'unit_kerja', 'unit', 'jabatan'), $rules);
if ($validator->fails()) {
return Redirect::back()->withErrors($validator)->withInput();
} else {
//code
DB::table('users')->where('id', $id)->update(array('first_name' => Input::get('first_name'), 'last_name' => Input::get('last_name'), 'nip' => Input::get('nip'), 'unit_kerja' => Input::get('unit_kerja'), 'unit' => Input::get('unit'), 'jabatan' => Input::get('jabatan')));
// Find the user using the user id
//$usergroupremove = Sentry::getUserProvider()->findById($id);
// Find the group using the group id
//$groupremove = Sentry::findGroupById($usergroupremove->getGroups());
// Assign the group to the user
//$usergroupremove->removeGroup($groupsremove);
// Find the user using the user id
//$user = Sentry::findUserById($id);
// Find the group using the group id
//$adminGroup = Sentry::findGroupById(Input::get('group'));
// Assign the group to the user
//$user->addGroup($adminGroup);
//$user->save();
}
$karyawan->update($data);
return Redirect::route('admin.karyawan.index')->with("successMessage", "Berhasil menyimpan {$karyawan->first_name}. ");
}
示例8: sendManualEmail
public static function sendManualEmail($memberid, $contactid, $templateid)
{
$contact = Contact::findOrFail($contactid);
$user = User::findOrFail($memberid);
if (!$user || !$contact) {
return false;
}
if (!$user->active || !$contact->active) {
return false;
}
if (EmailSchedullerPool::sendmail($memberid, $contactid, $templateid)) {
if ($contact->email_sent == "" || $contact->email_sent == 0) {
$contact->email_sent = $templateid;
$contact->last_follow_up = date('Y-m-d H:i:s');
$contact->save();
} else {
if ($contact->templateExist($templateid)) {
//do nothing
} else {
$contact->email_sent = $contact->email_sent . "," . $templateid;
$contact->save();
}
}
$contact->saveHistory("success", $memberid, $templateid);
return true;
} else {
return false;
}
}
示例9: postProfil
public function postProfil()
{
$validate = Validator::make(Input::all(), ['adsoyad' => 'required', 'email' => 'required|email|unique:users,email,' . Auth::user()->id . '', 'profil' => 'mimes:jpg,png,gif,jpeg']);
$messages = $validate->messages();
if ($validate->fails()) {
return Redirect::back()->with(array('mesaj' => 'true', 'title' => 'Doğrulama Hatası', 'text' => '' . $messages->first() . '', 'type' => 'error'));
}
$user = User::findOrFail(Auth::user()->id);
$user->namesurname = Input::get('adsoyad');
if (Input::has('password')) {
$user->password = Hash::make(Input::get('password'));
$user->save();
}
$user->email = Input::get('email');
if (Input::hasFile('profil')) {
if (Auth::user()->profil != '') {
File::delete('Backend/avatar/' . Auth::user()->profil . '');
}
$profil = Input::file('profil');
$dosyaadi = $profil->getClientOriginalName();
$uzanti = $profil->getClientOriginalExtension();
$isim = Str::slug($dosyaadi) . Str::slug(str_random(5)) . '.' . $uzanti;
$dosya = $profil->move('Backend/avatar/', $isim);
$image = Image::open('Backend/avatar/' . $isim)->resize(80, 80)->save();
$user->profil = $isim;
$user->save();
}
$user->save();
if ($user->save()) {
return Redirect::back()->with(array('mesaj' => 'true', 'title' => 'Kullanıcı Güncellendi', 'text' => 'Kullanıcı Başarı İle Güncellendi', 'type' => 'success'));
} else {
return Redirect::back()->with(array('mesaj' => 'true', 'title' => 'Kullanıcı Güncellenemedi', 'text' => 'Kullanıcı Güncellenirken Sorun İle Karşılaşıldı', 'type' => 'error'));
}
}
示例10: usuariopuedereservartodoslospuestos
/**
* Devuelve true si usuario identificado por $id puede reservar todos lo puestos de un recurso tipo espacio
* @param $id int (identificador de usuario)
* @return boolean
*/
public function usuariopuedereservartodoslospuestos($id)
{
if (User::findOrFail($id)->isUser() || $this->puestos->count() == 0) {
return false;
}
return true;
}
示例11: postProfil
public function postProfil()
{
$validation = Validator::make(Input::all(), User::$user_validate);
if ($validation->fails()) {
return Redirect::back()->with(['message' => 'true', 'title' => 'Uyarı!', 'text' => 'Kullanıcı adınızı boş bıraktınız.', 'type' => 'warning']);
}
$user = User::findOrFail(Auth::user()->id);
$user->username = Input::get('username');
$user->email = Input::get('email');
$user->name = Input::get('name');
if (Input::has('recovery')) {
$user->recovery = Input::get('recovery');
$user->save();
}
if (Input::has('password')) {
$user->password = Hash::make(Input::get('password'));
$user->save();
}
$user->save();
if ($user->save()) {
return Redirect::back()->with(['message' => 'true', 'title' => 'Tebrikler!', 'text' => 'Hesap bilgileriniz başarıyla güncelleştirildi.', 'type' => 'success']);
} else {
return Redirect::back()->with(['message' => 'true', 'title' => 'Hata!', 'text' => 'Hesap bilgileriniz güncelleştirilemedi!', 'type' => 'error']);
}
}
示例12: testShouldUpdateUser
public function testShouldUpdateUser()
{
$user = User::create(['username' => 'ajcastro', 'password' => 'password', 'name' => 'arjon_x', 'email' => 'ajcastro29@gmail.com', 'password' => '123456']);
$updatedUser = $this->repo->update($user->id, ['name' => 'arjon']);
$this->assertEquals('arjon', User::findOrFail($user->id)->name);
$this->assertTrue($updatedUser instanceof User);
}
示例13: show
public function show($id)
{
try {
$iteration = Iterations::findOrFail($id);
$iterations = Iterations::where('projectid', '=', $iteration->projectid)->get();
$project = Project::findOrFail($iteration->projectid);
$issues = Issue::where('iterationid', '=', $id)->get();
//$issues = $iteration->issues;
$countIssues = sizeof($issues);
$categories = Category::all();
$idCategory = 0;
$totalPoints = $issues->sum('points');
$materiales = Material::all();
$personal = PersonalType::all();
$team = Teams::where('projectid', '=', $project->id)->get()->first();
$members = DB::table('memberof')->where('teamid', '=', $team->id)->get();
$hasmembers = sizeof($members) > 0 ? true : false;
$users = array();
foreach ($members as $member) {
$users[] = User::findOrFail($member->usersid);
echo $hasmembers;
}
$this->layout->content = View::make('layouts.iterations.show')->with('iteration', $iteration)->with('iterations', $iterations)->with('issues', $issues)->with('categories', $categories)->with('idCategory', $idCategory)->with('countIssues', $countIssues)->with('totalPoints', $totalPoints)->with('project', $project)->with('materiales', $materiales)->with('personal', $personal)->with('hasmembers', $hasmembers)->with('members', $members)->with('users', $users)->with('message', '');
} catch (Illuminate\Database\Eloquent\ModelNotFoundException $e) {
return Redirect::to('/projects/')->with('message', 'Error al crear la iteración');
}
}
示例14: blocking
public function blocking($id)
{
$user = User::findOrFail($id);
$user->is_banned = !$user->is_banned;
$user->save();
return Redirect::route('users.show', $id);
}
示例15: testLinkBack
public static function testLinkBack($va, $updateDB = TRUE)
{
$va = User::findOrFail($va);
$url = $va->vatsimimagepagelink;
$ch = curl_init();
$timeout = 5;
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$content = curl_exec($ch);
curl_close($ch);
$needle = 'vatsim.net';
if (stripos($content, $needle) !== FALSE) {
//The content was found update the database and return true
if ($updateDB) {
$va->linkbackstatus = 1;
$va->save();
}
return true;
} else {
//The content was not found return false and update the DB
if ($updateDB) {
$va->linkbackstatus = 0;
$va->save();
}
return false;
}
}