/**
  * 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'));
 }
Example #2
0
 public function usuariopuedereservartodo($id)
 {
     if (User::findOrFail($id)->isUser() || $this->tipo != Config::get('options.equipo')) {
         return false;
     }
     return true;
 }
 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.'));
 }
Example #4
0
 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;
     }
 }
 /**
  * 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]);
 }
 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);
 }
 /**
  * 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}. ");
 }
 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;
     }
 }
 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'));
     }
 }
Example #10
0
 /**
  * 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;
 }
 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']);
     }
 }
 public function testShouldUpdateUser()
 {
     $user = User::create(['username' => 'ajcastro', 'password' => 'password', 'name' => 'arjon_x', 'email' => '*****@*****.**', 'password' => '123456']);
     $updatedUser = $this->repo->update($user->id, ['name' => 'arjon']);
     $this->assertEquals('arjon', User::findOrFail($user->id)->name);
     $this->assertTrue($updatedUser instanceof User);
 }
 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');
     }
 }
Example #14
0
 public function blocking($id)
 {
     $user = User::findOrFail($id);
     $user->is_banned = !$user->is_banned;
     $user->save();
     return Redirect::route('users.show', $id);
 }
Example #15
0
 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;
     }
 }
Example #16
0
 /**
  * Execute the console command.
  *
  * @return void
  */
 public function fire()
 {
     $user = User::findOrFail($this->argument('username'));
     if ($this->confirm('Do you really want to remove user: '******'? [yes|no]')) {
         $user->removed_at = new MongoDate();
         $user->type = 'deleted';
         $user->unset(['age', 'description', 'email', 'last_login', 'last_ip', 'location', 'password', 'settings', 'sex', 'shadow_email']);
         $user->deleteAvatar();
         $user->save();
         $this->info('User deleted');
     }
     /*
     foreach (Content::where('user_id', $this->argument('username'))->get() as $obj)
                 $obj->delete();
     foreach (Entry::where('user_id', $this->argument('username'))->get() as $obj)
                 $obj->delete();
     foreach (EntryReply::where('user_id', $this->argument('username'))->get() as $obj)
                 $obj->delete();
     foreach (Comment::where('user_id', $this->argument('username'))->get() as $obj)
                 $obj->delete();
     foreach (CommentReply::where('user_id', $this->argument('username'))->get() as $obj)
                 $obj->delete();
     foreach (ContentRelated::where('user_id', $this->argument('username'))->get() as $obj)
                 $obj->delete();
     */
 }
Example #17
0
 /**
  * Execute the console command.
  *
  * @return void
  */
 public function fire()
 {
     $user = User::findOrFail($this->argument('username'));
     $user->blocked_at = new MongoDate();
     $user->save();
     $this->info('User blocked');
 }
 public function onOpen(ConnectionInterface $conn)
 {
     // Get user's stream. Any connection without user/stream will be closed.
     /* @var $request \Guzzle\Http\Message\EntityEnclosingRequest */
     $request = $conn->WebSocket->request;
     $uid = $request->getQuery()->get('uid');
     if (!$uid) {
         $this->log->debug('Connection failed: no UID');
         $conn->close();
         return;
     }
     try {
         /* @var $user \User */
         $user = User::findOrFail($uid);
         if (!$user->announcement_stream || $user->announcement_start && $user->announcement_start->isFuture()) {
             throw new Exception('No stream or start time');
         }
         $conn->WebSocket->announcementStream = $user->announcement_stream;
         $conn->WebSocket->uid = $uid;
     } catch (Exception $e) {
         $this->log->debug('Connection failed: ' . $e->getMessage());
         $conn->close();
         return;
     }
     $this->log->debug('User connected: ' . $uid);
     // Store the new connection to send messages to later
     $this->clients->attach($conn);
 }
Example #19
0
 public function handleDelete()
 {
     // Handle the delete confirmation.
     $id = Input::get('user');
     $user = User::findOrFail($id);
     $user->delete();
     return Redirect::action('AdminUserController@index')->with('flash_dlt_success', 'Oh NO!! You have deleted an user');
 }
 public function changePwd($userId)
 {
     if (!Auth::compareIds($userId, App::$instance)) {
         $this->error('403');
     }
     $user = User::findOrFail($userId);
     $this->render("users/v2/changePwd", compact('user'));
 }
 /**
  * Display the specified user.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     if (!Sentry::getUser()) {
         return Redirect::route('sessions.create');
     }
     $user = User::findOrFail($id);
     return View::make('users.show', compact('user'));
 }
 /**
  * Display the specified resource.
  * GET /users/{id}
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     $user = User::findOrFail($id);
     if (!$user) {
         App::abort(404);
     }
     return View::make('users.show')->with('user', $user);
 }
Example #23
0
 /**
  * replaceContent()
  * Returns the email content as a string with the appropriate reference variables replaced with the dynamic values
  * @param string $content
  * @param int $user
  * @return string
  */
 public static function replaceContent($content, $user)
 {
     $user = User::findOrFail($user);
     $variables = array("[name]", "[vaname]", "[cid]", "[email]", "[auditorname]");
     $values = array($user->name, $user->vaname, $user->cid, $user->email, Auth::consoleuser()->get()->name);
     $content = str_replace($variables, $values, $content);
     return $content;
 }
Example #24
0
 /**
  * // Devuelve true si User con id = $id atiende $this->recurso
  * @param $id int
  * @return $atendido boolean
  */
 public function atendidoPor($id)
 {
     $atendido = false;
     if (User::findOrFail($id)->atiende->count() > 0) {
         $atendido = true;
     }
     return $atendido;
 }
Example #25
0
 /**
  * Execute the console command.
  *
  * @return void
  */
 public function fire()
 {
     if (!$this->argument('username')) {
         print 'no username given';
     }
     $user = User::findOrFail($this->argument('username'));
     $user->deleteAvatar();
     $user->save();
 }
 private function sendActivation($user_id, $email)
 {
     $token = Tools::hash($email);
     $url = Tools::generateUrl(['activate_account', $token]);
     $user = User::findOrFail($user_id);
     $user->activate_token = $token;
     $user->save();
     Mailing::activate($email, $url);
 }
Example #27
0
 protected function userLastVisit($user_id)
 {
     $model = User::findOrFail($user_id);
     date_default_timezone_set("Asia/Dacca");
     $date = date('Y-m-d H:i:s', time());
     $model->last_visit = $date;
     $model->ip_address = getHostByName(getHostName());
     $model->save();
 }
 public function salaryEdit($code)
 {
     $str = explode(",", $code);
     $type = $str[0];
     $id = $str[1];
     $user = User::findOrFail($id);
     $comp = \CTCComponent::where('is_active', '=', 'yes')->get();
     return View::make('template.salary_edit')->with('comp', $comp)->with('type', $type)->with('user', $user);
 }
Example #29
0
 /**
  * Show the form for editing the specified kin.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     $property = Property::find($id);
     $user = User::findOrFail($property->issued_by);
     if ($property->received_by > 0) {
         $retuser = User::findOrFail($property->received_by);
     }
     return View::make('properties.edit', compact('property', 'user', 'retuser'));
 }
 /**
  * Update the specified resource in storage.
  * PUT /profile/{id}
  *
  * @param  int  $id
  * @return Response
  */
 public function postEdit()
 {
     $id = Auth::user()->id;
     $user = User::findOrFail($id);
     $user->fill(Input::all());
     $user->save();
     Flash::message('User Updated!');
     return Redirect::route('profile.edit');
 }