Example #1
1
 /**
  * 
  */
 public function Confirm()
 {
     $auth = new Auth();
     $shop = new ShoppingCart();
     $user = $auth->id();
     $myShop = $shop->all();
     $objDetails = new DetalleCompra();
     $total = 0;
     if (empty($myShop)) {
         return false;
     }
     foreach ($myShop as $key => $val) {
         $total += $val->precio * $val->cantidad;
     }
     $result_insert = $this->create($user, $total);
     if ($result_insert->success) {
         foreach ($myShop as $k => $v) {
             try {
                 $objDetails->create($result_insert->id, $v->id_prod, $v->name, $v->cantidad, $v->precio, $v->talle, $v->color);
                 //$stock = new TempStock();
                 //echo $stock->removeTempStock($user,$v->id_prod,$v->id_talle,$v->id_color,$v->type);
             } catch (Exception $e) {
                 echo $e->getMessage();
             }
         }
         $auth->restPoints($total);
         $auth->sumConsumed($total);
         $shop->removeAll();
         return true;
     }
 }
 public function viewresult()
 {
     echo "hello";
     exit;
     $user_id = \Auth::id();
     return view('user.view_result');
 }
 /**
  * Unfollow a user
  *
  * @param $userIdToUnfollow
  * @return Response
  */
 public function destroy($userIdToUnfollow)
 {
     $input = array_add(Input::all(), 'userId', Auth::id());
     $this->execute(UnfollowUserCommand::class, $input);
     Flash::success("You have now unfollowed this user.");
     return Redirect::back();
 }
Example #4
0
 public function postLogin()
 {
     if (Request::ajax()) {
         $userdata = array('usuario' => Input::get('usuario'), 'password' => Input::get('password'));
         if (Auth::attempt($userdata, Input::get('remember', 0))) {
             //buscar los permisos de este usuario y guardarlos en sesion
             $query = "SELECT m.nombre as modulo, s.nombre as submodulo,\n                        su.agregar, su.editar, su.eliminar,\n                        CONCAT(m.path,'.', s.path) as path, m.icon\n                        FROM modulos m \n                        JOIN submodulos s ON m.id=s.modulo_id\n                        JOIN submodulo_usuario su ON s.id=su.submodulo_id\n                        WHERE su.estado = 1 AND m.estado = 1 AND s.estado = 1\n                        and su.usuario_id = ?\n                        ORDER BY m.nombre, s.nombre ";
             $res = DB::select($query, array(Auth::id()));
             $menu = array();
             $accesos = array();
             foreach ($res as $data) {
                 $modulo = $data->modulo;
                 //$accesos[] = $data->path;
                 array_push($accesos, $data->path);
                 if (isset($menu[$modulo])) {
                     $menu[$modulo][] = $data;
                 } else {
                     $menu[$modulo] = array($data);
                 }
             }
             $usuario = Usuario::find(Auth::id());
             Session::set('language', 'Español');
             Session::set('language_id', 'es');
             Session::set('menu', $menu);
             Session::set('accesos', $accesos);
             Session::set('perfilId', $usuario['perfil_id']);
             Session::set("s_token", md5(uniqid(mt_rand(), true)));
             Lang::setLocale(Session::get('language_id'));
             return Response::json(array('rst' => '1', 'estado' => Auth::user()->estado));
         } else {
             $m = '<strong>Usuario</strong> y/o la <strong>contraseña</strong>';
             return Response::json(array('rst' => '2', 'msj' => 'El' . $m . 'son incorrectos.'));
         }
     }
 }
Example #5
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $user_id = Auth::id();
     $comment = Input::get('comment');
     $tags = Input::get('tagged_uid');
     $rating = Input::get('rating');
     $type = Input::get('media_type');
     $imdb_id = Input::get('imdb_id');
     $post = new Post();
     $post->user_id = $user_id;
     $post->type = $type;
     $post->imdb_id = $imdb_id;
     $post->rating = $rating;
     $post->comment = $comment;
     $post->save();
     if (sizeof($tags) > 0) {
         foreach ($tags as $tagged_uid) {
             $tag = new Tag();
             $tag->post_id = $post->id;
             $tag->user_tagging = $user_id;
             $tag->user_tagged = $tagged_uid;
             $tag->save();
         }
     }
     return Redirect::to('/media/' . $imdb_id);
 }
Example #6
0
 public function vote()
 {
     $class = \Input::get('class');
     $postId = \Input::get('postId');
     $previousVote = PostVote::where('user_id', \Auth::id())->where('post_id', $postId)->first();
     $isUpvote = str_contains($class, 'up');
     // If there is a vote by the same user on the same post
     if (!is_null($previousVote)) {
         if ($isUpvote) {
             if ($previousVote->type === 'up') {
                 // Cancel out previous upvote
                 $previousVote->delete();
             } else {
                 $previousVote->update(['type' => 'up']);
             }
         } else {
             if ($previousVote->type === 'down') {
                 // Cancel out previous downvote
                 $previousVote->delete();
             } else {
                 $previousVote->update(['type' => 'down']);
             }
         }
     } else {
         // Create a new vote
         PostVote::create(['type' => $isUpvote ? 'up' : 'down', 'user_id' => \Auth::id(), 'post_id' => $postId]);
     }
 }
 /**
  * Store a newly created resource in storage.
  * POST /article
  *
  * @return Response
  */
 public function store()
 {
     $rules = ['title' => 'required|max:100', 'content' => 'required', 'tags' => array('required', 'regex:/^\\w+$|^(\\w+,)+\\w+$/')];
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->passes()) {
         $article = Article::create(Input::only('title', 'content'));
         $article->user_id = Auth::id();
         $resolved_content = Markdown::parse(Input::get('content'));
         $article->resolved_content = $resolved_content;
         $tags = array_unique(explode(',', Input::get('tags')));
         if (str_contains($resolved_content, '<p>')) {
             $start = strpos($resolved_content, '<p>');
             $length = strpos($resolved_content, '</p>') - $start - 3;
             $article->summary = substr($resolved_content, $start + 3, $length);
         } elseif (str_contains($resolved_content, '</h')) {
             $start = strpos($resolved_content, '<h');
             $length = strpos($resolved_content, '</h') - $start - 4;
             $article->summary = substr($resolved_content, $start + 4, $length);
         }
         $article->save();
         foreach ($tags as $tagName) {
             $tag = Tag::whereName($tagName)->first();
             if (!$tag) {
                 $tag = Tag::create(array('name' => $tagName));
             }
             $tag->count++;
             $article->tags()->save($tag);
         }
         return Redirect::route('article.show', $article->id);
     } else {
         return Redirect::route('article.create')->withInput()->withErrors($validator);
     }
 }
Example #8
0
 public function isSeen()
 {
     // are there guards?
     $game = Auth::user();
     $guard = $game->map->guards()->where('health', '>', 0)->where('user_id', Auth::id())->first();
     if ($guard) {
         // if so
         $stealth = $game->stealth;
         if ($stealth == 0) {
             $stealth = 1;
         }
         $chance = 5 / $stealth * 100;
         $seen = mt_rand(1, 100);
         if ($seen < $chance) {
             $before = $game->health;
             $game->health = $game->health - 1;
             $after = $game->health;
             if ($game->stealth != 0) {
                 $game->stealth = $game->stealth - 1;
             }
             $game->save();
             return "You have been spotted and a guard attacks you. -1 Health -1 Stealth";
         } else {
             return "The guards don't see you, but you might want to hurry.";
         }
     } else {
         return false;
     }
 }
 /**
  * @return void
  */
 public function index()
 {
     if ($this->Common->isPosted()) {
         $name = $this->request->data['ContactForm']['name'];
         $email = $this->request->data['ContactForm']['email'];
         $message = $this->request->data['ContactForm']['message'];
         $subject = $this->request->data['ContactForm']['subject'];
         if (!Auth::id()) {
             $this->ContactForm->Behaviors->attach('Tools.Captcha');
         }
         $this->ContactForm->set($this->request->data);
         if ($this->ContactForm->validates()) {
             $this->_send($name, $email, $subject, $message);
         } else {
             $this->Common->flashMessage(__('formContainsErrors'), 'error');
         }
     } else {
         // prepopulate form
         $this->request->data['ContactForm'] = $this->request->query;
         # try to autofill fields
         $user = (array) $this->Session->read('Auth.User');
         if (!empty($user['email'])) {
             $this->request->data['ContactForm']['email'] = $user['email'];
         }
         if (!empty($user['username'])) {
             $this->request->data['ContactForm']['name'] = $user['username'];
         }
     }
     $this->helpers = array_merge($this->helpers, array('Tools.Captcha'));
 }
 public function UserPermissions()
 {
     if (Auth::check()) {
         $user_id = Auth::id();
         $cache_key = "user-" . $user_id . "-permissions";
         if (Cache::tags('user-permissions')->has($cache_key)) {
             $permission_array = Cache::tags('user-permissions')->get($cache_key);
         } else {
             if (Auth::user()->is_admin) {
                 $raw_permission_array = [];
                 $permission_array = [];
                 $permission_objects = Permission::all();
                 $user_permissions = DB::table('permission_user')->where('user_id', '=', $user_id)->get();
                 foreach ($user_permissions as $user_permission) {
                     $permission_id = $user_permission->permission_id;
                     $raw_permission_array[$permission_id] = 1;
                 }
                 foreach ($permission_objects as $permission) {
                     $route_name = $permission->route;
                     $permission_id = $permission->id;
                     if (isset($raw_permission_array[$permission_id])) {
                         $permission_array[$route_name] = $raw_permission_array[$permission_id];
                     } else {
                         $permission_array[$route_name] = 0;
                     }
                 }
             } else {
                 $permission_array = false;
             }
             Cache::tags('user-permissions')->put($cache_key, $permission_array, 60);
         }
     }
     return $permission_array;
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $post = new Post();
     $post->user_id = Auth::id();
     Log::info('This is useful info', Input::all());
     return $this->validateAndSave($post);
 }
Example #12
0
 /**
  * Validate inputs and save to database.
  *
  * @return Response
  */
 protected function validateAndSave($post)
 {
     $validator = Validator::make(Input::all(), Post::$rules);
     if ($validator->fails()) {
         Session::flash('errorMessage', 'Validation failed');
         return Redirect::back()->withInput()->withErrors($validator);
     } else {
         $post->title = Input::get('title');
         $post->content = Input::get('content');
         $post->user_id = Auth::id();
         $image = Input::file('image');
         if ($image) {
             $filename = $image->getClientOriginalName();
             $post->image = '/uploaded/' . $filename;
             $image->move('uploaded/', $filename);
         }
         $result = $post->save();
         $posttags = Input::has('tuttags') ? Input::get('tuttags') : array();
         if (Input::has('addtags')) {
             $addtag = Input::get('addtags');
             $posttags . push($addtag);
         }
         $post->tags()->sync($posttags);
         $post->save();
         if ($result) {
             Session::flash('successMessage', 'Great Success!');
             return Redirect::action('PostsController@show', $post->slug);
         } else {
             Session::flash('errorMessage', 'Post was not saved.');
             return Redirect::back()->withInput();
         }
     }
 }
Example #13
0
 protected function getData()
 {
     $this->userId = \Auth::id();
     $this->routeRoot = head(explode(".", app('router')->currentRouteName()));
     $this->id = \Input::get('id') == 'new' ? null : \Input::get('id');
     $this->routeEntity = implode("&", app('router')->current()->parameters());
 }
 /**
  * Upload profile picture
  */
 public function upload()
 {
     $validator = Validator::make(Input::all(), ["propic" => "required|image|mimes:jpg,jpeg,png|max:6000"], ["required" => "Please insert an image"]);
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator);
     } else {
         $user = User::find(Auth::id());
         if ($user) {
             if ($user->profile_picture) {
                 File::delete("assets/images/propic/" . $user->profile_picture);
             }
             $image = Input::file('propic');
             $name = $image->getClientOriginalName();
             /*$type 			= $image->getMimeType();
             		$size 			= $image->getSize()/1000;*/
             $destination = 'assets/images/propic/';
             $image->move($destination, $name);
             $user->profile_picture = 'assets/images/propic/' . $name;
             if ($user->save()) {
                 return Redirect::back()->with('event', '<p class="alert alert-success"><span class="glyphicon glyphicon-ok"></span> Picture uploaded</p>');
             }
             return Redirect::back()->with("event", '<p class="alert alert-danger"><span class="glyphicon glyphicon-remove"></span> Error occured. Please try after sometime</p>');
         }
     }
 }
Example #15
0
 public function __construct(IRetailerRepository $retailer)
 {
     parent::__construct();
     $this->adminId = Auth::id();
     $this->address = new Address();
     $this->retailer = $retailer;
 }
Example #16
0
 public function postQues()
 {
     if (Session::get('currentqid') != Input::get('qid')) {
         return Response::json('error', 400);
     }
     if (Session::get('currentbatchid') != Input::get('batchid')) {
         return Response::json('error', 400);
     }
     $question = Question::find(Session::get('currentqid'));
     $question->user_id = Auth::id();
     $question->batchentry_id = Input::get('batchid');
     $question->qbodytext = Input::get('qbodytext');
     $question->aoptiontext = Input::get('aoptiontext');
     $question->boptiontext = Input::get('boptiontext');
     $question->coptiontext = Input::get('coptiontext');
     $question->doptiontext = Input::get('doptiontext');
     $question->solutiontext = Input::get('solutiontext');
     $question->exam_id = Input::get('exam_id');
     $question->exam_year = Input::get('examyear');
     $question->topic_id = Input::get('topicid');
     $question->doubt = Input::get('doubt');
     $question->page_no = Input::get('pageNo');
     $question->correctans = Input::get('correctans');
     $question->complete = 1;
     $question->save();
     return Response::json(array('flash' => 'Question id', Session::get('currentqid') . 'sucessfully updated!'), 200);
 }
 /**
  * Show the form for creating a new resource.
  * GET /credentials/create
  *
  * @return Response
  */
 public function create()
 {
     $rules = array('name' => 'required', 'username' => 'required', 'password' => 'required', 'type' => 'required');
     $validator = Validator::make($data = Input::all(), $rules);
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput();
     }
     $credential = new Credential();
     $credential->user_id = Auth::id();
     $credential->project_id = Input::get('project_id');
     $credential->name = Input::get('name');
     $credential->username = Input::get('username');
     $credential->password = Input::get('password');
     if (Input::get('type') == "server") {
         $credential->type = true;
         $credential->hostname = Input::get('hostname');
         $credential->port = Input::get('port');
     } else {
         $credential->type = false;
         $credential->hostname = "";
         $credential->port = "";
     }
     $credential->save();
     return Redirect::back();
 }
Example #18
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     // create the validator
     $validator = Validator::make(Input::all(), Post::$rules);
     // attempt validation
     if ($validator->fails()) {
         // validation failed, redirect to the post create page with validation errors and old inputs
         return Redirect::back()->withInput()->withErrors($validator);
     } else {
         // validation succeeded, create and save the post
         $post = new Post();
         $post->title = Input::get('title');
         $post->description = Input::get('description');
         $post->user_id = Auth::id();
         $result = $post->save();
         if ($result) {
             Session::flash('successMessage', 'Your post successfully saved');
             return Redirect::action('posts.index');
         } else {
             Session::flash('errorMessage', 'Your post wasn\'t saved');
             Log::warning('Post failed to save: ', Input::all());
             return Redirect::back()->withInput();
         }
     }
 }
Example #19
0
 public function getComment()
 {
     $id = Auth::id();
     $postList = Post::where("author_id", $id)->get(array('_id'));
     $postIdList = array();
     foreach ($postList as $post) {
         //                echo $post->_id;
         //              echo "<br>";
         array_push($postIdList, $post->_id);
     }
     $comment_data = Comment::whereIn('post_id', $postIdList)->get();
     //echo count($comment_data);
     foreach ($comment_data as $comment) {
         $user_id = $comment['user_id'];
         $user = User::getUserById($user_id);
         $post = Post::where('_id', $comment->post_id)->first();
         $comment['title'] = $post['title'];
         $comment['username'] = $user['username'];
         $comment['email'] = $user['email'];
         $format = "F j, Y, g:i a";
         $date = new DateTime($comment['updated_at']);
         $formatDate = $date->format($format);
         $comment['update_time'] = $formatDate;
         if (isset($user['fb_img'])) {
             $comment['fb_img'] = $user['fb_img'];
         }
     }
     return View::make('backend.comment', array('comment_data' => $comment_data));
 }
Example #20
0
 /**
  * Store a newly created post in storage.
  *
  * @return Response
  */
 public function store()
 {
     $validate = Validator::make(Input::all(), Question::$rules);
     if ($validate->passes()) {
         //save a new Question
         $question = new Question();
         $question->title = Input::get('title');
         $question->body = Input::get('body');
         $question->user_id = Auth::id();
         $question->save();
         $question_id = $question->id;
         //saving Tags in Tag Table
         /*	convert input to array 	*/
         $tags_arr = explode(',', Input::get('tag'));
         /*	
         save in Tag table and return object for saving in 
         Tagmap table
         */
         foreach ($tags_arr as $tag_str) {
             $tag_obj = Tag::firstOrCreate(array('title' => $tag_str));
             //this line will attach a tag ( insert and save automatically )
             $new_question->tags()->attach($tag_obj->id);
         }
         return Redirect::action('QuestionController@index');
     }
     return Redirect::back()->withErrors($validate)->withInput();
 }
Example #21
0
 public static function boot()
 {
     parent::boot();
     // Setup event bindings...
     Balance::saving(function ($balance) {
         $balance->user_id = Auth::id();
         return $balance;
     });
     $user_id = Auth::id();
     $balance = Balance::where('user_id', $user_id)->orderBy('id', 'DESC')->first();
     if (count($balance) > 0) {
         $date = Carbon::createFromFormat('Y-m-d H:i:s', $balance->created_at);
         if ($date->isToday()) {
             // Deixa como está.
         } else {
             // Cria o pro=imeiro registro
             $todayAmount = DB::table('transactions')->where('created_at', '>', date("Y-m-d") . " 00:00:00")->where('created_at', '<=', date('Y-m-d H:i:s'))->where('user_id', Auth::id())->where('done', 1)->sum('amount');
             $newAmount = $balance->amount + $todayAmount;
             // Cria um novo pro dia de hoje
             $balance = Balance::create(['amount' => $newAmount, 'user_id' => $user_id]);
         }
     } else {
         // Cria o pro=imeiro registro
         $amount = DB::table('transactions')->where('created_at', '<=', date('Y-m-d H:i:s'))->where('user_id', Auth::id())->where('done', 1)->sum('amount');
         $balance = Balance::create(['amount' => $amount, 'user_id' => $user_id]);
     }
 }
Example #22
0
 public function login()
 {
     /*$rules = array(
     			'email'    => 'required|email',
     			'password' => 'required|alphaNum|min:3' 
     		);
     		$validator = Validator::make(
     		array(
     		 'email' => Input::get('emaillog'),
             'password' => Input::get('passwordlog')
            )
     		, $rules);
     		if ($validator->fails()) {
     			return Redirect::to('tuEmpresa')
     				->withErrors($validator) // send back all errors to the login form
     				->withInput(Input::except('password'));
     	 
          } else {*/
     // create our user data for the authentication
     $userdata = array('email' => Input::get('emaillog'), 'password' => Input::get('passwordlog'));
     // attempt to do the login
     if (Auth::attempt($userdata)) {
         Session::put('Id', Auth::id());
         return Redirect::to('enterate');
     } else {
         // validation not successful, send back to form
         return Redirect::to('tuEmpresa');
     }
     //}
 }
Example #23
0
 public function postBasic()
 {
     $response = array();
     // 获取所有表单数据
     $data = Input::all();
     $user = User::where('id', '=', Auth::id())->first();
     // 创建验证规则
     $rules = array();
     // 自定义验证消息
     $messages = array();
     // 开始验证
     $validator = Validator::make($data, $rules, $messages);
     if ($validator->passes()) {
         // 验证成功
         // 更新用户
         $user->nickname = $data['nickname'];
         $user->phone_number = $data['phone_number'];
         $user->qq = $data['qq'];
         $user->wechat = $data['wechat'];
         $user->address = $data['address'];
         $user->signature = $data['signature'];
         if ($user->save()) {
             $response['success'] = true;
             $response['message'] = '资料更新成功';
         } else {
             $response['success'] = false;
             $response['message'] = '资料更新失败';
         }
     } else {
         $response['success'] = false;
         $response['message'] = $validator->errors->first();
     }
     return Response::json($response);
 }
Example #24
0
 /**
  * Tracking Urls for Auth.User.
  * 
  * 
  */
 protected function trackingUrls()
 {
     if (!auth_check_session()) {
         return;
     }
     $this->trackingToFile('urls', array(\Auth::id(), app('url')->current(), \Route::currentRouteName()));
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $books = (array) json_decode(Input::all()['add_book_data']);
     DB::transaction(function () use($books) {
         $db_flag = false;
         $user_id = Auth::id();
         $book_title = Books::insertGetId(array('title' => $books['title'], 'author' => $books['author'], 'description' => $books['description'], 'category_id' => $books['category'], 'added_by' => $user_id));
         $newId = $book_title;
         if (!$book_title) {
             $db_flag = true;
         } else {
             $number_of_issues = $books['number'];
             for ($i = 0; $i < $number_of_issues; $i++) {
                 $issues = Issue::create(array('book_id' => $newId, 'added_by' => $user_id));
                 if (!$issues) {
                     $db_flag = true;
                 }
             }
         }
         if ($db_flag) {
             throw new Exception('Invalid update data provided');
         }
     });
     return "Books Added successfully to Database";
 }
Example #26
0
 public function update($id)
 {
     if (Auth::id() != $id) {
         return Redirect::to('http://google.com');
     }
     $user = Auth::User();
     $validator = Validator::make(Input::all(false), ['email' => 'required|email|unique:users,email,' . $id, 'password' => 'min:5|confirmed:password_confirmation', 'first_name' => 'required', 'last_name' => 'required']);
     if ($validator->passes()) {
         $img_ava = $user->avatar_img;
         $password = Input::get('password');
         if (Input::hasFile('avatar_img')) {
             if (File::exists(Config::get('user.upload_user_ava_directory') . $img_ava)) {
                 File::delete(Config::get('user.upload_user_ava_directory') . $img_ava);
             }
             if (!is_dir(Config::get('user.upload_user_ava_directory'))) {
                 File::makeDirectory(Config::get('user.upload_user_ava_directory'), 0755, true);
             }
             $img = Image::make(Input::file('avatar_img'));
             $img_ava = md5(Input::get('username')) . '.' . Input::file('avatar_img')->getClientOriginalExtension();
             if ($img->width() < $img->height()) {
                 $img->resize(100, null, function ($constraint) {
                     $constraint->aspectRatio();
                 })->crop(100, 100)->save(Config::get('user.upload_user_ava_directory') . $img_ava, 90);
             } else {
                 $img->resize(null, 100, function ($constraint) {
                     $constraint->aspectRatio();
                 })->crop(100, 100)->save(Config::get('user.upload_user_ava_directory') . $img_ava, 90);
             }
         }
         $user->update(['username' => null, 'email' => Input::get('email'), 'password' => !empty($password) ? Hash::make($password) : $user->password, 'first_name' => Input::get('first_name'), 'last_name' => Input::get('last_name')]);
         return Redirect::back()->with('success_msg', Lang::get('messages.successupdate'));
     } else {
         return Redirect::back()->withErrors($validator)->withInput();
     }
 }
 public function unsubscribe($slug)
 {
     $thread = Thread::whereSlug($slug)->firstOrFail();
     $this->authorize('laraboard::thread-unsubscribe', $thread);
     $sub = Subscription::where('post_id', $thread->id)->where('user_id', \Auth::id())->delete();
     return redirect()->back()->with('success', 'Thread subscription deleted.');
 }
Example #28
0
 /**
  * Bootstrap any application services.
  *
  * @return void
  */
 public function boot()
 {
     //
     view()->composer('layouts.master', function ($view) {
         $sidebar = array();
         $Count = DB::table('projects')->where('PJtype', 'NGS')->count();
         $sidebar = array_add($sidebar, 'NGScount', $Count);
         $Count = DB::table('projects')->where('PJtype', 'NGS')->where('status', '!=', '結案')->count();
         $sidebar = array_add($sidebar, 'NGScountNotClose', $Count);
         $Count = DB::table('projects')->where('PJtype', 'NGS')->where('status', '=', '結案')->count();
         $sidebar = array_add($sidebar, 'NGScountClose', $Count);
         $Count = DB::table('issue')->count();
         $sidebar = array_add($sidebar, 'IssueCount', $Count);
         $Count = DB::table('issue')->where('status', '=', '等待回覆')->count();
         $sidebar = array_add($sidebar, 'IssueCountWait', $Count);
         $Count = DB::table('issue')->where('status', '=', '已回覆')->count();
         $sidebar = array_add($sidebar, 'IssueCountReply', $Count);
         $Count = DB::table('issue')->where('status', '=', '已結案')->count();
         $sidebar = array_add($sidebar, 'IssueCountClosed', $Count);
         $sidebar = (object) $sidebar;
         $userQuestions = 0;
         $userSendIssue = DB::table('issue')->where('user_id', '=', \Auth::id())->where('status', '!=', '已結案')->count();
         $userQueueQuestions = DB::table('question')->where('status', '=', '等待回覆')->Where(function ($query) {
             $query->where('sendList', 'like', \Auth::id() . '|%')->orWhere('sendList', 'like', '%|' . \Auth::id() . '|%')->orWhere('sendList', 'like', '%|' . \Auth::id())->orWhere('sendList', '=', \Auth::id());
         })->count();
         $userQuestions = $userSendIssue + $userQueueQuestions;
         //dd($sidebar->NGScount);
         $view->with('sidebar', $sidebar)->with('userQuestions', $userQuestions)->with('userSendIssue', $userSendIssue)->with('userQueueQuestions', $userQueueQuestions);
     });
 }
 /**
  * Upload the file and store
  * the file path in the DB.
  */
 public function store()
 {
     // Rules
     $rules = array('name' => 'required', 'file' => 'required|max:20000');
     $messages = array('max' => 'Please make sure the file size is not larger then 20MB');
     // Create validation
     $validator = Validator::make(Input::all(), $rules, $messages);
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput();
     }
     $directory = "uploads/files/";
     // Before anything let's make sure a file was uploaded
     if (Input::hasFile('file') && Request::file('file')->isValid()) {
         $current_file = Input::file('file');
         $filename = Auth::id() . '_' . $current_file->getClientOriginalName();
         $current_file->move($directory, $filename);
         $file = new Upload();
         $file->user_id = Auth::id();
         $file->project_id = Input::get('project_id');
         $file->name = Input::get('name');
         $file->path = $directory . $filename;
         $file->save();
         return Redirect::back();
     }
     $upload = new Upload();
     $upload->user_id = Auth::id();
     $upload->project_id = Input::get('project_id');
     $upload->name = Input::get('name');
     $upload->path = $directory . $filename;
     $upload->save();
     return Redirect::back();
 }
Example #30
0
 public function getIndex(Request $request)
 {
     // Get all the books "owned" by the current logged in users
     // Sort in descending order by id
     $birds = \Birdwatcher\Bird::where('bird_id', '=', \Auth::id())->orderBy('id', 'DESC')->get();
     return view('birds.index')->with('birds', $birds);
 }