/**
  * Get the API ancestor controller class
  * of the current controller class.
  *
  * @return Esensi\Core\Http\Controllers\ApiController
  */
 public function api()
 {
     // Make a copy of the parent class
     $class = get_parent_class();
     $parent = App::make($class);
     // Copy over the packaged properties
     if ($this instanceof PackagedInterface) {
         $parent->setUI($this->getUI());
         $parent->setPackage($this->getPackage());
         $parent->setNamespacing($this->getNamespacing());
     }
     // Copy over the injected repositories
     if ($this instanceof RepositoryInjectedInterface) {
         foreach ($this->repositories as $name => $repository) {
             $parent->setRepository($repository, $name);
         }
     }
     // Return first ApiController ancestor found
     if (str_contains($class, 'ApiController')) {
         return $parent;
     }
     // Recursively look up the parent class
     if (method_exists($parent, 'api')) {
         return $parent->api();
     }
     // Return the parent class found already
     return $parent;
 }
Exemple #2
0
 public function downloadInvoice($view, $id)
 {
     $brochure = App::make('walis-merchant.brochure');
     $brochure->loadView($view, InvoiceRepository::find($id));
     $filename = 'invoice_' . sha1(date("Y-n-d-His")) . '.pdf';
     return $brochure->download($filename);
 }
Exemple #3
0
 /**
  * Display the content of the page
  *
  * @param $query
  * @return \Illuminate\View\View
  */
 public function display($query)
 {
     $title = 'TestView';
     $page = "";
     $arr = explode('/', $query);
     // \App\Page::find(4)->content->find(5)->element->module->name
     $heading = \App\Node::findBySlug('header');
     //        dd(\App\Node::findBySlug($arr[0])->content);
     // test
     $content = \App\Node::active()->findBySlug($arr[0])->content;
     foreach ($content as $item) {
         // get the module Name of
         //            $module = \App\Module::findOrFail($p->module_id);
         // resolve the Module Name out of the IOC Container and render the content partiall
         //            $content .= App::make('module:' . $module->name)->render($p->content_id);
         //            foreach ($item->content as $content)
         //            {
         //Todo check if Module is Active and Content is Active
         $module = $item->element->module->name;
         if ($module != 'Heading') {
             continue;
         }
         // resolve the Module out of the IOC Container and render the partial
         $page .= App::make('module:' . strtolower($module))->render($item->element->row);
         //            }
     }
     return view('layout.master', compact('title', 'page'));
 }
 public function getTraining()
 {
     $training = new \Offside\Team\Training($this->trainingRepository);
     $javascript = App::make('Javascript');
     $javascript::put(['attackTraining' => $training->getAttackDateTime(), 'midfieldTraining' => $training->getMidfieldDateTime(), 'defenseTraining' => $training->getDefenseDateTime(), 'anyTrainingActive' => !$training->allTrainingsDone(), 'elapsedTime' => $training->getElapsedTime()]);
     return view("my-team.training");
 }
 /**
  * Register the HTML builder instance.
  * This binds the 'html' reference in the IoC container to the package implementation.
  * Laravel's HTML Facade will automatically use this when being called
  *
  * @return void
  */
 protected function registerHtmlBuilder()
 {
     $this->app->bindShared('html', function ($app) {
         $urlGenerator = App::make(UrlGenerator::class);
         return new HtmlBuilder($urlGenerator);
     });
 }
Exemple #6
0
 /**
  * @param Proxy $proxy
  * @param string $name
  */
 public function __construct(Proxy $proxy, $name = '')
 {
     self::$client = App::make('Elasticsearch');
     self::$config = App::make('Menthol\\Flexible\\Config');
     $this->setProxy($proxy);
     $this->setName($name ?: $proxy->getModel()->getTable());
 }
Exemple #7
0
 public function __construct(QueryStringOperations $qso)
 {
     $this->queryStringOps = $qso;
     $this->request = App::make('request');
     $this->url = App::make('url');
     $this->config = App::make('config');
 }
 /**
  * Handle the command
  *
  * @param BaseCommand|RegisterUserCommand $command
  *
  * @return mixed
  */
 public function handle(BaseCommand $command)
 {
     $user = new User($command->all());
     $user->save();
     App::make('Altwallets\\Services\\UserMailer')->sendRegistrationEmail($user);
     return $user;
 }
 public function __construct()
 {
     $this->package = \Vsch\TranslationManager\ManagerServiceProvider::PACKAGE;
     $this->packagePrefix = $this->package . '::';
     $this->manager = App::make($this->package);
     $this->cookiePrefix = $this->manager->getConfig('persistent_prefix', 'K9N6YPi9WHwKp6E3jGbx');
     $locale = Cookie::get($this->cookieName(self::COOKIE_LANG_LOCALE), \Lang::getLocale());
     App::setLocale($locale);
     $this->primaryLocale = Cookie::get($this->cookieName(self::COOKIE_PRIM_LOCALE), $this->manager->getConfig('primary_locale', 'en'));
     $this->locales = $this->loadLocales();
     $this->translatingLocale = Cookie::get($this->cookieName(self::COOKIE_TRANS_LOCALE));
     if (!$this->translatingLocale || $this->translatingLocale === $this->primaryLocale && count($this->locales) > 1) {
         $this->translatingLocale = count($this->locales) > 1 ? $this->locales[1] : $this->locales[0];
         Cookie::queue($this->cookieName(self::COOKIE_TRANS_LOCALE), $this->translatingLocale, 60 * 24 * 365 * 1);
     }
     $this->displayLocales = Cookie::has($this->cookieName(self::COOKIE_DISP_LOCALES)) ? Cookie::get($this->cookieName(self::COOKIE_DISP_LOCALES)) : implode(',', array_slice($this->locales, 0, 5));
     $this->displayLocales .= implode(',', array_flatten(array_unique(explode(',', ($this->displayLocales ? ',' : '') . $this->primaryLocale . ',' . $this->translatingLocale))));
     //$this->sqltraces = [];
     //$this->logSql = 0;
     //
     //$thisController = $this;
     //\Event::listen('illuminate.query', function ($query, $bindings, $time, $name) use ($thisController)
     //{
     //    if ($thisController->logSql)
     //    {
     //        $thisController->sqltraces[] = ['query' => $query, 'bindings' => $bindings, 'time' => $time];
     //    }
     //});
 }
 /**
  * @param $id
  * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  */
 public function show($id)
 {
     $todolist = $this->todolistRepository->byId($id);
     $javaScript = App::make('JavaScript');
     $javaScript->put(['todolist' => $todolist]);
     return view('todolist', compact('todolist'));
 }
 public function __construct()
 {
     $this->middleware('auth');
     //        $this->beforeFilter('csrf', ['on' => 'post']);
     $this->displayNameField = config('genealabs-bones-keeper.displayNameField');
     $this->user = App::make(config('auth.model'));
 }
Exemple #12
0
 /**
  * Unfortunately we need to do an Integrated test for this particular use-case.
  */
 public function testSlugRetrieval()
 {
     $account = Account::create([]);
     App::make(AccountRepositoryInterface::class)->save($account);
     $this->assertNotEmpty($account->slug);
     $this->assertInstanceOf(Slug::class, $account->slug);
 }
Exemple #13
0
 public function __construct()
 {
     $this->request = App::make('request');
     $this->config = App::make('config');
     $this->serializer = App::make('serializer');
     $this->embededResponse = App::make('Symfony\\Component\\HttpFoundation\\Response');
 }
 /**
  * Register the service provider.
  *
  * @return void
  */
 public function register()
 {
     $this->app->bind('odm.documentmanager', function ($app) {
         $conn = Config::get('laravel-odm::connection');
         return DocumentManager::create(new Connection($conn['server'], $conn['options']), App::make('odm.config'));
     });
     $this->app->bind('odm.config', function ($app) {
         $conn = Config::get('laravel-odm::connection');
         $dir = Config::get('laravel-odm::dir');
         $config = new Configuration();
         $config->setProxyDir($dir['proxy']);
         $config->setProxyNamespace('Proxies');
         $config->setHydratorDir($dir['hydrator']);
         $config->setHydratorNamespace('Hydrators');
         $config->setMetadataDriverImpl(App::make('odm.annotation'));
         $config->setDefaultDB($conn['options']['db']);
         return $config;
     });
     $this->app->bind('odm.annotation', function ($app) {
         $dir = Config::get('laravel-odm::dir');
         AnnotationDriver::registerAnnotationClasses();
         $reader = new AnnotationReader();
         return new AnnotationDriver($reader, $dir['document']);
     });
 }
 /**
  * Constructor for initialize Paypal.
  */
 public function __construct()
 {
     // Get Cart in Container
     $this->cart = App::make('App\\Http\\Cart\\Cart');
     $this->_apiContext = Paypal::ApiContext(config('services.paypal.client_id'), config('services.paypal.secret'));
     $this->_apiContext->setConfig(['mode' => 'sandbox', 'service.EndPoint' => 'https://api.sandbox.paypal.com', 'http.ConnectionTimeOut' => 30, 'log.LogEnabled' => true, 'log.FileName' => storage_path('logs/paypal.log'), 'log.LogLevel' => 'FINE']);
 }
Exemple #16
0
 /**
  * Profiler constructor.
  */
 public function __construct()
 {
     $this->profiler = App::make('profiler');
     if ($this->profiler instanceof NullProfiler) {
         abort(500, 'Profiler is not instantiate correctly.');
     }
 }
 public function __construct()
 {
     $this->request = App::make('request');
     $this->config = App::make('config');
     $this->restResponse = App::make('Noherczeg\\RestExt\\Services\\ResponseComposer');
     $this->linker = App::make('Noherczeg\\RestExt\\Services\\Linker');
     $this->restExt = App::make('Noherczeg\\RestExt\\RestExt');
     if ($this->accessPolicy === null) {
         $this->accessPolicy = $this->config->get('restext::access_policy');
     }
     // if we set the property it should override the Accept Header even if it it is set otherwise in the configs
     if ($this->produces !== null) {
         $this->produce($this->produces);
     }
     $securityRoles = $this->securityRoles;
     $accessPolicy = $this->accessPolicy;
     // Default actions
     $this->beforeFilter(function () use($securityRoles, $accessPolicy) {
         // To prevent processing / returning of content if by default the access policy is set to
         // "whitelist" and no allowed roles have been set.
         if ($accessPolicy == 'whitelist' && count($securityRoles) == 0) {
             throw new PermissionException();
         }
         // If the "prefer_accept" configuration is set to true, we set RestResponse to send the MediaType given in
         // the Accept Header if it's compatible with our system. If not we set it to the default config's value.
         if ($this->config->get('restext::prefer_accept')) {
             if (in_array($this->requestAccepts(), $this->restResponse->getSupportedMediaTypes())) {
                 $this->restResponse->setMediaType($this->requestAccepts());
             }
             $this->restResponse->setMediaType($this->config->get('restext::media_type'));
         }
     });
 }
 public function pdf($reporterId)
 {
     $reporter = MediaReporter::find($reporterId);
     $pdf = App::make('dompdf');
     $pdf->loadView('blupl/printmedia::printing._print-single', ['name' => $reporter->name, 'role' => $reporter->role, 'organization' => $reporter->organization->name, 'photo' => $reporter->photo]);
     return $pdf->stream();
 }
 /**
  * Execute the console command.
  */
 public function handle()
 {
     if (!preg_match('/' . Config::get('laravel-hash-store::config.filter', '^.+$') . '/', $this->argument('key'))) {
         throw new Exception('Invalid hash key!');
     }
     $this->line('Hash created: ' . App::make('HashStore')->create($this->argument('key')));
 }
 public function __construct()
 {
     $this->middleware('auth');
     $user = Auth::user();
     $javascript = App::make('Javascript');
     $javascript::put(['goalkeeper' => trans('messages.goalkeeper'), 'defense' => trans('messages.defense'), 'midfield' => trans('messages.midfield'), 'attack' => trans('messages.attack'), 'average' => trans('messages.average'), 'experienced' => trans('messages.experienced'), 'legendary' => trans('messages.legendary'), 'golden' => trans('messages.golden'), 'budget' => $user ? $user->budget : 0]);
 }
Exemple #21
0
function phone_format($phone, $country, $format = null)
{
    $lib = App::make('libphonenumber');
    $phoneNumber = $lib->parse($phone, $country);
    $format = is_null($format) ? PhoneNumberFormat::INTERNATIONAL : $format;
    return $lib->format($phoneNumber, $format);
}
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     $cover_letter = CoverLetter::findOrFail($id);
     $pdf = App::make('dompdf.wrapper');
     $pdf->loadview('admin.coverletters.view', ['cover_letter' => $cover_letter]);
     return $pdf->download("{$cover_letter->name}.cover_Letter.pdf");
 }
 public function __construct()
 {
     $bfacp = App::make('bfadmincp');
     $this->isLoggedIn = $bfacp->isLoggedIn;
     $this->request = App::make('Illuminate\\Http\\Request');
     $this->user = $bfacp->user;
 }
 public function generateMatches()
 {
     $league = $this->league->getLeague();
     $teams = $this->league->getTeams()->toArray();
     if (!$league->running) {
         shuffle($teams);
         $this->league->deleteMatches();
         //Generate all possible matches, make them in rounds, than reverse them to play the return match
         $rounds = $this->reverseMatches($this->generateAllPossibleMatches($teams));
         //Make persistence on rounds[]
         $numberOfDays = 0;
         $scheDule = new MatchSchedule(true);
         $time = $scheDule->getSchedule();
         foreach ($rounds as $key => $round) {
             if ($key % 2 == 0) {
                 $numberOfDays++;
             }
             $date = Carbon::now()->addDay($numberOfDays)->hour($time['hour'])->minute($time['minute'])->second(0);
             foreach ($round as $game) {
                 //Resolve MatchRepository from IoC and create a new Match Model than attach it to League
                 App::make("Offside\\Repo\\MatchRepositoryInterface", ['league' => $league->id, 'firstTeam' => $game[0]['id'], 'secondTeam' => $game[1]['id'], 'starts' => $date]);
             }
             $time = $scheDule->getSchedule();
         }
         //After matches generated mark League as running, which will block any manipulation
         $league->running = true;
         $league->save();
     }
 }
 /**
  * Retrieve a user by the given credentials.
  * This will first authenticate against ldap before loading the user with eloquent
  * @param  array  $credentials
  * @return \Illuminate\Auth\UserInterface|null
  */
 public function retrieveByCredentials(array $credentials)
 {
     $username = $credentials['username'];
     $user = $this->createModel()->query()->where('username', $username)->first();
     if ($user == null && ($this->config['autoRegister'] || isset($credentials['isRegister']))) {
         //if our user wasn't found, and we have auto register enabled or we're coming from the user registration
         //directly, then we'll attempt an authentication and take the appropriate action.
         $ldap_info = $this->getAdLdap()->user()->info($username);
         if ($ldap_info['count'] != 1) {
             return null;
         }
         if ($this->getAdLdap()->authenticate($ldap_info[0]['dn'], $credentials['password'])) {
             if ($this->config['autoRegister']) {
                 //if we have auto register enabled, create a user and such using the ldap info.
                 $ldapInfo = $this->getAdLdap()->user()->info($username, array("givenname", "sn"))[0];
                 $userInfo = array();
                 $userInfo['firstname'] = isset($ldapInfo['givenname']) ? $ldapInfo['givenname'][0] : $username;
                 $userInfo['lastname'] = isset($ldapInfo['sn']) ? $ldapInfo['sn'][0] : '';
                 $userInfo['username'] = $username;
                 $userInfo['password'] = '******';
                 $user = App::make('UserRegistrator')->registerUser($userInfo, $this->config['registrationLanguage']);
             } elseif (isset($credentials['isRegister'])) {
                 //if we're not auto registering, but this is the registration process,
                 //we need to return a valid UserInterface object so that Guard will
                 //pass the authentication and actually continue with the registration process.
                 //This is necessary because we don't allow users that can't authenticate to ldap to register
                 $user = new GenericUser(array("id" => $username));
             }
         }
     }
     return $user;
 }
 public function getIndex($profileId)
 {
     $profile = Profile::where('id', '=', $profileId)->first();
     if ($profile && $profile->isActive == 1) {
         session(['profileId' => $profileId]);
         $vote = Vote::where(['user_id' => Auth::id(), 'profile_id' => $profileId])->first();
         $voted = false;
         if ($vote && $vote->isActive == 1) {
             $voted = true;
         }
         $photos = [];
         if ($profile->photo1 != '') {
             $photos[] = $profile->photo1;
         }
         if ($profile->photo2 != '') {
             $photos[] = $profile->photo2;
         }
         if ($profile->photo3 != '') {
             $photos[] = $profile->photo3;
         }
         if ($profile->photo4 != '') {
             $photos[] = $profile->photo4;
         }
         if ($profile->photo5 != '') {
             $photos[] = $profile->photo5;
         }
         $fb = App::make('SammyK\\LaravelFacebookSdk\\LaravelFacebookSdk');
         $user = User::where('id', '=', $profile->user_id)->first();
         $data = array('selectedPage' => 1, 'profile' => $profile, 'user' => $user, 'fbLink' => $fb->getLoginUrl(['email']), 'votes' => $profile->votes()->where('isActive', '1')->paginate($this->pictures_lazy_load), 'total_votes' => $profile->votes()->where('isActive', '1')->count(), 'voted' => $voted, 'photos' => $photos, 'pageUrl' => env('BASE_FB_URL') . 'profile/index/' . $profile->id);
         return view('profile.index', $data);
     } else {
         echo 'profile not found';
     }
 }
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     //
     $pusher = App::make('pusher');
     $pusher->trigger('test_channel', 'my_event', array('text' => Hash::make('pusher')));
     return view('chat');
 }
 /**
  * Returns an html icon class of the type of
  * notification by retrieving it from the configuration file.
  *
  * @return string|null
  */
 public function getIconAttribute()
 {
     $class = $this->attributes['notifiable_type'];
     /*
      * Resolve the configuration service from the IoC since
      * we don't want to override the Notification models constructor
      * to inject the service
      */
     $config = App::make(ConfigService::class);
     // Make sure we have an instance of the ConfigService returned by the IoC
     if ($config instanceof ConfigService) {
         $icon = $config->setPrefix('maintenance')->get("notifications.icons.{$class}");
         // Return the models notification icon if it's found
         if (is_string($icon) && !empty($icon)) {
             return $icon;
         }
         /*
          * Looks like the notification icon could not be
          * found, we'll return the default notification icon
          */
         $defaultIcon = $config->setPrefix('maintenance')->get('notifications.icons.default');
         return $defaultIcon;
     }
     return;
 }
 public function __construct()
 {
     //$this->beforeFilter(function(){  });
     $this->uriSegment = null;
     $this->modelName = null;
     $this->viewsPath = null;
     $this->resourceId = null;
     if (Route::input('alias') !== null) {
         $this->uriSegment = Route::input('alias');
         $this->viewsPath = File::exists(app_path('views/' . Config::get('reactiveadmin::uri') . '/' . $this->uriSegment)) ? Config::get('reactiveadmin::uri') . '.' . $this->uriSegment : 'reactiveadmin::default';
         $this->modelName = studly_case(str_singular(Route::input('alias')));
         $this->modelWrapper = App::make('model_wrapper');
         $this->modelWrapper->model($this->modelName);
         if (Route::input('id') !== null) {
             $this->resourceId = Route::input('id');
         }
         View::share('config', $this->modelWrapper->getConfig());
         // TODO: refactor this!
         // custom behavior
         switch ($this->uriSegment) {
             case 'settings':
                 View::composer(array('admin.' . $this->viewsPath . '.index'), function ($view) {
                     $view->with('settings', Settings::all());
                 });
                 break;
             default:
                 # code...
                 break;
         }
     }
     View::share('view', $this->uriSegment);
     View::share('model', $this->modelName);
 }
Exemple #30
-2
 /**
  * Controller Auto-Router
  *
  * @param string $controller eg. 'Admin\\UserController'
  * @param array $request_methods eg. array('get', 'post', 'put', 'delete')
  * @param string $prefix eg. admin.users
  * @param array $disallowed eg. array('private_method that starts with one of request methods)
  * @return Closure
  */
 public static function autoRoute($controller, $request_methods, $disallowed = array(), $prefix = '')
 {
     return function () use($controller, $prefix, $disallowed, $request_methods) {
         //get all defined functions
         $methods = get_class_methods(App::make($controller));
         //laravel methods to disallow by default
         $disallowed_methods = array('getBeforeFilters', 'getAfterFilters', 'getFilterer');
         //build list of functions to not allow
         if (is_array($disallowed)) {
             $disallowed_methods = array_merge($disallowed_methods, $disallowed);
         }
         //if there is a index method then lets just bind it and fill the gap in route_names
         if (in_array('getIndex', $methods)) {
             Lara::fillRouteGaps($prefix, $controller . '@getIndex');
         }
         //over all request methods, get, post, etc
         foreach ($request_methods as $type) {
             //filter functions that starts with request method and not in disallowed list
             $actions = array_filter($methods, function ($action) use($type, $disallowed_methods) {
                 return Str::startsWith($action, $type) && !in_array($action, $disallowed_methods);
             });
             foreach ($actions as $action) {
                 $controller_route = $controller . '@' . $action;
                 // Admin\\Controller@get_login
                 $url = Str::snake(str_replace($type, '', $action));
                 // login; snake_case
                 //double check and dont bind to already bound gaps filled index
                 if (in_array($action, $methods) && $action !== 'getIndex') {
                     $route = str_replace('..', '.', $prefix . '.' . Str::snake($action));
                     Route::$type($url, array('as' => $route, 'uses' => $controller_route));
                 }
             }
         }
     };
 }