Ejemplo n.º 1
1
 /**
  * Show the application dashboard to the user.
  *
  * @return Response
  */
 public function index()
 {
     echo 'id:' . Auth::user()->id . '<br>';
     echo 'username:'******'<br>';
     dd(Auth::user());
     //return view('frontend.index');
 }
Ejemplo n.º 2
1
 public function slots()
 {
     $user = Auth::user();
     $location = $user->location;
     $slot = Slot::where('location', '=', $location)->first();
     $input = Input::get('wager');
     $owner = User::where('name', '=', $slot->owner)->first();
     $num1 = rand(1, 10);
     $num2 = rand(5, 7);
     $num3 = rand(5, 7);
     if ($user->name != $owner->name) {
         if ($num1 & $num2 & $num3 == 6) {
             $money = rand(250, 300);
             $payment = $money += $input * 1.75;
             $user->money += $payment;
             $user->save();
             session()->flash('flash_message', 'You rolled three sixes!!');
             return redirect('/home');
         } else {
             $user->money -= $input;
             $user->save();
             $owner->money += $input;
             $owner->save();
             session()->flash('flash_message_important', 'You failed to roll three sixes!!');
             return redirect(action('SlotsController@show', [$slot->location]));
         }
     } else {
         session()->flash('flash_message_important', 'You own this slot!!');
         return redirect(action('SlotsController@show', [$slot->location]));
     }
 }
Ejemplo n.º 3
0
 /**
  * Show the form for creating a new resource.
  *
  * @return Response
  */
 public function create($pid)
 {
     //获取当前用户的信息
     $uid = Auth::user()->id;
     //        dd(Auth::user()->toArray());
     $product = Product::getProductById($pid);
     $product = $product[0];
     $pastid = $pid . time();
     //订单随机号
     //如果订单没有生成
     if (!Past::exsitId($uid, $pid)) {
         $past = new Past();
         $past->pastid = $pastid;
         $past->uid = $uid;
         $past->pid = $pid;
         $past->pname = $product->name;
         $past->price = $product->price;
         $past->type = $product->type;
         $past->payway = $product->payway;
         $past->image = $product->images;
         $past->save();
     } else {
         $past = Past::getPastByUPid($uid, $pid);
         $past = $past[0];
         $pastid = $past->pastid;
     }
     //		dd($product);
     $this->show($pastid);
     return redirect('past/show' . "/" . $pastid);
 }
Ejemplo n.º 4
0
 public function update()
 {
     $profile = Profile::where('user_id', Auth::user()->id)->first();
     $profile->fill(Input::all());
     $profile->save();
     return Redirect::to("/edit_profile");
 }
Ejemplo n.º 5
0
 /**
  * Show the form for creating a new resource.
  *
  * @return Response
  */
 public function newComment(CommentFormRequest $request)
 {
     $user_id = Auth::user()->id;
     $comment = new Comment(array('post_id' => $request->get('post_id'), 'content' => $request->get('content'), 'user_id' => $user_id));
     $comment->save();
     return redirect()->back()->with('custom_success', 'Your comment has been created!');
 }
 /**
  * Get the validation rules that apply to the request.
  *
  * @return array
  */
 public function rules()
 {
     $validation['password'] = '******';
     $validation['current_password'] = '******';
     $user = Auth::user();
     return $validation;
 }
Ejemplo n.º 7
0
 /**
  * Handle an authentication attempt.
  *
  * @return Response
  */
 public function store()
 {
     $rules = array('email' => 'required|email', 'password' => 'required');
     $validate = Validator::make(Input::all(), $rules);
     if ($validate->fails()) {
         return Redirect::to('/');
     } else {
         if (Auth::attempt(array('email' => Input::get('email'), 'password' => Input::get('password'), 'status' => 'Activate'))) {
             /*$user = User::where('email','=',$email)->get();
               Session::put('user_type',$user[0]->role);
               $id = $user[0]->id;
               Session::put('created_by',$id);*/
             Session::put('user_id', Auth::user()->id);
             Session::put('user_name', Auth::user()->username);
             Session::put('user_role', Auth::user()->role);
             Session::flash('message', 'User has been Successfully Login.');
             $roles = Auth::user()->role;
             if ($roles = 'admin' || 'manager') {
                 return Redirect::to('dashboard');
             } elseif ($roles = 'user') {
                 return Redirect::to('profile');
             }
         } else {
             Session::flash('message', 'Your username or password incorrect');
             return Redirect::to('/');
         }
     }
 }
 public function store(PostRequest $request)
 {
     if (Input::has('link')) {
         $input['link'] = Input::get('link');
         $info = Embed::create($input['link']);
         if ($info->image == null) {
             $embed_data = ['text' => $info->description];
         } else {
             if ($info->description == null) {
                 $embed_data = ['text' => ''];
             } else {
                 $orig = pathinfo($info->image, PATHINFO_EXTENSION);
                 $qmark = str_contains($orig, '?');
                 if ($qmark == false) {
                     $extension = $orig;
                 } else {
                     $extension = substr($orig, 0, strpos($orig, '?'));
                 }
                 $newName = public_path() . '/images/' . str_random(8) . ".{$extension}";
                 if (File::exists($newName)) {
                     $imageToken = substr(sha1(mt_rand()), 0, 5);
                     $newName = public_path() . '/images/' . str_random(8) . '-' . $imageToken . ".{$extension}";
                 }
                 $image = Image::make($info->image)->fit(70, 70)->save($newName);
                 $embed_data = ['text' => $info->description, 'image' => basename($newName)];
             }
         }
         Auth::user()->posts()->create(array_merge($request->all(), $embed_data));
         return redirect('/subreddit');
     }
     Auth::user()->posts()->create($request->all());
     return redirect('/subreddit');
 }
 /**
  * Bind data to the view.
  *
  * @param  View  $view
  * @return void
  */
 public function compose(View $view)
 {
     $user = Cache::remember('user', 1440, function () {
         return Auth::user();
     });
     $view->with('user', $user);
 }
Ejemplo n.º 10
0
 public function process(UploadedFile $file)
 {
     // File extension
     $this->extension = $file->getClientOriginalExtension();
     // Mimetype for the file
     $this->mimetype = $file->getMimeType();
     // Current user or 0
     $this->user_id = Auth::user() ? Auth::user()->id : 0;
     $this->size = $file->getSize();
     list($this->path, $this->filename) = $this->upload($file);
     $this->save();
     // Check to see if image thumbnail generation is enabled
     if (static::$app['config']->get('cabinet::image_manipulation')) {
         $thumbnails = $this->generateThumbnails($this->path, $this->filename);
         $uploads = array();
         foreach ($thumbnails as $thumbnail) {
             $upload = new $this();
             $upload->filename = $thumbnail->fileSystemName;
             $upload->path = static::$app['config']->get('cabinet::upload_folder_public_path') . $this->dateFolderPath . $thumbnail->fileSystemName;
             // File extension
             $upload->extension = $thumbnail->getClientOriginalExtension();
             // Mimetype for the file
             $upload->mimetype = $thumbnail->getMimeType();
             // Current user or 0
             $upload->user_id = $this->user_id;
             $upload->size = $thumbnail->getSize();
             $upload->parent_id = $this->id;
             $upload->save();
             $uploads[] = $upload;
         }
         $this->children = $uploads;
     }
 }
Ejemplo n.º 11
0
 public static function boot()
 {
     parent::boot();
     Type::creating(function ($type) {
         $type->company_id = $type->company_id ?: Auth::user()['company_id'];
     });
 }
Ejemplo n.º 12
0
 /**
  * @return mixed
  */
 public function showNews()
 {
     $slug = Request::segment(2);
     $news_title = "Not active";
     $news_text = "Either this news item is not active, or it does not exist";
     $active = 1;
     $news_id = 0;
     $results = DB::table('news')->where('slug', '=', $slug)->get();
     foreach ($results as $result) {
         $active = $result->active;
         if ($active > 0 || Auth::check() && Auth::user()->hasRole('news')) {
             if (Session::get('lang') == null || Session::get('lang') == "en") {
                 $news_title = $result->title;
                 $news_text = $result->news_text;
                 $news_id = $result->id;
             } else {
                 $news_title = $result->title_fr;
                 $news_text = $result->news_text_fr;
                 $news_id = $result->id;
             }
             $news_image = $result->image;
             $news_date = $result->news_date;
         }
     }
     return View::make('public.news')->with('news_title', $news_title)->with('news_text', $news_text)->with('page_content', $news_text)->with('active', $active)->with('news_id', $news_id)->with('news_date', $news_date)->with('news_image', $news_image)->with('menu', $this->menu)->with('page_category_id', 0)->with('page_title', $news_title);
 }
Ejemplo n.º 13
0
 /**
  * Show the form for editing the specified user addresses.
  *
  * @param int $id
  *
  * @return \Illuminate\Http\Response
  */
 public function edit($id)
 {
     $user = Auth::user();
     $address = Address::findorfail($id);
     $countries = Country::all();
     return view('address.my-account.edit-address')->with('user', $user)->with('address', $address)->with('countries', $countries);
 }
Ejemplo n.º 14
0
 /**
  * Method ini digunakan untuk mendapatkan
  * jumlah formka5 yang di disposisikan ke user yang sedang login
  *
  * Data dari form di dapatkan dari formka5
  * dan table disposisi pada field kepada
  *
  * Jumlah id FormKA5 ini digunakan pada FormKA6 dan FormKA7
  */
 public static function countMyDisposisi($year = null)
 {
     $myUser = Auth::user();
     if ($year != null) {
         $form = Form::whereRaw('YEAR(`tanggal`) = ?', array($year))->get();
     } else {
         $form = Form::all();
     }
     $mydis = [];
     $i = 0;
     foreach ($form as $fm) {
         $dis = $fm->disposisi->first();
         if ($dis != NULL && $fm->nama == "ka5") {
             $kepada = json_decode($dis->kepada);
             foreach ($kepada as $user) {
                 if ($user->id == $myUser->id) {
                     if (strftime("%Y", strtotime($dis->form->tanggal)) == $year) {
                         $mydis[$i] = $dis->form->id;
                         $i++;
                     }
                 }
             }
         }
     }
     return $mydis;
 }
 private function composeFullname()
 {
     view()->composer('admin.app', function ($view) {
         $view->with('fullname', Auth::user()->admin->fullname);
         return;
     });
     //        view()->composer('partial.header', function ($view) {
     //            if (Auth::check()){
     //                $user = Auth::user();
     //                if ($user->role=='0'){
     //                    $view->with('role','0');
     //                    $view->with('fullname',$user->admin->fullname);
     //                    return;
     //                }
     //                if ($user->role=='1'){
     //                    $view->with('role','1');
     //                    $view->with('fullname',$user->customer->firstname);
     //                    return;
     //                }
     //
     //            }
     //        });
     //        view()->composer('admin.partial.header', function ($view) {
     //            if (Auth::check()){
     //                $user = Auth::user();
     //                if ($user->role=='0'){
     //                    $view->with('fullname',$user->admin->fullname);
     //                    return;
     //                }
     //            }
     //        });
 }
Ejemplo n.º 16
0
 public function dashboard()
 {
     $messages = Redis::lrange('messages', 0, -1);
     $messages = $messages ? $messages : [];
     $tasks = Auth::user()->tasks()->get();
     return view('dashboard', compact('messages', 'tasks'));
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $template = new Template($request->all());
     $template->user_id = Auth::user()->id;
     $template->save();
     return Redirect::route('templates.index');
 }
Ejemplo n.º 18
0
 public function searchBySalary(Request $request)
 {
     $query = intval($request->input('query'));
     $profession = Auth::user()->profession;
     switch ($profession) {
         case 'Director':
             $auditions = Audition::searchByQuery(['range' => ['pay_directors' => ['gte' => $query]]]);
             return view('search', compact('auditions'));
             break;
         case 'Producer':
             $auditions = Audition::searchByQuery(['range' => ['pay_producers' => ['gte' => $query]]]);
             return view('search', compact('auditions'));
             break;
         case 'Cameraman':
             $auditions = Audition::searchByQuery(['range' => ['pay_cameraman' => ['gte' => $query]]]);
             return view('search', compact('auditions'));
             break;
         case 'Film editor':
             $auditions = Audition::searchByQuery(['range' => ['pay_film_editors' => ['gte' => $query]]]);
             return view('search', compact('auditions'));
             break;
         case 'Sound designer':
             $auditions = Audition::searchByQuery(['range' => ['pay_sound_designers' => ['gte' => $query]]]);
             return view('search', compact('auditions'));
             break;
         case 'Actor':
             $auditions = Audition::searchByQuery(['range' => ['pay_actors' => ['gte' => $query]]]);
             return view('search', compact('auditions'));
             break;
     }
 }
Ejemplo n.º 19
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $todo = new Todo(Request::all());
     $todo->user_id = Auth::user()->id;
     $todo->save();
     return $todo;
 }
Ejemplo n.º 20
0
 public function main(Request $request)
 {
     switch ($request->data) {
         case "courses":
             $courses = Course::all();
             foreach ($courses as $course) {
                 $course["status"] = $course->seatsStatus();
                 $course["enrolled"] = $course->totalEnrolled();
                 $course["waitlist"] = $course->totalWaitlisted();
             }
             return response()->json(['courses' => $courses]);
         case "gpa":
             if ($request->has('student_id')) {
                 $student = User::find($request->get('student_id'));
                 return $student->gpa();
             } else {
                 return [];
             }
         case "classestaken":
             return Auth::user()->pastClasses();
         case "activecodes":
             $section_id = $request->get('section_id');
             return Auth::user()->returnActiveCodes($section_id);
         case "generateaddcode":
             $section_id = $request->get('section_id');
             Auth::user()->generateAddCode($section_id);
             return redirect()->action('CoursesController@addCode');
         default:
             return "no data specified";
     }
 }
Ejemplo n.º 21
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (!Auth::user() || Auth::user()->id !== 1) {
         return redirect('/');
     }
     return $next($request);
 }
Ejemplo n.º 22
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $user = Auth::user();
     $pusher = new Pusher(Config::get('services.pusher.key'), Config::get('services.pusher.secret'), Config::get('services.pusher.id'));
     $pusher->trigger('my-channel', 'my-event', array('message' => $user->name . ': ' . Input::get('msg'), 'user_id' => $user->id));
     return 'done';
 }
Ejemplo n.º 23
0
 public function postLogin(\Illuminate\Http\Request $request)
 {
     $username = $request->input('username');
     $password = $request->input('password');
     // First try to log in as a local user.
     if (Auth::attempt(array('username' => $username, 'password' => $password))) {
         $this->alert('success', 'You are now logged in.', true);
         return redirect('users/' . Auth::user()->id);
     }
     // Then try with ADLDAP.
     $ldapConfig = \Config::get('adldap');
     if (array_get($ldapConfig, 'domain_controllers', false)) {
         $adldap = new \adldap\adLDAP($ldapConfig);
         if ($adldap->authenticate($username, $password)) {
             // Check that they exist.
             $user = \Ormic\Model\User::where('username', '=', $username)->first();
             if (!$user) {
                 $user = new \Ormic\Model\User();
                 $user->username = $username;
                 $user->save();
             }
             \Auth::login($user);
             //$this->alert('success', 'You are now logged in.', TRUE);
             return redirect('');
             //->with(['You are now logged in.']);
         }
     }
     // If we're still here, authentication has failed.
     return redirect()->back()->withInput($request->only('username'))->withErrors(['Authentication failed.']);
 }
Ejemplo n.º 24
0
 /**
  * Store a newly created resource in storage.
  *
  * @param AdduserRequest $request
  * @return \Illuminate\Http\Response
  */
 public function store(AdduserRequest $request)
 {
     //        $input = $request->all();                               // get all data
     //        $input['confirmed'] = 1;                                // set confirmed to 1
     //        $input['password'] = Hash::make($input['password']);    // hash password
     //
     //        $user       =   User::create($input);                   // save above details
     $user = User::create(['first_name' => $request->first_name, 'last_name' => $request->last_name, 'email' => $request->email, 'confirmed' => 1, 'password' => Hash::make($request->password)]);
     //        $profile    =   $user->profile()->save(new Profile);    // also create new profile
     //        $profile->apartment_id  =   Auth::user()->profile->defaultApartment; // get current defaultApartment
     //        $profile->save();                                       // save details on profile
     $profile = Profile::create(['user_id' => $user->id, 'apartment_id' => Auth::user()->profile->defaultApartment]);
     dd(Auth::user()->profile->defaultApartment);
     $role = Role::whereName('user')->first();
     $user->assignRole($role);
     //Assign Role
     $block_no = $request->blockno;
     // get block_no from profileform
     $floor_no = $request->floorno;
     // get floor_no from profileform
     $profile->apartments()->attach($profile->defaultApartment, ['approved' => '1', 'block_no' => $block_no, 'floor_no' => $floor_no]);
     // attach this profile with default apartment, with approved = 1, and block_no, floor_no according to profileform in apartment_profile pivot table.
     Crm_account::create(['account' => $user->first_name . $user->last_name, 'fname' => $user->first_name, 'lname' => $user->last_name, 'company' => 'Company Name', 'email' => $user->email, 'address' => 'Current Address', 'city' => 'Nagpur', 'state' => 'Maharashtra', 'zip' => '440012', 'country' => 'India']);
     return redirect()->back()->withMessage('User has been Added')->withStatus('success');
 }
Ejemplo n.º 25
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (!Auth::check() || !Auth::user()->admPower) {
         return redirect()->route('paginaInicial');
     }
     return $next($request);
 }
Ejemplo n.º 26
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (Auth::user()) {
         Cache::forever('last_seen_' . Auth::user()->id, date('Y-m-d H:i:s'));
     }
     return $next($request);
 }
Ejemplo n.º 27
0
 public static function boot()
 {
     parent::boot();
     static::creating(function ($model) {
         $model->effectivefrom = date('Y-m-d', strtotime($model->effectivefrom));
         $model->effectiveto = date('Y-m-d', strtotime($model->effectiveto));
         $model->createdby = Auth::user()->id;
         $model->createddate = date("Y-m-d H:i:s");
         $model->modifiedby = Auth::user()->id;
         $model->modifieddate = date("Y-m-d H:i:s");
     });
     static::created(function ($model) {
         Log::create(['employeeid' => Auth::user()->id, 'operation' => 'Add', 'date' => date("Y-m-d H:i:s"), 'model' => class_basename(get_class($model)), 'detail' => $model->toJson()]);
     });
     static::updating(function ($model) {
         $model->effectivefrom = date('Y-m-d', strtotime($model->effectivefrom));
         $model->effectiveto = date('Y-m-d', strtotime($model->effectiveto));
         $model->modifiedby = Auth::user()->id;
         $model->modifieddate = date("Y-m-d H:i:s");
     });
     static::updated(function ($model) {
         Log::create(['employeeid' => Auth::user()->id, 'operation' => 'Update', 'date' => date("Y-m-d H:i:s"), 'model' => class_basename(get_class($model)), 'detail' => $model->toJson()]);
     });
     static::deleted(function ($model) {
         Log::create(['employeeid' => Auth::user()->id, 'operation' => 'Delete', 'date' => date("Y-m-d H:i:s"), 'model' => class_basename(get_class($model)), 'detail' => $model->toJson()]);
     });
 }
Ejemplo n.º 28
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @param  string|null  $guard
  * @return mixed
  */
 public function handle($request, Closure $next, $guard = null)
 {
     if (Auth::user()->id == 1) {
         return $next($request);
     }
     return redirect()->guest('login')->withErrors(trans('auth.admin'));
 }
Ejemplo n.º 29
0
 public function store(Requests\ArticleRequest $request)
 {
     // Validation:
     $article = new Article($request->all());
     Auth::user()->articles()->save($article);
     return redirect('articles');
 }
Ejemplo n.º 30
0
 public function vacations($vacation)
 {
     if ($vacation == 'winter') {
         $programs = Program::where('programs.active', '=', '1')->join('vacations', 'programs.id', '=', 'vacations.program_id')->where('vacations.season', '=', 'Зима')->orderBy('programs.id', 'desc')->select('programs.*', 'vacations.start_date as start_date', 'vacations.finish_date as finish_date')->get();
     } elseif ($vacation == 'spring') {
         $programs = Program::where('programs.active', '=', '1')->join('vacations', 'programs.id', '=', 'vacations.program_id')->where('vacations.season', '=', 'Весна')->orderBy('programs.id', 'desc')->select('programs.*', 'vacations.start_date as start_date', 'vacations.finish_date as finish_date')->get();
     } elseif ($vacation == 'summer') {
         $programs = Program::where('programs.active', '=', '1')->join('vacations', 'programs.id', '=', 'vacations.program_id')->where('vacations.season', '=', 'Лето')->orderBy('programs.id', 'desc')->select('programs.*', 'vacations.start_date as start_date', 'vacations.finish_date as finish_date')->get();
     } elseif ($vacation == 'autumn') {
         $programs = Program::where('programs.active', '=', '1')->join('vacations', 'programs.id', '=', 'vacations.program_id')->where('vacations.season', '=', 'Осень')->orderBy('programs.id', 'desc')->select('programs.id as id', 'vacations.start_date as start_date', 'vacations.finish_date as finish_date')->get();
     } elseif ($vacation == 'weekend') {
         $programs = Program::where('programs.active', '=', '1')->join('vacations', 'programs.id', '=', 'vacations.program_id')->where('vacations.season', '=', 'Выходной')->orderBy('programs.id', 'desc')->select('programs.*', 'vacations.start_date as start_date', 'vacations.finish_date as finish_date')->get();
     } elseif ($vacation == 'festival') {
         $programs = Program::where('programs.active', '=', '1')->join('vacations', 'programs.id', '=', 'vacations.program_id')->where('vacations.season', '=', 'Фестиваль')->orderBy('programs.id', 'desc')->select('programs.*', 'vacations.start_date as start_date', 'vacations.finish_date as finish_date')->get();
     } else {
         $programs = Program::where('programs.active', '=', '1')->join('vacations', 'programs.id', '=', 'vacations.program_id')->orderBy('programs.id', 'desc')->select('programs.*', 'vacations.start_date as start_date', 'vacations.finish_date as finish_date')->get();
     }
     $all_news = News::where('active', '=', '1')->get();
     $monthes = array(1 => 'Января', 2 => 'Февраля', 3 => 'Марта', 4 => 'Апреля', 5 => 'Мая', 6 => 'Июня', 7 => 'Июля', 8 => 'Августа', 9 => 'Сентября', 10 => 'Октября', 11 => 'Ноября', 12 => 'Декабря');
     if (Auth::check()) {
         $user = Auth::user()->name;
     } else {
         $user = '******';
     }
     return view('index', ['programs' => $programs, 'monthes' => $monthes, 'all_news' => $all_news, 'user' => $user]);
 }