Ejemplo n.º 1
0
 /**
  * Returns the specified route parameter if it exists.
  *
  * @param string $parameter
  *
  * @return bool|string|int
  */
 public function getRouteParameter($parameter)
 {
     $param = Route::getCurrentRoute()->getParameter($parameter);
     if ($param) {
         return $param;
     }
     return false;
 }
Ejemplo n.º 2
0
 public function LngCompose($view)
 {
     $arrLng = Languages::all()->toArray();
     $action = Route::currentRouteAction();
     $params = Route::getCurrentRoute()->parameters();
     $arrAction = explode("\\", $action);
     $controller = array_pop($arrAction);
     $view->with(compact('arrLng', 'action', 'controller', 'params'));
 }
Ejemplo n.º 3
0
 function showLoginCk()
 {
     Session::put('current_url', Route::getCurrentRoute()->getPath());
     if (Auth::check() == false) {
         return View::make('login');
     } else {
         return View::make('alldata')->with('location', $this->locationID());
         //return $this->Getalldata();
     }
 }
Ejemplo n.º 4
0
 /**
  * Returns true / false if the specified
  * work order session has already ended.
  *
  * @param $attribute
  * @param $workOrderId
  * @param $parameters
  *
  * @return bool
  */
 public function validateSessionEnd($attribute, $workOrderId, $parameters)
 {
     $sessionId = Route::getCurrentRoute()->getParameter('sessions');
     if ($sessionId) {
         $session = $this->session->find($sessionId);
         if (!is_null($session->out)) {
             return false;
         }
     }
     return true;
 }
Ejemplo n.º 5
0
 public function __construct()
 {
     $this->curretRoute = Route::getCurrentRoute()->getPath();
     $this->groupRoutesLogin = ['login', 'register', 'password/email', 'password/reset'];
     if (isset(Auth::user()->id)) {
         $this->user = new User();
         $this->datos = $this->user->isADoctor(Auth::user()->id);
     } else {
         return redirect()->route('login');
     }
 }
Ejemplo n.º 6
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (registrar()) {
         $has_notifications = RegistrationNotification::where('registration_id', registrar()->id)->where('seen', 0)->count();
         $notification_routes = ['registration.registrar.notifications', 'registration.registrar.notifications.update'];
         if ($has_notifications && !in_array(Route::getCurrentRoute()->getName(), $notification_routes)) {
             return redirect()->route('registration.registrar.notifications')->with('message', 'عليك التأكيد بأنك قرأت هذه الإشعارات.');
         }
     }
     return $next($request);
 }
 protected function getConfigForEndpoint()
 {
     /** @var \Illuminate\Routing\Route $route */
     $route = Route::getCurrentRoute();
     foreach ($this->endpoints as $path => $config) {
         if ($path == $route->getPath() && $this->checkRequestMethod()) {
             return $config;
         }
     }
     return null;
 }
 /**
  * Validates that work order only contains one report.
  *
  * @param string     $attribute
  * @param int|string $locationId
  * @param $parameters
  *
  * @return bool
  */
 public function validateUniqueReport($attribute, $locationId, $parameters)
 {
     $workOrderId = Route::getCurrentRoute()->getParameter('work_orders');
     if ($workOrder = $this->workOrder->find($workOrderId)) {
         if ($workOrder->report) {
             return false;
         }
         return true;
     }
     return false;
 }
 /**
  * Validates that the inserted stock is smaller than the available stock.
  *
  * @param $attribute
  * @param $quantity
  * @param $parameters
  *
  * @return bool
  */
 public function validateEnoughQuantity($attribute, $quantity, $parameters)
 {
     if (is_numeric($quantity)) {
         $stockId = Route::getCurrentRoute()->getParameter('stocks');
         $stock = $this->inventoryStock->find($stockId);
         if ($quantity > $stock->quantity) {
             return false;
         }
         return true;
     }
     return false;
 }
 /**
  * Validates that a stock does not exist on the specified location.
  *
  * @param string     $attribute
  * @param int|string $locationId
  * @param array      $parameters
  *
  * @return bool
  */
 public function validateStockLocation($attribute, $locationId, $parameters)
 {
     $itemId = Route::getCurrentRoute()->getParameter('inventory');
     $stockId = Route::getCurrentRoute()->getParameter('stocks');
     if (!empty($stockId)) {
         $stocks = $this->inventoryStock->where('inventory_id', $itemId)->where('id', '!=', $stockId)->where('location_id', $locationId)->get();
     } else {
         $stocks = $this->inventoryStock->where('inventory_id', $itemId)->where('location_id', $locationId)->get();
     }
     if ($stocks->count() > 0) {
         return false;
     }
     return true;
 }
 /**
  * @param $attribute
  * @param $users
  * @param $parameters
  *
  * @return bool
  */
 public function validateUserAssignment($attribute, $users, $parameters)
 {
     $workOrder_id = Route::getCurrentRoute()->getParameter('work_orders');
     foreach ($users as $user) {
         $assignment = $this->assignment->with('toUser')->where('work_order_id', $workOrder_id)->where('to_user_id', $user)->get()->first();
         if ($assignment) {
             $this->invalidUsers[] = $assignment->toUser->full_name;
         }
     }
     if (count($this->invalidUsers) > 0) {
         return false;
     }
     return true;
 }
Ejemplo n.º 12
0
 /**
  * Validates that the event only has one report.
  *
  * @param string $attribute
  * @param string $value
  * @param $parameters
  *
  * @return bool
  */
 public function validateUniqueReport($attribute, $value, $parameters)
 {
     if (is_array($parameters) && count($parameters) > 0) {
         $eventId = Route::getCurrentRoute()->getParameter('events');
         // Make sure the event exists
         $event = $this->event->find($eventId);
         if ($event) {
             $report = $this->report->where('event_id', $parameters[0])->first();
             if ($report) {
                 return false;
             }
             return true;
         }
     }
     return false;
 }
Ejemplo n.º 13
0
 /**
  *
  * @param string $uri
  * @param string $current
  * @return boolean
  */
 public static function match($uri, $current = NULL)
 {
     $uri = trim($uri, '/');
     if ($current === NULL) {
         $current = Route::getCurrentRoute()->getUri();
     }
     $current = trim($current, '/');
     if ($current == $uri) {
         return TRUE;
     }
     if (empty($uri)) {
         return FALSE;
     }
     if (strpos($current, $uri) !== FALSE) {
         return TRUE;
     }
     return FALSE;
 }
Ejemplo n.º 14
0
 public function loadFromDB()
 {
     if (php_sapi_name() != 'cli') {
         // php artisan route:list gets broken otherwise
         $this->beforeFilter(function () {
             $uri = explode('/', Route::getCurrentRoute()->uri());
             if (count($uri) < 2) {
                 return;
             }
             $routeName = $uri[0];
             $routeParameters = Route::getCurrentRoute()->parameters();
             $routeValue = array_shift($routeParameters);
             if ($routeValue) {
                 try {
                     $this->record = call_user_func(array('\\App\\' . ucfirst($routeName), 'withTrashed'))->find($routeValue);
                     if ($this->record === null) {
                         throw new \Exception('Record could not be found for given id in database');
                     }
                     if ($this->record->trashed()) {
                         return redirect($routeName)->with('pageWarning', 'You tried to access a ' . $routeName . ' which was deleted on ' . str_ireplace(' ', ' at ', $this->record->deleted_at));
                     }
                     if ($routeName == 'lead' && $this->record->converted_at) {
                         return redirect($routeName)->with('pageWarning', 'You tried to access a ' . $routeName . ' which was converted on ' . str_ireplace(' ', ' at ', $this->record->converted_at));
                     }
                     $user = User::find(Auth::User()->id);
                     $history = empty($user->recent_items) ? [] : unserialize($user->recent_items);
                     if (!in_array($routeName . '-' . $routeValue, $history)) {
                         array_unshift($history, $routeName . '-' . $routeValue);
                     }
                     if (count($history) > 30) {
                         array_pop($history);
                     }
                     $user->recent_items = serialize($history);
                     $user->update();
                 } catch (\Exception $e) {
                     return redirect($routeName)->with('pageError', $routeName . ' record could not be found in database.' . $e->getTraceAsString());
                 }
             }
         });
     }
 }
Ejemplo n.º 15
0
 public function pages()
 {
     $slug = Route::getCurrentRoute()->getPath();
     $content = Menu::where('slug', $slug)->first();
     if ($content->content_id > 0) {
         $content['data'] = $content->content;
         $content['data']['html'] = json_decode($content->content->content);
     } elseif ($content->cat_id > 0) {
         $cat_id = $content->category->id;
         $contents = Content::where('cat_id', $cat_id)->get();
         $array = [];
         $counter = 0;
         foreach ($contents as $c) {
             $array[$counter] = $c;
             $array[$counter]['html'] = json_decode($c->content);
             $counter++;
         }
         $content['data'] = collect($array)->toArray();
     }
     return $content;
 }
Ejemplo n.º 16
0
 /**
  * Retrieve a list of menu items to display in the layout template
  *
  * @return void
  */
 private function _getMenuItems()
 {
     return ['home' => ['href' => route('home'), 'active' => Route::getCurrentRoute()->getName() == "home", 'title' => 'Home'], 'about' => ['href' => route('about'), 'active' => Route::getCurrentRoute()->getName() == "about", 'title' => 'About'], 'contact' => ['href' => route('contact'), 'active' => Route::getCurrentRoute()->getName() == "contact", 'title' => 'Contact']];
 }
Ejemplo n.º 17
0
 public function fooBar()
 {
     dump(Route::getCurrentRoute());
     dump($this->getRouter()->getCurrentRoute()->getName());
 }
Ejemplo n.º 18
0
 public function getCurrentRouteInfo()
 {
     return Route::getCurrentRoute()->getAction();
 }
Ejemplo n.º 19
0
 /**
  * get scope current
  * 
  * @return int
  */
 public function getScopeCurrent()
 {
     if ($this->isRuleAll()) {
         return RoleScope::SCOPE_COMPANY;
     }
     $routeName = Route::getCurrentRoute()->getName();
     if (isset(self::$rules[$routeName])) {
         return self::$rules[$routeName]->scope;
     }
     return null;
 }
 public function defaultMinistryPage()
 {
     $ministry_slug = Route::getCurrentRoute()->getUri();
     return view($ministry_slug, ['ministry' => Ministry::whereSlug($ministry_slug)->first()]);
 }
 public function defaultPage()
 {
     $view = Route::getCurrentRoute()->getUri();
     return view($view);
 }
Ejemplo n.º 22
0
 /**
  * Determine the appropriate action parameter to use for a form.
  *
  * If no action is specified, the current request URI will be used.
  *
  * @param  string   $action
  * @param  bool     $https
  * @return string
  */
 protected function route($route = null)
 {
     if (!is_null($route)) {
         return $route;
     }
     return array_merge([Route::currentRouteName()], array_values(Route::getCurrentRoute()->parameters()));
 }
Ejemplo n.º 23
0
 public function isAdminRequest()
 {
     return Route::getCurrentRoute()->getPrefix() == '/admin';
 }
Ejemplo n.º 24
0
 /**
  * Calls 'after' filters, if any supplied
  *
  * @param  Illuminate\Http\Response $response
  * @return Illuminate\Http\Response
  */
 private function callAfterFilters($response)
 {
     // Only if there exists a route AND after filters, we will apply the after
     // filter. Why? Because if there's no matching route, then, the after
     // filter will squak out as we'll be missing the 'route' parameter
     // that it needs.
     if (($route = Router::getCurrentRoute()) && !is_null($after = Config::get('hive::response.after'))) {
         $afterFilters = Route::parseFilters($after);
         foreach ($afterFilters as $filter => $parameters) {
             Router::callRouteFilter($filter, $parameters, $route, Router::getCurrentRequest(), $response);
         }
     }
     return $response;
 }
 /**
  * Determines and loads the current controller and action.
  */
 protected function _loadCurrentResource()
 {
     $resource = class_basename(Route::getCurrentRoute()->getActionName());
     list($this->_controller, $this->_action) = explode('@', $resource);
 }
Ejemplo n.º 26
0
 public function getPageWithTheme()
 {
     $path = Route::getCurrentRoute()->getPath();
     $page = Pages::where(['slug' => $path])->firstOrFail();
     return view($path, ['page' => $page]);
 }
Ejemplo n.º 27
0
 public static function add($object_id, $message)
 {
     $user = User::findOrFail(Auth::user()->id);
     History::create(['user_id' => $user->id, 'username' => $user->name, 'url' => Route::getCurrentRoute()->getName(), 'action' => Route::getCurrentRoute()->getActionName(), 'message' => $message, 'object_id' => $object_id]);
 }