public static function isAdmin() { if (!Entrust::hasRole('admin')) { return false; } return true; }
/** * Display a listing of rateinquiries * * @return Response */ public function index() { //RateInquiry::where('viewed', 0)->where('status', 1)->update(array('viewed'=> 1)); $from = null; $to = null; if (Input::has('search')) { //dd(Input::all()); $from = Input::get('from'); $to = Input::get('to'); if (Entrust::hasRole('Admin')) { $user_id = Input::get('agent_id'); $rateinquiries = RateInquiry::whereHas('user', function ($q) use($user_id) { $q->where('users.id', 'like', '%' . $user_id . '%'); }); } elseif (Entrust::hasRole('Agent')) { $rateinquiries = RateInquiry::whereHas('user', function ($q) { $q->where('users.id', '=', Auth::id()); }); } if (!empty($from) && !empty($to)) { $rateinquiries = $rateinquiries->where('from', '>=', $from)->where('to', '<=', $to); } $rateinquiries = $rateinquiries->get(); } else { if (Entrust::hasRole('Admin')) { $rateinquiries = RateInquiry::orderBy('updated_at', 'desc')->get(); } elseif (Entrust::hasRole('Agent')) { $rateinquiries = RateInquiry::where('user_id', Auth::id())->orderBy('updated_at', 'desc')->get(); } } return View::make('inquiries.rate-inquiries.index', compact('rateinquiries', 'user_id', 'from', 'to')); }
public function postSchimbaStadiu($id_livrabil) { $actualizare_ore = Input::get('ore_lucrate') > 0; $is_stadiu = Input::get('stadiu_selectionat') != null && Input::get('stadiu_selectionat') > 0; $array_update = array(); if ($is_stadiu) { //Face insert in tabela de istoric de stadii //Actualizeaza stadiul livrabilului $array_update = array_add($array_update, 'id_stadiu', Input::get('stadiu_selectionat')); } if ($actualizare_ore) { //Actualizeaza numarul de ore lucrate la acest livrabil $array_update = array_add($array_update, 'ore_lucrate', Input::get('ore_lucrate')); } // Start transaction! DB::beginTransaction(); if ($is_stadiu) { try { DB::table('istoric_stadii_livrabil')->insertGetId(array('id_livrabil_etapa' => Input::get('id_livrabil_etapa'), 'id_stadiu' => Input::get('stadiu_selectionat'), 'id_user' => Entrust::user()->id)); } catch (Exception $e) { DB::rollback(); return Redirect::back()->with('message', 'Eroare salvare date: ' . $e); } } if ($is_stadiu || $actualizare_ore) { try { DB::table('livrabile_etapa')->where('id', Input::get('id_livrabil_etapa'))->update($array_update); } catch (Exception $e) { DB::rollback(); return Redirect::back()->with('message', 'Eroare salvare date: ' . $e); } } DB::commit(); return Redirect::back()->with('message', 'Actualizare realizata cu succes!')->withInput(); }
public function allowed($sAction = null, $sRole = null) { if (static::isAdmin() || \Entrust::hasRole('admin') || \Entrust::can($sAction) || \Entrust::hasRole($sRole)) { return true; } return false; }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next, $role) { if (\Auth::check() && !\Entrust::hasRole($role)) { return redirect()->back(); } return $next($request); }
public static function getCreditLimit($agent_id) { if (Entrust::hasRole('Agent')) { return Agent::where('user_id', $agent_id)->first()->credit_limit; } return false; }
public function __construct() { $this->middleware('auth'); // Check for the right roles to access these pages if (!\Entrust::can('view-admin-panel')) { abort(403, 'Unauthorized access - you do not have the necessary role to see this page.'); } }
public function __construct() { $this->data['crud'] = $this->crud; // Check for the right roles to access these pages if (!\Entrust::can('view-admin-panel')) { abort(403, trans('crud.unauthorized_access')); } }
public static function userHasAgent() { if (Entrust::hasRole('Agent')) { if ($x = User::getAgentOfUser(Auth::user())) { return Agent::with('market')->find($x->agent_id); } } return false; }
/** * Funcion que retorna la vista de inicio del modulo de Equipo, esta retorna la vista con los datos * @param Request $request - variable interna que controla los elementos de la vista para obtner su valor * @return $this */ public function inicio(Request $request) { if (!\Entrust::can('crud-empleados')) { return \Redirect::to('/'); } else { $registros = \DB::table('users')->join('role_user', 'users.id', '=', 'user_id')->join('roles', 'roles.id', '=', 'role_id')->where('users.type', '=', 0)->select('users.id AS id_usuario', 'users.name AS nombre_usuario', 'users.email', 'users.avatar', 'roles.display_name')->orderBy('roles.display_name', 'asc')->paginate(6); return view('Center.empleados.ver')->with('registros', $registros); } }
public function inicio(Request $request) { if (!\Entrust::can('crud-promociones')) { return \Redirect::to('/'); } else { $registros = Promociones::buscar($request->get('parametros'))->orderBy('nombre', 'desc')->paginate(6); return view('Center.promociones.ver')->with('registros', $registros); } }
public function __construct() { $this->_user = Auth::user(); $this->_parameters = Route::current()->parameters(); if (!User::hasHotelPermission($this->_user, $this->_parameters['hotels'])) { if (!Entrust::hasRole('Admin')) { App::abort(403); } } }
/** * Display a listing of xcasts * * @return Response */ public function index() { $search = Request::get('q'); $xcasts = $search ? Xcast::search($search) : Xcast::latest('updated_at'); if (!Entrust::can('manage_premium_casts') && !Entrust::can('delete_casts')) { $xcasts = $xcasts->onlyFree(); } $xcasts = $xcasts->paginate(8); return View::make('admin.xcasts.index', compact('xcasts')); }
public function destroy(Comment $comment) { if ($comment->user_id != Auth::user()->id && !Entrust::hasRole('admin')) { return redirect()->back()->withErrors(config('constants.INVALID_LINK')); } $belongs_to = $comment->belongs_to; $comment->delete(); $activity = 'Deleted a commented on a ' . ucfirst($belongs_to); Activity::log($activity); return redirect()->back()->withSuccess(config('constants.DELETED')); }
public function getInDebugModeAttribute() { //限管理員 if (!\Entrust::hasRole('admin')) { return false; } if (!$this->debug) { return false; } return true; }
public function postDestroy($id) { if (\Entrust::hasRole('Admin')) { $category = Category::find($id); if ($category) { $category->delete(); return redirect('admin/categories/view')->with('flash_message', 'Category deleted'); } } return redirect('admin/categories/view')->with('flash_message', 'You unable to delete categories due to Demo account'); }
/** * Login with the provided username & password in local first, if * failed, try login in center. * * @param Request * @return Json */ public function login(Request $request) { $username = $request->input('username'); $password = $request->input('password'); // if login failed if (!Auth::attempt(['username' => $username, 'password' => $password]) && self::loginCheckSSO($username, $password) === 'SUCCESS') { $user = User::where('username', '=', $username)->first(); Auth::login($user); } $response = ['is_student' => \Entrust::hasRole('student'), 'is_manager' => \Entrust::hasRole('manager'), 'status' => Auth::check()]; return response()->json($response); }
public function getInvestitii() { $ids = self::getIDsDepartamente(Confide::getDepartamenteUser()); $sql = "SELECT \n investitie.id,\n investitie.denumire,\n im.adresa,\n investitie.id_imobil,\n j.denumire AS judet,\n l.denumire AS localitate\n FROM por12_investitie investitie\n INNER JOIN imobil im ON im.id = investitie.id_imobil AND im.logical_delete = 0\n LEFT OUTER JOIN judet j ON j.id_judet = im.id_judet AND j.logical_delete = 0\n LEFT OUTER JOIN localitate l ON l.id_localitate = im.id_localitate AND l.logical_delete = 0"; if (!Entrust::can("administrare_platforma")) { $sql .= " INNER JOIN departament ON departament.id = investitie.id_departament AND departament.logical_delete = 0\n AND departament.id IN (" . $ids . ") "; } $sql .= " WHERE investitie.logical_delete = 0"; //dd($sql); $investitii = DB::select($sql); return View::make('investitie_por_axa12.list')->with('investitii', $investitii); }
public function getBanci() { $banci = array(); $sql = "SELECT\n id,\n denumire,\n adresa, \n telefon\n FROM banca\n WHERE logical_delete = 0"; if (\Entrust::can('administrare_platforma')) { $banci = DB::select($sql); } else { $sql .= " AND id_organizatie = :id_organizatie"; $banci = DB::select($sql, array('id_organizatie' => isset(self::organizatie()[0]) ? self::organizatie()[0]->id_organizatie : -1)); } return View::make("banca::banca.list")->with("banci", $banci); }
public function getReprezentantiOrganizatie() { $reprezentanti = array(); $sql = "SELECT \n rl.id,\n rl.nume,\n rl.cnp\n FROM reprezentant_legal rl\n WHERE rl.logical_delete = 0"; if (\Entrust::can('administrare_platforma')) { $reprezentanti = DB::select($sql); } else { $sql .= " AND id_organizatie = :id_organizatie"; $reprezentanti = DB::select($sql, array('id_organizatie' => isset(self::organizatie()[0]) ? self::organizatie()[0]->id_organizatie : -1)); } return View::make('entitate::reprezentant_legal.list')->with('reprezentanti', $reprezentanti); }
/** * Store a newly created payment in storage. * * @return Response */ public function store() { $data = Input::all(); $user_id = Auth::id(); $validator = Validator::make(Input::all(), array('amount' => 'required|numeric')); if ($validator->fails()) { return Redirect::back()->withErrors($validator)->withInput(); } /** * Payments are starting from "BK" numbers */ if ($x = Payment::find(Payment::max('id'))) { $y = (int) substr($x->reference_number, 2); $data['reference_number'] = 'BK' . ++$y; } else { $data['reference_number'] = 'BK10000000'; } $data['agent_id'] = User::getAgentOfUser(Auth::id()); if (Entrust::hasRole('Agent')) { $agent_id = $data['agent_id']->user_id; $name = User::where('id', $user_id)->first()->first_name . ' ' . User::where('id', $user_id)->first()->last_name; $email = User::where('id', $user_id)->first()->email; $phone = Agent::where('user_id', $user_id)->first()->phone; $amount = Input::get('amount'); $details = Input::get('details'); $data = array('details' => $name, 'ip_address' => $_SERVER['REMOTE_ADDR'], 'amount' => $amount, 'payment_status' => 0, 'my_booking' => 2); $reserv_id = Payment::create($data); $data_tab_HSBC_payment = array('currency' => 'USD'); $tab_HSBC_payment_id = HsbcPayment::create($data_tab_HSBC_payment); $stamp = strtotime("now"); $payment_id = Payment::orderBy('created_at', 'desc')->first()->id; $orderid = "{$stamp}" . 'AP' . "{$payment_id}"; $last_res_resid = str_replace(".", "", $orderid); $hsbc_id = HsbcPayment::orderBy('created_at', 'desc')->first()->id; $hsbc_payment_id_pre = "{$stamp}" . 'HSBC' . "{$hsbc_id}"; $hsbc_payment_id = str_replace(".", "", $hsbc_payment_id_pre); if ($last_res_resid) { $payment = DB::table('payments')->where('id', $payment_id)->update(array('reference_number' => $last_res_resid, 'HSBC_payment_id' => $hsbc_payment_id)); $data_tab_HSBC_payment = DB::table('hsbc_payments')->where('id', $hsbc_id)->update(array('HSBC_payment_id' => $hsbc_payment_id)); $client = array('booking_name' => $name, 'email' => $email, 'phone' => $phone, 'remarks' => $details, 'val' => 0, 'payment_reference_number' => $last_res_resid); $client_payment_id = Booking::create($client); } $currency = 'USD'; $x = $amount * 1.037; $total_price_all_hsbc = round($x, 2) * 100; //dd($hsbc_payment_id . '/' . $currency . '/' . $total_price_all_hsbc . '/' . $last_res_resid); HsbcPayment::goto_hsbc_gateway($hsbc_payment_id, $currency, $total_price_all_hsbc, $last_res_resid); // return $this->storeAllDataAndSendEmails(); } //Payment::create($data); return Redirect::route('accounts.payments.index'); }
/** * Deletes a log file. */ public function delete($file_name) { if (!\Entrust::can('delete-logs')) { abort(403, 'Unauthorized access - you do not have the necessary permission to delete logs.'); } $disk = Storage::disk('local'); if ($disk->exists('logs/' . $file_name)) { $disk->delete('logs/' . $file_name); return 'success'; } else { abort(404, "The log file doesn't exist."); } }
/** * Deletes a backup file. */ public function delete($file_name) { if (!\Entrust::can('delete-backups')) { abort(403, 'Unauthorized access - you do not have the necessary permission to delete backups.'); } $disk = Storage::disk(config('dick.backupmanager.disk')); if ($disk->exists('backups/' . $file_name)) { $disk->delete('backups/' . $file_name); return 'success'; } else { abort(404, "The backup file doesn't exist."); } }
public function getPersonalOrganizatie() { $personal = array(); $sql = "SELECT \n p.id,\n p.nume,\n p.cnp,\n p.telefon_1,\n p.telefon_2,\n p.mail_1,\n p.mail_2,\n (SELECT group_concat(ent.denumire) \n FROM entitate ent\n INNER JOIN personal_entitate pe ON pe.id_entitate = ent.id AND pe.logical_delete = 0\n WHERE ent.logical_delete = 0\n AND pe.id_personal = p.id) AS entitati\n FROM personal p\n WHERE p.logical_delete = 0"; //dd($sql); if (\Entrust::can('administrare_platforma')) { $personal = DB::select($sql); } else { $sql .= " AND p.id_organizatie = :id_organizatie"; $personal = DB::select($sql, array('id_organizatie' => isset(self::organizatie()[0]) ? self::organizatie()[0]->id_organizatie : -1)); //dd($sql); } return View::make('entitate::personal.list')->with('personal', $personal); }
/** * Get the validation rules that apply to the request. * * @return array */ public function rules() { $rules = ['name' => 'required', 'email' => 'required|email|unique:users', 'role' => 'required', 'password' => 'required']; if ($this->isMethod('PATCH')) { if (!\Entrust::hasRole('admin')) { unset($rules['role']); } $rules['email'] = 'required|email|unique:users,email,' . $this->get('id'); if (empty($this->get('password'))) { unset($rules['password']); } } return $rules; }
public function update($id, $userData) { if (isset($userData['password']) && !empty(trim($userData['password']))) { $userData['password'] = bcrypt($userData['password']); } else { unset($userData['password']); } $user = $this->user->find($id); $user->update($userData); if (\Entrust::hasRole('admin')) { $role = $this->role->where('name', $userData['role'])->first(); $user->roles()->detach(); $user->attachRole($role); } }
public function getSeriiFacturare() { $ids = self::getIDsDepartamente(Confide::getDepartamenteUser()); $sql = "SELECT \n sf.id,\n sf.serie,\n sf.numar,\n sf.id_entitate,\n ent.denumire AS entitate\n FROM serie_factura sf\n INNER JOIN entitate ent ON ent.id = sf.id_entitate AND ent.logical_delete = 0\n WHERE "; if (!Entrust::can("administrare_platforma")) { /*$sql .= " INNER JOIN departament d ON d.id_entitate = ent.id AND d.logical_delete = 0" . " AND d.id IN (" . $ids . ")";*/ $sql .= " EXISTS(SELECT id FROM departament WHERE departament.id_entitate = sf.id_entitate AND departament.logical_delete = 0\n AND departament.id IN (" . $ids . ")) AND "; } $sql .= " sf.logical_delete = 0 ORDER BY ent.id, sf.serie"; //dd($sql); $serii = DB::select($sql); return View::make('serii_facturare.list')->with('serii', $serii); }
public function destroy(Attachment $attachment) { if (!Helper::getMode()) { return redirect()->back()->withErrors(config('constants.DISABLE_MESSAGE')); } if ($attachment->user_id != Auth::user()->id && !Entrust::hasRole('admin')) { return redirect()->back()->withErrors(config('constants.INVALID_LINK')); } $belongs_to = $attachment->belongs_to; File::delete('uploads/attachment_files/' . $attachment->file); $attachment->delete($id); $activity = 'Deleted a file on a ' . $belongs_to; Activity::log($activity); return redirect()->back()->withSuccess(config('constants.DELETED')); }
public function index() { $subjects = collect(Subject::where('trash', '=', false)->get()->toArray())->groupBy('name')->count(); $partitions = Partition::where('trash', '=', false)->count(); $invites = Invite::count(); $questions = Question::where('trash', '=', false)->count(); $users = User::count(); $trash = ''; $testrooms = ''; if (\Entrust::hasRole('admin')) { $trash = Question::where('trash', '=', true)->count() + Subject::where('trash', '=', true)->count() + Partition::where('trash', '=', true)->count() + TestRoom::where('teacher_id', '=', \Auth::user()->id)->where('trash', '=', true)->count(); } elseif (\Entrust::hasRole('teacher')) { $testrooms = TestRoom::where('teacher_id', '=', \Auth::user()->id)->count(); } return view('admin.welcome', ['subjects' => $subjects, 'partitions' => $partitions, 'invites' => $invites, 'questions' => $questions, 'users' => $users, 'trash' => $trash, 'testrooms' => $testrooms]); }
/** * @param $filters * @param null $limit * * @return \Illuminate\Database\Eloquent\Collection|static[] */ public function getAll($filters, $limit = null) { $query = $this->post->select('*'); if (!\Entrust::can('manage-all-content')) { $query->where('created_by', auth()->user()->id); } $from = "posts "; if (isset($filters['status']) && $filters['status'] != '') { $status = $filters['status']; $query->whereRaw("posts.metadata->>'status' = ?", [$status]); } if (isset($filters['date_from']) && $filters['date_from'] != '') { $query->whereRaw("date(created_at) >= ?", [str_replace('/', '-', $filters['date_from'])]); } if (isset($filters['date_to']) && $filters['date_to'] != '') { $query->whereRaw("date(created_at) <= ?", [str_replace('/', '-', $filters['date_to'])]); } if (isset($filters['post_type']) && $filters['post_type'] != '') { $post_type = $filters['post_type']; $query->whereRaw("posts.metadata->>'type' = ?", [$post_type]); } if (array_has($filters, "sub_category1")) { $ids = $filters['sub_category1']; $query->category($ids); } if (array_has($filters, "sub_category")) { $category = Category::find($filters['sub_category']); $category_ids = $category->getDescendantsAndSelf()->lists('id')->toArray(); $query->category($category_ids); } if (array_has($filters, "category")) { $category = Category::find($filters['category']); $category_ids = $category->getDescendantsAndSelf()->lists('id')->toArray(); $query->category($category_ids); } $query->from($this->db->raw($from)); $query->orderBy('updated_at', 'DESC'); if (is_null($limit)) { return $query->get(); } return $query->paginate(); }