public function getLoggedinDashboard()
 {
     $role = Auth::user()->role;
     if ($role == 'hotel-staff') {
         $branch_code = $this->getStaffBranch();
         $data_room_booked_details = DB::table('hotel_rooms')->join('branch', 'hotel_rooms.branch_code', '=', 'branch.branch_code')->where('branch.branch_code', '=', $branch_code)->where('hotel_rooms.status', '=', 'booked')->count();
         $data_room_details = DB::table('hotel_rooms')->join('branch', 'hotel_rooms.branch_code', '=', 'branch.branch_code')->where('branch.branch_code', '=', $branch_code)->where('hotel_rooms.status', '=', 'available')->count();
         $data_total_sales = DB::table('sales')->where('branch_code', '=', $branch_code)->sum('sale_value');
         $total_client = DB::table('customer')->join('accommodation', 'customer.customer_id', '=', 'accommodation.customer_id')->select('customer.customer_id', 'accommodation.branch_code')->where('accommodation.branch_code', '=', $branch_code)->count();
         $data_room = DB::table('hotel_rooms')->join('branch', 'hotel_rooms.branch_code', '=', 'branch.branch_code')->select('hotel_rooms.room_code', 'hotel_rooms.branch_code', 'hotel_rooms.price_per_night', 'hotel_rooms.description', 'hotel_rooms.status', 'hotel_rooms.image', 'branch.branch_name', 'branch.address', 'branch.email', 'branch.city')->where('branch.branch_code', '=', $branch_code)->where('hotel_rooms.status', '=', 'available')->take(5)->get();
         $data_room_booked = DB::table('accommodation')->join('customer', 'accommodation.customer_id', '=', 'customer.customer_id')->select('customer.fullname', 'accommodation.branch_code', 'accommodation.room_code', 'accommodation.checkin_time', 'accommodation.checkout_time')->where('accommodation.branch_code', '=', $branch_code)->orderBy('checkout_time')->take(5)->get();
         $cancelled = DB::table('refund')->where('date', '=', date('y-m-d'))->where('branch_id', '=', $branch_code)->count('refund_id');
     } else {
         DB::setFetchMode(PDO::FETCH_ASSOC);
         $company_id_logged_user = Auth::user()->comp_id;
         $data_room_details = DB::table('hotel_rooms')->join('branch', 'hotel_rooms.branch_code', '=', 'branch.branch_code')->where('branch.company_id', '=', $company_id_logged_user)->where('hotel_rooms.status', '=', 'available')->count();
         $data_room_booked_details = DB::table('hotel_rooms')->join('branch', 'hotel_rooms.branch_code', '=', 'branch.branch_code')->where('branch.company_id', '=', $company_id_logged_user)->where('hotel_rooms.status', '=', 'booked')->count();
         $data_total_sales = DB::table('sales')->where('company_id', '=', Auth::user()->comp_id)->sum('sale_value');
         $total_client = DB::table('customer')->select('customer_id')->where('company_id', '=', Auth::user()->comp_id)->count();
         $company_id_logged_user = Auth::user()->comp_id;
         $data_room = DB::table('hotel_rooms')->join('branch', 'hotel_rooms.branch_code', '=', 'branch.branch_code')->select('hotel_rooms.room_code', 'hotel_rooms.branch_code', 'hotel_rooms.price_per_night', 'hotel_rooms.description', 'hotel_rooms.status', 'hotel_rooms.image', 'branch.branch_name', 'branch.address', 'branch.email', 'branch.city')->where('branch.company_id', '=', $company_id_logged_user)->where('hotel_rooms.status', '=', 'available')->take(5)->get();
         $data_room_booked = DB::table('accommodation')->join('customer', 'accommodation.customer_id', '=', 'customer.customer_id')->select('customer.fullname', 'accommodation.branch_code', 'accommodation.room_code', 'accommodation.checkin_time', 'accommodation.checkout_time')->where('accommodation.comp_id', '=', Auth::user()->comp_id)->orderBy('checkout_time')->take(5)->get();
         $cancelled = DB::table('refund')->join('branch', 'refund.branch_id', '=', 'branch.branch_code')->where('branch.company_id', '=', Auth::user()->comp_id)->count('refund_id');
     }
     return View::make('dashboard', array('data' => $data_room_details, 'booked' => $data_room_booked_details, 'sales' => $data_total_sales, 'clients' => $total_client, 'room_details' => $data_room, 'room_booked' => $data_room_booked, 'cancelled' => $cancelled));
 }
Example #2
1
 /**
  *  get_show takes in a username, finds the user's id from the username, gets the information about the user from the 
  *	followers and critts table and outputs it into the others.profile view
  */
 public function action_show($username)
 {
     // we get the user's id that matches the username
     $user_id = User::where('username', '=', $username)->only('id');
     // declare some default values for variables
     $following = null;
     $followers = 0;
     // if the username is not found, display an error
     if ($user_id == null) {
         echo "This username does not exist.";
     } else {
         if (Auth::user()) {
             // if the user tries to go to his/her own profile, redirect to user's profile action.
             if ($user_id == Auth::user()->id) {
                 return Redirect::to_action('user@index');
             }
             // check if the current user is already following $username
             $following = Follower::where('user_id', '=', Auth::user()->id)->where('following_id', '=', $user_id)->get() ? true : false;
         }
         // eager load the critts with user data
         $allcritts = Critt::with('user')->where('user_id', '=', $user_id);
         // order the critts and split them in chunks of 10 per page
         $critts = $allcritts->order_by('created_at', 'desc')->paginate(10);
         // count the critts
         $critts_count = $allcritts->count();
         // count the followers
         $followers = Follower::where('following_id', '=', $user_id)->count();
         // bind data to the view
         return View::make('others.profile')->with('username', $username)->with('user_id', $user_id)->with('following', $following)->with('followers', $followers)->with('count', $critts_count)->with('critts', $critts);
     }
 }
Example #3
0
 public function find($filter = null)
 {
     $query = \DB::table('clients')->join('contacts', 'contacts.client_id', '=', 'clients.id')->where('clients.account_id', '=', \Auth::user()->account_id)->where('contacts.is_primary', '=', true)->where('contacts.deleted_at', '=', null)->select('clients.public_id', 'clients.nit', 'clients.business_name', 'clients.name', 'contacts.first_name', 'contacts.last_name', 'contacts.phone', 'clients.balance', 'clients.paid_to_date', 'clients.work_phone', 'contacts.email', 'custom_value1', 'clients.deleted_at');
     if (!\Session::get('show_trash:client')) {
         $query->where('clients.deleted_at', '=', null);
     }
     if ($filter) {
         $cod1 = substr($filter, 0, 3);
         $cod2 = 'cod';
         $cod3 = 'COD';
         $cod4 = 'Cod';
         $cod5 = substr($filter, 0, 3);
         $cod6 = 'Ind';
         $cod7 = 'ind';
         $cod7 = 'IND';
         if (strcmp($cod5, $cod6) == 0 or strcmp($cod5, $cod7) == 0) {
             $filter = substr($filter, 3);
             $query->where(function ($query) use($filter) {
                 $query->where('clients.custom_value1', 'like', $filter . '%');
             });
         } else {
             if (strcmp($cod1, $cod2) == 0 or strcmp($cod1, $cod3) == 0 or strcmp($cod1, $cod4) == 0) {
                 $filter = substr($filter, 3);
                 $query->where(function ($query) use($filter) {
                     $query->where('clients.public_id', 'like', $filter . '%');
                 });
             } else {
                 $query->where(function ($query) use($filter) {
                     $query->where('clients.name', 'like', '%' . $filter . '%')->orWhere('clients.business_name', 'like', '%' . $filter . '%')->orWhere('clients.nit', 'like', $filter . '%')->orWhere('contacts.first_name', 'like', '%' . $filter . '%')->orWhere('contacts.last_name', 'like', '%' . $filter . '%')->orWhere('contacts.email', 'like', $filter . '%');
                 });
             }
         }
     }
     return $query;
 }
Example #4
0
 /**
  * Send the response after the user was authenticated.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 protected function handleUserWasAuthenticated(Request $request)
 {
     if (method_exists($this, 'authenticated')) {
         return $this->authenticated($request, Auth::user());
     }
     return redirect()->intended($this->redirectPath());
 }
 public function getDelMember($id)
 {
     $staff = User::find($id);
     if (\Auth::user()->role_id == 1) {
         return view('html.error-403');
     }
     if ($staff->role_id == 4) {
         return view('html.error-403');
     }
     $teams = Team::where('created_user_id', $staff->id)->get();
     if (!empty($team)) {
         foreach ($teams as $key => $value) {
             TeamDetail::where('team_id', $value->id)->delete();
         }
         foreach ($teams as $key => $value) {
             $value->delete();
         }
     }
     $detail = TeamDetail::where('staff_id', $staff->id)->get();
     if (!empty($detail)) {
         foreach ($detail as $key => $value) {
             $value->delete();
         }
     }
     Profile::where('user_id', $staff->id)->first()->delete();
     $staff->delete();
     return redirect()->route('admin.index')->with('success', 'Deleted Successfully!!!');
 }
Example #6
0
 public function setUserEntityTheme($file, $dataarr)
 {
     $getpersonalcount = DB::table('tbl_bankaccounts')->leftjoin('tbl_bankbranches', 'bankaccount_branch', '=', 'branch_id')->leftjoin('tbl_banks', 'branch_bankid', '=', 'bank_id')->where('bank_isproduct', '0')->where('bankaccount_userentity', 'Personal')->where('bankaccount_createdby', Auth::user()->id)->count();
     $getbusinesscount = DB::table('tbl_bankaccounts')->leftjoin('tbl_bankbranches', 'bankaccount_branch', '=', 'branch_id')->leftjoin('tbl_banks', 'branch_bankid', '=', 'bank_id')->where('bank_isproduct', '0')->where('bankaccount_userentity', 'Business')->where('bankaccount_createdby', Auth::user()->id)->count();
     $resultbViewAcctype = DB::table('tbl_bankaccounttypes')->get();
     $resultbViewAcctypearr = array();
     foreach ($resultbViewAcctype as $data) {
         $resultbViewAcctypearr[$data->accounttype_id] = $data->accounttype_name;
     }
     $resultbViewBanks = DB::table('tbl_banks')->where('bank_isproduct', 0)->where('bank_status', '1')->orderBy('bank_name', 'ASC')->get();
     $resultbViewBanksarr = array();
     foreach ($resultbViewBanks as $data) {
         $resultbViewBanksarr[$data->bank_id] = $data->bank_name;
     }
     $resultbViewBankbranchs = DB::table('tbl_bankbranches')->where("branch_bankid", key($resultbViewBanksarr))->where("branch_status", "1")->get();
     $resultbViewBankBrancharr = array();
     foreach ($resultbViewBankbranchs as $data) {
         $resultbViewBankBrancharr[$data->branch_id] = $data->branch_name;
     }
     if ($getpersonalcount <= 0 and $getbusinesscount <= 0) {
         $data = array('bankaccttype' => $resultbViewAcctypearr, 'bankname' => $resultbViewBanksarr, 'bankbranch' => $resultbViewBankBrancharr);
         $MyTheme = Theme::uses('fonebayad')->layout('ezibills_9_0');
         return $MyTheme->of('registration.firstloginaddbankacct', $data)->render();
     } else {
         //            $MyTheme = Theme::uses('fonebayad')->layout('ezibills_9_0');
         $MyTheme = Theme::uses('fonebayad')->layout('newDefault_myBills');
         return $MyTheme->of($file, $dataarr)->render();
     }
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function postCreate()
 {
     // Declare the rules for the form validation
     $rules = array('title' => 'required|min:3', 'content' => 'required|min:3');
     // Validate the inputs
     $validator = Validator::make(Input::all(), $rules);
     // Check if the form validates with success
     if ($validator->passes()) {
         // Create a new blog post
         $user = Auth::user();
         // Update the blog post data
         $this->post->title = Input::get('title');
         $this->post->slug = Str::slug(Input::get('title'));
         $this->post->content = Input::get('content');
         $this->post->meta_title = Input::get('meta-title');
         $this->post->meta_description = Input::get('meta-description');
         $this->post->meta_keywords = Input::get('meta-keywords');
         $this->post->user_id = $user->id;
         // Was the blog post created?
         if ($this->post->save()) {
             // Redirect to the new blog post page
             return Redirect::to('admin/blogs/' . $this->post->id . '/edit')->with('success', Lang::get('admin/blogs/messages.create.success'));
         }
         // Redirect to the blog post create page
         return Redirect::to('admin/blogs/create')->with('error', Lang::get('admin/blogs/messages.create.error'));
     }
     // Form validation failed
     return Redirect::to('admin/blogs/create')->withInput()->withErrors($validator);
 }
 /**
  * Saves user submissions for Independent Sponsor requests.
  */
 public function postRequest()
 {
     //Grab input
     $address1 = Input::get('address1');
     $address2 = Input::get('address2');
     $city = Input::get('city');
     $state = Input::get('state');
     $postal = Input::get('postal');
     $phone = Input::get('phone');
     $all_input = Input::all();
     //Validate input
     $rules = array('address1' => 'required', 'city' => 'required', 'state' => 'required', 'postal' => 'required', 'phone' => 'required');
     $validation = Validator::make($all_input, $rules);
     if ($validation->fails()) {
         return Redirect::to('/documents/sponsor/request')->withInput()->withErrors($validation);
     }
     //Add new user information to their record
     $user = Auth::user();
     $user->address1 = $address1;
     $user->address2 = $address2;
     $user->city = $city;
     $user->state = $state;
     $user->postal_code = $postal;
     $user->phone = $phone;
     $user->save();
     //Add UserMeta request
     $request = new UserMeta();
     $request->meta_key = UserMeta::TYPE_INDEPENDENT_SPONSOR;
     $request->meta_value = 0;
     $request->user_id = $user->id;
     $request->save();
     return Redirect::to('/user/edit/' . $user->id)->with('message', 'Your request has been received.');
 }
Example #9
0
 public function create($type = 'csv')
 {
     try {
         $export = static::getExportForType($type);
     } catch (Exception $e) {
         App::abort(404);
     }
     $export->user_id = Auth::user()->id;
     $export->filename = $export->generateFilename();
     $export->path = $export->folderPath();
     $export->setLogbooks(Input::get('logbooks'));
     $save = Input::has('save') ? (bool) Input::get('save') : true;
     if ($export->run($save)) {
         if ($save == false) {
             $res = Response::make($export->content);
             $res->header('Content-type', $export->getContentType());
             return $res;
         } else {
             $export->save();
             return Response::download($export->fullPath(), $export->filename, ['Content-type' => $export->getContentType()]);
         }
     } else {
         return Redirect::to(action('ExportsController@index'))->with('message', ['content' => 'Er is iets mis gegaan met exporteren.', 'class' => 'danger']);
     }
 }
 public function remove($id)
 {
     $fav = Favorite::where('StudentID', Auth::user()->StudentID)->where('FavoriteID', $id)->where('favorite', '1')->first();
     $fav->favorite = 0;
     $fav->updated_at = date_timestamp_get(date_create());
     $fav->save();
 }
Example #11
0
 /**
  * @param String|null $code
  * @param User|null $user
  * @return mixed
  */
 public function getAccessToken($code = null, $user = null)
 {
     if ($code) {
         // swap code for access token plus refresh token
         $guzzle = new Client();
         $options = ['headers' => ['User-Agent' => 'Reset app by Ortho Loess, hosted at ' . config('app.url'), 'Authorization' => $this->makeBasicAuthHeader()], 'form_params' => ['grant_type' => 'authorization_code', 'code' => $code]];
         $response = $guzzle->post(config('crest.sso-token-uri'), $options);
         $jsonResponse = json_decode($response->getBody(), true);
         //$this->accessToken = $jsonResponse['access_token'];
         $this->refreshToken = $jsonResponse['refresh_token'];
         return $jsonResponse['access_token'];
     } else {
         // use refresh token to get new access token.
         if (!$user) {
             $user = \Auth::user();
         }
         $token = \Cache::remember('accessToken:' . $user->id, 15, function () use($user) {
             $guzzle = new Client();
             $options = ['headers' => ['User-Agent' => 'Reset app by Ortho Loess, hosted at ' . config('app.url'), 'Authorization' => $this->makeBasicAuthHeader()], 'form_params' => ['grant_type' => 'refresh_token', 'refresh_token' => $user->refreshToken]];
             $response = $guzzle->post(config('crest.sso-token-uri'), $options);
             $jsonResponse = json_decode($response->getBody(), true);
             return $jsonResponse['access_token'];
         });
         return $token;
     }
     // cache access token
 }
Example #12
0
 public function postVote()
 {
     Input::merge(array_map('trim', Input::all()));
     $input = Input::all();
     $rules = array('MCUsername' => 'required|max:40', 'g-recaptcha-response' => 'required|recaptcha', 'sid' => 'required');
     $v = Validator::make($input, $rules);
     $sid = $input['sid'];
     $server = DB::table('mcservers')->where('mcs_id', '=', $sid)->first();
     if (!count($server)) {
         return Redirect::to('/minecraft/' . $sid)->withErrors("Ocorreu um erro com a validação do servidor");
     }
     if ($v->passes()) {
         if (mcservers::playerHasVoted($sid, $input['MCUsername']) || mcservers::ipHasVoted($sid, $_SERVER["HTTP_CF_CONNECTING_IP"])) {
             return Redirect::to('/minecraft/' . $sid)->withErrors("Já votaste hoje");
         }
         if ($server->mcs_votifier == 1) {
             $votifier = Votifier::newVote($server->mcs_ip, $server->mcs_vport, $server->mcs_votifierkey, $input['MCUsername']);
             if ($votifier == false) {
                 return Redirect::to('/minecraft/' . $sid)->withErrors("Não foi possivel enviar o voto para o servidor, porfavor contacta o admininstrador do mesmo");
             }
         }
         if (Auth::check()) {
             DB::table('users')->where('id', Auth::user()->id)->update(array('votes' => Auth::user()->votes + 1));
             utilities::log("Voted On Server " . $server->mcs_name);
         }
         DB::table('mcservers')->where('mcs_id', $sid)->update(array('mcs_tvotes' => $server->mcs_tvotes + 1, 'mcs_mvotes' => $server->mcs_mvotes + 1));
         DB::table('mcserversvotes')->insert(array('mcsv_sid' => $sid, 'mcsv_player' => $input['MCUsername'], 'mcsv_ip' => $_SERVER["HTTP_CF_CONNECTING_IP"], 'mcsv_day' => date("j"), 'mcsv_month' => date("n"), 'mcsv_year' => date("Y")));
         return Redirect::to('/minecraft/' . $sid)->With('success', 'Voto Registado!');
     } else {
         return Redirect::to('/minecraft/' . $sid)->withErrors($v);
     }
 }
Example #13
0
 public static function is($level)
 {
     if (!is_numeric($level)) {
         $level = self::level($level);
     }
     return Auth::user()->level == $level;
 }
 public function updateProfile()
 {
     $name = Input::get('name');
     //$username = Input::get('username');
     $birthday = Input::get('birthday');
     $bio = Input::get('bio', '');
     $gender = Input::get('gender');
     $mobile_no = Input::get('mobile_no');
     $country = Input::get('country');
     $old_avatar = Input::get('old_avatar');
     /*if(\Cashout\Models\User::where('username',$username)->where('id','!=',Auth::user()->id)->count()>0){
           Session::flash('error_msg', 'Username is already taken by other user . Please enter a new username');
           return Redirect::back()->withInput(Input::all(Input::except(['_token'])));
       }*/
     try {
         $profile = \Cashout\Models\User::findOrFail(Auth::user()->id);
         $profile->name = $name;
         // $profile->username = $username;
         $profile->birthday = $birthday;
         $profile->bio = $bio;
         $profile->gender = $gender;
         $profile->mobile_no = $mobile_no;
         $profile->country = $country;
         $profile->avatar = Input::hasFile('avatar') ? \Cashout\Helpers\Utils::imageUpload(Input::file('avatar'), 'profile') : $old_avatar;
         $profile->save();
         Session::flash('success_msg', 'Profile updated successfully');
         return Redirect::back();
     } catch (\Exception $e) {
         Session::flash('error_msg', 'Unable to update profile');
         return Redirect::back()->withInput(Input::all(Input::except(['_token', 'avatar'])));
     }
 }
Example #15
0
 public function userBanned()
 {
     if (Auth::check() && !Auth::user()->is_banned) {
         return Redirect::route('home');
     }
     return View::make('auth.userbanned');
 }
Example #16
0
 public function postSave($id = null)
 {
     $validator = Validator::make(Input::all(), Appointment::$rules);
     if ($validator->passes()) {
         $event = Appointment::find(Input::get('id'));
         if (!$event) {
             $event = new Appointment();
         }
         $calendar = Calendar::find(explode('/', Input::get('date'))[0]);
         if ($calendar) {
             $day = explode('/', Input::get('date'))[1];
             if ($day > 0 && $day <= $calendar->number_of_days) {
                 $event->name = Input::get('name');
                 $event->date = explode('/', Input::get('date'))[1];
                 $event->start_time = Input::get('start_time');
                 $event->end_time = Input::get('end_time');
                 $event->notes = Input::get('notes');
                 $event->calendar_id = $calendar->id;
                 $event->group_id = Input::get('group_id');
                 $event->user_id = Auth::user()->id;
                 $event->save();
                 return Response::json(array('status' => 'success', $event));
             } else {
                 $validator->messages()->add('date', 'The day is invalid.');
             }
         } else {
             $validator->messages()->add('date', 'The month is invalid.');
         }
     }
     return Response::json(array('status' => 'error', 'errors' => $validator->messages()));
 }
Example #17
0
 /**
  * Saves user submissions for Independent Sponsor requests.
  */
 public function putRequest()
 {
     //Validate input
     $rules = array('address1' => 'required', 'city' => 'required', 'state' => 'required', 'postal_code' => 'required', 'phone' => 'required');
     $validation = Validator::make(Input::all(), $rules);
     if ($validation->fails()) {
         return Response::json($this->growlMessage($validation->messages()->all(), 'error'), 400);
     }
     //Add new user information to their record
     $user = Auth::user();
     $user->address1 = Input::get('address1');
     $user->address2 = Input::get('address2');
     $user->city = Input::get('city');
     $user->state = Input::get('state');
     $user->postal_code = Input::get('postal_code');
     $user->phone = Input::get('phone');
     $user->save();
     if (!$user->getSponsorStatus()) {
         //Add UserMeta request
         $request = new UserMeta();
         $request->meta_key = UserMeta::TYPE_INDEPENDENT_SPONSOR;
         $request->meta_value = 0;
         $request->user_id = $user->id;
         $request->save();
     }
     return Response::json();
 }
Example #18
0
 public function canBuySongs()
 {
     if (!Auth::user()) {
         return false;
     }
     return $this->checkPermission(Auth::user()->function, 'buy_songs') || Auth::user()->username == "Admin";
 }
Example #19
0
 public function selectCampus($id)
 {
     $campusid = $id;
     $ipadress = $this->getIPAdress();
     /*store the institutions id alongside the specific ip adress in the devices table
      * and redirect user to the specific homepage
      */
     $exists = Device::where('ip', '=', $ipadress);
     if ($exists->count()) {
         $device = $exists->first();
         $device->branch_id = $campusid;
         if ($device->save()) {
             if (Auth::user()) {
                 return Redirect::route('member-home');
             } else {
                 return Redirect::route('home');
             }
         }
     } else {
         $devicecreate = Device::create(array('ip' => $ipadress, 'branch_id' => $campusid));
         if ($devicecreate) {
             if (Auth::user()) {
                 return Redirect::route('member-home');
             } else {
                 return Redirect::route('home');
             }
         }
     }
     return Redirect::route('selectcampus-get')->withInput()->with('global', 'Sorry!! Campus details were not loaded, please retry.');
 }
Example #20
0
 public function store(Project $project)
 {
     $sprint = new Sprint(array_merge(array_map('trim', Input::all()), ['project_id' => $project->id]));
     $actionHandler = Phragile::getGlobalInstance()->newSprintStoreActionHandler();
     $actionHandler->performAction($sprint, Auth::user());
     return $actionHandler->getRedirect();
 }
Example #21
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $input = Input::all();
     if ($this->post->fill($input)->validate_post()) {
         $image = Input::file('attachment');
         if ($image->isValid()) {
             $path = 'uploads/posts/' . Auth::user()->username;
             $filename = 'posts-' . time() . rand(1000, 9999) . '.' . $image->getClientOriginalExtension();
             if ($image->move($path, $filename)) {
                 $data = $this->post->create(['user_id' => Auth::user()->id, 'title' => $input['title'], 'content' => $input['content'], 'attachment' => $filename]);
                 if ($data->id) {
                     $post = $this->post->find($data->id);
                     $post->tags()->attach($input['tags']);
                     Session::flash('type', 'success');
                     Session::flash('message', 'Post Created');
                     return Redirect::route('post.index');
                 } else {
                     Session::flash('type', 'error');
                     Session::flash('message', 'Error!!! Cannot create post');
                     return Redirect::back()->withInput();
                 }
             } else {
                 Session::flash('type', 'error');
                 Session::flash('message', 'Error!!! File cannot be uploaded');
                 return Redirect::back()->withInput();
             }
         } else {
             Session::flash('type', 'error');
             Session::flash('message', 'Error!!! File is not valid');
             return Redirect::back()->withInput();
         }
     } else {
         return Redirect::back()->withInput()->withErrors($this->post->errors);
     }
 }
Example #22
0
 private function givePointsToBadge($points, $badge)
 {
     if (Badge::byName($badge) && Auth::user()->hasBadge($badge)) {
         Auth::user()->badge->where('name', $badge)->points += $points;
         return Auth::user()->badge->save();
     }
 }
 /**
  * Show the application dashboard to the user.
  *
  * @return Response
  */
 public function index()
 {
     if (\Auth::user()->status != 1) {
         \Session::flash('message', 'You are Blocked by Admin');
     }
     return view('home');
 }
Example #24
0
 /**
  * Setup the layout used by the controller.
  *
  * @return void
  */
 protected function setupLayout()
 {
     if (!is_null($this->layout)) {
         $this->layout = View::make($this->layout);
     }
     View::share('currentUser', Auth::user());
 }
Example #25
0
 public function updateBudgetPrediction($event)
 {
     $event->name = Crypt::decrypt($event->name);
     // remove all budget prediction points, if any
     $event->budgetpredictionpoints()->delete();
     $similar = array();
     // get all similar budgets from the past:
     $budgets = Auth::user()->budgets()->where('date', '<=', $event->date)->get();
     foreach ($budgets as $budget) {
         $budget->name = Crypt::decrypt($budget->name);
         if ($budget->name == $event->name) {
             $similar[] = $budget->id;
         }
     }
     if (count($similar) > 0) {
         // get all transactions for these budgets:
         $amounts = array();
         $transactions = Auth::user()->transactions()->orderBy('date', 'DESC')->where('onetime', '=', 0)->whereIn('budget_id', $similar)->get();
         foreach ($transactions as $t) {
             $date = new Carbon($t->date);
             $day = intval($date->format('d'));
             $amounts[$day] = isset($amounts[$day]) ? $amounts[$day] + floatval($t->amount) * -1 : floatval($t->amount) * -1;
         }
         // then make sure it's "average".
         foreach ($amounts as $day => $amount) {
             // save as budget prediction point.
             $bpp = new Budgetpredictionpoint();
             $bpp->budget_id = $event->id;
             $bpp->amount = $amount / count($similar);
             $bpp->day = $day;
             $bpp->save();
         }
     }
 }
Example #26
0
 public static function checkPermission($user, $post)
 {
     if ($post->deleted_at) {
         return false;
     }
     $friend = User::find($post->created_by);
     if (Auth::check()) {
         if ($post->created_by != $user->id) {
             switch ($post->privacy_level) {
                 case Post::_PRIVATE:
                     return false;
                     break;
                 case Post::_FRIEND:
                     $can_see = $user->friendship($friend);
                     if ($can_see == Friend::STRANGER) {
                         return false;
                     }
                     break;
                 case Post::_CUSTOM:
                     $can_see = DB::table('friend_post')->where('post_id', $post->id)->where('friend_id', Auth::user()->id)->first();
                     if (is_null($can_see)) {
                         return false;
                     }
                     break;
                 case Post::_PUBLIC:
                 default:
                     break;
             }
         }
     } else {
         return $post->privacy_level == Post::_PUBLIC;
     }
     return true;
 }
 /**
  * Display a listing of videos
  *
  * @return Response
  */
 public function index()
 {
     $menu = json_decode(Menu::orderBy('order', 'ASC')->get()->toJson());
     $user = Auth::user();
     $data = array('menu' => $menu, 'user' => $user, 'admin_user' => Auth::user());
     return View::make('admin.menu.index', $data);
 }
Example #28
0
 function is_admin()
 {
     if (\Auth::user()->role->name == 'admin') {
         return true;
     }
     return false;
 }
Example #29
0
 protected function user_list($condition = "")
 {
     $lang = Config::get('app.locale');
     $user_id = Auth::user()->id;
     $sql = "SELECT us.id, em.code AS em_code, em.{$lang} AS em_name, org.{$lang} as organization, de.{$lang} as department, \n                us.user, '****************' AS pw, ur.{$lang} as user_roll, ifnull(DATE_FORMAT(us.updated_at,'%m-%d-%Y %h:%i %p'),DATE_FORMAT(us.created_at,'%m-%d-%Y %h:%i %p')) AS modify_at\n                FROM ((((users AS us LEFT JOIN employees AS em ON us.employee_id=em.id)\n                LEFT JOIN user_rolls AS ur ON us.user_roll_id=ur.id)\n                left join organizations as org on em.organization_id=org.id)\n                left join departments as de on em.department_id=de.id)\n                WHERE us.is_deleted = 0 \n                AND em.organization_id IN (SELECT manage_organizations.organization_id FROM manage_organizations WHERE manage_organizations.is_deleted = 0 AND manage_organizations.is_deleted = 0 AND manage_organizations.user_id={$user_id}) \n                {$condition}  \n                ORDER BY em.{$lang}";
     return DB::select($sql);
 }
Example #30
0
 public function edit($id)
 {
     if (Request::isMethod('post')) {
         $rules = array('title' => 'required|min:4', 'link' => 'required', 'content' => 'required|min:50', 'meta_description' => 'required|min:20', 'meta_keywords' => 'required');
         $validator = Validator::make(Input::all(), $rules);
         if ($validator->fails()) {
             return Redirect::to("admin/{$this->name}/{$id}/{$this->action}")->withErrors($validator)->withInput(Input::except(''));
         } else {
             $table = Page::find($id);
             $table->title = Input::get('title');
             $table->link = Input::get('link');
             $table->user_id = Auth::user()->id;
             $table->content = Input::get('content');
             $table->meta_title = Input::get('meta_title') ? Input::get('meta_title') : $table->title;
             $table->meta_description = Input::get('meta_description') ? Input::get('meta_description') : $table->description;
             $table->meta_keywords = Input::get('meta_keywords');
             $table->published_at = Page::toDate(Input::get('published_at'));
             $table->active = Input::get('active', 0);
             if ($table->save()) {
                 $name = trans("name.{$this->name}");
                 return Redirect::to("admin/{$this->name}")->with('success', trans("message.{$this->action}", ['name' => $name]));
             }
             return Redirect::to("admin/{$this->name}")->with('error', trans('message.error'));
         }
     }
     return View::make("admin.{$this->name}.{$this->action}", ['item' => Page::find($id), 'name' => $this->name, 'action' => $this->action]);
 }