_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q21100
ForgotPasswordController.sendResetLinkResponse
train
protected function sendResetLinkResponse(Request $request, $response) { if ($request->expectsJson()) { return response()->json([ 'status' => trans($response) ]); } return back()->with('status', trans($response)); }
php
{ "resource": "" }
q21101
ControllerRoute.obtainReplacements
train
protected function obtainReplacements() { return [ 'ROUTE_LINK' => $link = $this->getReplacements()[0], 'ROUTE_CONTROLLER' => $this->controller($this->getReplacements()[1]), 'ROUTE_METHOD' => $this->getReplacements()[2], 'ROUTE_NAME' => dot_path($link), ...
php
{ "resource": "" }
q21102
AdminLTE.publicAssets
train
public function publicAssets() { return [ ADMINLTETEMPLATE_PATH.'/public/css' => public_path('css'), ADMINLTETEMPLATE_PATH.'/public/js' => public_path('js'), ADMINLTETEMPLATE_PATH.'/public/fonts' => public_path('fonts'), ...
php
{ "resource": "" }
q21103
AdminLTE.views
train
public function views() { return [ ADMINLTETEMPLATE_PATH.'/resources/views/auth' => resource_path('views/vendor/adminlte/auth'), ADMINLTETEMPLATE_PATH.'/resources/views/errors' => resource_path('views/vendor/adminlte/errors'), ...
php
{ "resource": "" }
q21104
AdminLTE.resourceAssets
train
public function resourceAssets() { return [ ADMINLTETEMPLATE_PATH.'/resources/assets/css' => resource_path('assets/css'), ADMINLTETEMPLATE_PATH.'/resources/assets/img' => resource_path('assets/img'), ADMINLTETEMPLATE_PATH.'/resources/assets/js' => resource_path('assets/...
php
{ "resource": "" }
q21105
Installable.install
train
private function install($files) { foreach ($files as $fileSrc => $fileDst) { if (file_exists($fileDst) && !$this->force && !$this->confirmOverwrite(basename($fileDst))) { return; } if ($this->files->isFile($fileSrc)) { $this->publishFile($...
php
{ "resource": "" }
q21106
MakeV.command
train
protected function command() { $api = $this->option('api') ? ' --api ' : ''; $action = $this->argument('action') ? ' ' . $this->argument('action') . ' ' : ''; return 'php artisan make:route ' . $this->argument('link') . $action . ' --type=' . $this->option('type') . ' --method='...
php
{ "resource": "" }
q21107
Controller.controllerMethod
train
protected function controllerMethod($controllername) { if (str_contains($controller = $controllername, '@')) { return substr($controllername, strpos($controllername, '@')+1, strlen($controllername)); } return 'index'; }
php
{ "resource": "" }
q21108
HasEmail.email
train
protected function email() { if (($email = env('ADMIN_EMAIL', null)) != null) { return $email; } if (($email = git_user_email()) != null) { return $email; } return "admin@example.com"; }
php
{ "resource": "" }
q21109
HasUsername.username
train
public function username() { if (($username = env('ADMIN_USERNAME', null)) != null) { return $username; } if (($username = git_user_name()) != null) { return $username; } return "Admin"; }
php
{ "resource": "" }
q21110
MakeRoute.routeExists
train
protected function routeExists($link) { if ($this->option('api')) { return $this->apiRouteExists($link); } return $this->webRouteExists($link); }
php
{ "resource": "" }
q21111
MakeRoute.webRouteExists
train
protected function webRouteExists($link) { $link = $this->removeTrailingSlashIfExists($link); $link = $this->removeDuplicatedTrailingSlashes($link); foreach (Route::getRoutes() as $value) { if (in_array(strtoupper($this->option('method')), array_merge($value->methods(), ['ANY']))...
php
{ "resource": "" }
q21112
MakeRoute.action
train
protected function action() { if ($this->argument('action') != null) { return $this->argument('action'); } if (strtolower($this->option('type')) != 'regular') { return $this->argument('link') . 'Controller'; } return $this->argument('link'); }
php
{ "resource": "" }
q21113
MakeRoute.validateMethod
train
protected function validateMethod() { if (! in_array(strtoupper($this->option('method')), $methods = array_merge(Router::$verbs, ['ANY']))) { throw new MethodNotAllowedException($methods); } }
php
{ "resource": "" }
q21114
MakeRoute.createMenu
train
protected function createMenu() { try { $this->warnIfSpatieMenuIsNotInstalled(); } catch (\Exception $e) { //Skip installation of menu $this->error($e->getMessage()); return; } Artisan::call('make:menu', [ 'link' => $link = ...
php
{ "resource": "" }
q21115
MakeRoute.createView
train
protected function createView($name = null) { if ($name == null) { $name = $this->action(); } Artisan::call('make:view', [ 'name' => $name ]); $this->info('View ' . undot_path($name) .'.blade.php created.'); }
php
{ "resource": "" }
q21116
MakeRoute.createController
train
protected function createController() { Artisan::call('make:controller', [ 'name' => $controller = $this->controllerWithoutMethod($this->action()) ]); $this->addMethodToController($controller, $this->controllerMethod($this->action())); $this->info('Controller ' . $control...
php
{ "resource": "" }
q21117
MakeRoute.createResourceController
train
protected function createResourceController() { Artisan::call('make:controller', [ 'name' => $controller = $this->controllerWithoutMethod($this->action()), '--resource' => true ]); $this->info('Resource Controller ' . $controller .' created.'); $this->createVi...
php
{ "resource": "" }
q21118
MakeRoute.addMethodToController
train
protected function addMethodToController($controller, $controllerMethod) { $tmpfile = $this->createTmpFileWithMethod($controllerMethod); $path = $this->getPath($tmpfile); add_file_into_file('\/\/', $path, app_path('Http/Controllers/' . $controller . '.php')); }
php
{ "resource": "" }
q21119
MakeRoute.createTmpFileWithMethod
train
protected function createTmpFileWithMethod($controllerMethod) { $temp = tmpfile(); fwrite($temp, $this->getMethodCode($controllerMethod)); return $temp; }
php
{ "resource": "" }
q21120
Route.code
train
public function code() { return $this->compiler->compile( $this->filesystem->get($this->getStubPath()), $this->obtainReplacements() ); }
php
{ "resource": "" }
q21121
Collection.findOne
train
public function findOne($criteria = null, $projection = null) { $items = $this->find($criteria, $projection)->limit(1)->toArray(); return isset($items[0]) ? $items[0]:null; }
php
{ "resource": "" }
q21122
App.service
train
public function service($name, $callable) { $this->registry[$name] = function($c) use($callable) { static $object; if (null === $object) { $object = $callable($c); } return $object; }; return $this; }
php
{ "resource": "" }
q21123
App.baseUrl
train
public function baseUrl($path) { $url = ''; if (\strpos($path, ':')===false) { /* if ($this->registry['base_port'] != '80') { $url .= $this->registry['site_url']; } */ $url .= $this->registry['base_url'].'/'.\ltrim($path, '/...
php
{ "resource": "" }
q21124
App.set
train
public function set($key, $value) { $keys = \explode('/',$key); if (\count($keys)>5) return false; switch (\count($keys)){ case 1: $this->registry[$keys[0]] = $value; break; case 2: $this->registry[$keys[0]][$keys[1]] = $value; ...
php
{ "resource": "" }
q21125
App.path
train
public function path(){ $args = \func_get_args(); switch (\count($args)){ case 1: $file = $args[0]; if ($this->isAbsolutePath($file) && \file_exists($file)) { return $file; } $parts = \explode(':', $fi...
php
{ "resource": "" }
q21126
App.cache
train
public function cache(){ $args = \func_get_args(); switch(\count($args)){ case 1: return $this->helper('cache')->read($args[0]); case 2: return $this->helper('cache')->write($args[0], $args[1]); } return null; }
php
{ "resource": "" }
q21127
App.block
train
public function block($name, $options=[]) { if (!isset($this->blocks[$name])) return null; $options = \array_merge([ 'print' => true ], $options); $block = \implode("\n", $this->blocks[$name]); if ($options['print']){ echo $block; } re...
php
{ "resource": "" }
q21128
App.param
train
public function param($index=null, $default = null, $source = null) { $src = $source ? $source : $_REQUEST; $cast = null; if (\strpos($index, ':') !== false) { list($index, $cast) = \explode(':', $index, 2); } $value = fetch_from_array($src, $index, $default); ...
php
{ "resource": "" }
q21129
App.get
train
public function get($path, $callback, $condition = true){ if (!$this->req_is('get')) return; $this->bind($path, $callback, $condition); }
php
{ "resource": "" }
q21130
App.post
train
public function post($path, $callback, $condition = true){ if (!$this->req_is('post')) return; $this->bind($path, $callback, $condition); }
php
{ "resource": "" }
q21131
App.bindClass
train
public function bindClass($class, $alias = false) { $self = $this; $clean = $alias ? $alias : \trim(\strtolower(\str_replace("\\", "/", $class)), "\\"); $this->bind('/'.$clean.'/*', function() use($self, $class, $clean) { $parts = \explode('/', \trim(\preg_replace("#$clean#"...
php
{ "resource": "" }
q21132
App.bind
train
public function bind($path, $callback, $condition = true) { if (!$condition) return; if (!isset($this->routes[$path])) { $this->routes[$path] = []; } // make $this available in closures if (\is_object($callback) && $callback instanceof \Closure) { $call...
php
{ "resource": "" }
q21133
App.render_route
train
protected function render_route($route, $params = []) { $output = false; if (isset($this->routes[$route])) { $ret = null; if (\is_callable($this->routes[$route])){ $ret = \call_user_func($this->routes[$route], $params); } if (!is_null(...
php
{ "resource": "" }
q21134
App.invoke
train
public function invoke($class, $action="index", $params=[]) { $controller = new $class($this); return \method_exists($controller, $action) && \is_callable([$controller, $action]) ? \call_user_func_array([$controller,$action], $params) : false; }
php
{ "resource": "" }
q21135
App.getClientIp
train
public function getClientIp(){ if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])){ // Use the forwarded IP address, typically set when the // client is using a proxy server. return $_SERVER['HTTP_X_FORWARDED_FOR']; }elseif (isset($_SERVER['HTTP_CLIENT_IP'])){ /...
php
{ "resource": "" }
q21136
Utils.resolveDependencies
train
public function resolveDependencies(array $data) { $new_data = array(); $original_count = \count($data); while (\count($new_data) < $original_count) { foreach ($data as $name => $dependencies) { if (!\count($dependencies)) { $new_data[] = ...
php
{ "resource": "" }
q21137
Utils.url_get_contents
train
public function url_get_contents($url) { $content = ''; if (\function_exists('curl_exec')){ $conn = \curl_init($url); \curl_setopt($conn, CURLOPT_SSL_VERIFYPEER, true); \curl_setopt($conn, CURLOPT_FRESH_CONNECT, true); \curl_setopt($conn, CURLOPT_RETURNTRANSF...
php
{ "resource": "" }
q21138
Utils.isEmail
train
public function isEmail($email) { if (\function_exists('idn_to_ascii')) { $email = @\idn_to_ascii($email); } return (bool) \filter_var($email, FILTER_VALIDATE_EMAIL); }
php
{ "resource": "" }
q21139
Utils.fixStringBooleanValues
train
public function fixStringBooleanValues(&$input) { if (!\is_array($input)) { if (\is_string($input) && ($input === 'true' || $input === 'false')) { $input = filter_var($input, FILTER_VALIDATE_BOOLEAN); } return $input; } foreach ($input as $k => $v) { if (\is...
php
{ "resource": "" }
q21140
Utils.fixStringNumericValues
train
public function fixStringNumericValues(&$input) { if (!\is_array($input)) { if (\is_string($input) && \is_numeric($input)) { $input += 0; } return $input; } foreach ($input as $k => $v) { if (\is_array($input[$k])) { $input[$k] = $this->fixSt...
php
{ "resource": "" }
q21141
Utils.retry
train
public function retry($times, callable $fn) { retrybeginning: try { return $fn(); } catch (\Exception $e) { if (!$times) { throw new \Exception('', 0, $e); } $times--; goto retrybeginning; } }
php
{ "resource": "" }
q21142
Assets.style
train
public function style($assets, $name, $path="", $cache=0, $version=false) { $path = $this->path($path); if(!$path) return null; $href = rtrim($this->pathToUrl($path), '/')."/{$name}.css".($version ? "?ver={$version}":""); $path.= "/{$name}.css"; $tag = '<link href="'.$href.'"...
php
{ "resource": "" }
q21143
Assets.style_and_script
train
public function style_and_script($assets, $name, $path="", $cache=0, $version=false) { echo $this->script($assets, $name, $path, $cache, $version); echo $this->style($assets, $name, $path, $cache, $version); }
php
{ "resource": "" }
q21144
Lexy.compile_default_structures
train
protected function compile_default_structures($value) { $value = preg_replace('/(?(R)\((?:[^\(\)]|(?R))*\)|(?<!\w)(\s*)@(if|foreach|for|while)(\s*(?R)+))/', '$1<?php $2 $3 { ?>', $value); $value = preg_replace('/(\s*)@elseif(\s*\(.*\))/', '$1<?php } elseif$2 { ?>', $value); $value = preg_replac...
php
{ "resource": "" }
q21145
RedisLite.keys
train
public function keys($pattern = null) { $keys = array(); $stmt = $this->connection->query("SELECT `key` FROM ".$this->table." ORDER BY `key`;"); $res = $stmt->fetchAll(\PDO::FETCH_ASSOC); if (!$pattern) { foreach ($res as $record) { $keys[] = $record["key"...
php
{ "resource": "" }
q21146
Database.registerCriteriaFunction
train
public function registerCriteriaFunction($criteria) { $id = \uniqid('criteria'); if (\is_callable($criteria)) { $this->document_criterias[$id] = $criteria; return $id; } if (is_array($criteria)) { $fn = null; eval('$fn = function($docume...
php
{ "resource": "" }
q21147
Database.callCriteriaFunction
train
public function callCriteriaFunction($id, $document) { return isset($this->document_criterias[$id]) ? $this->document_criterias[$id]($document):false; }
php
{ "resource": "" }
q21148
Database.getCollectionNames
train
public function getCollectionNames() { $stmt = $this->connection->query("SELECT name FROM sqlite_master WHERE type='table' AND name!='sqlite_sequence';"); $tables = $stmt->fetchAll( \PDO::FETCH_ASSOC); $names = []; foreach ($tables as $table) { $names[] = $table['name'];...
php
{ "resource": "" }
q21149
Database.listCollections
train
public function listCollections() { foreach ($this->getCollectionNames() as $name) { if(!isset($this->collections[$name])) { $this->collections[$name] = new Collection($name, $this); } } return $this->collections; }
php
{ "resource": "" }
q21150
Cookie.set
train
public function set($name, $value, $ttl = 86400 /* 1 day */, $path = '/', $domain = '', $secure = false, $http_only = false) { $this->_cookies[$name] = $value; $result = \setcookie($name, $value, time() + $ttl, $path, $domain, $secure, $http_only); if (isset($this->_deleted_cookies[$name])) { ...
php
{ "resource": "" }
q21151
Cookie.get
train
public function get($name) { if (isset($this->_deleted_cookies[$name])) { return null; } if (\array_key_exists($name, $this->_cookies)) { return $this->_cookies[$name]; } $value = isset($_COOKIE[$name]) ? $_COOKIE[$name] : null; $this->_cookies[$...
php
{ "resource": "" }
q21152
Cookie.delete
train
public function delete($name, $path = '/', $domain = '', $secure = false, $http_only = false) { $success = $this->set($name, null, -10, $path, $domain, $secure, $http_only); $this->_deleted_cookies[$name] = $name; if (isset($this->_cookies[$name])) { unset($this->_cookies[$name]); ...
php
{ "resource": "" }
q21153
Cookie.getAndDelete
train
public function getAndDelete($name, $path = '/', $domain = '', $secure = false, $http_only = false) { $value = $this->get($name); $this->delete($name, $path, $domain, $secure, $http_only); return $value; }
php
{ "resource": "" }
q21154
Cursor.getData
train
protected function getData() { $sql = ['SELECT document FROM '.$this->collection->name]; if ($this->criteria) { $sql[] = 'WHERE document_criteria("'.$this->criteria.'", document)'; } if ($this->sort) { $orders = []; foreach ($this->sort as $field...
php
{ "resource": "" }
q21155
I18n.get
train
public function get($key, $alternative=null, $lang=null){ if (!$lang) { $lang = $this->locale; } if (!$alternative){ $alternative = $key; } return isset($this->_languages[$lang][$key]) ? $this->_languages[$lang][$key]:$alternative; }
php
{ "resource": "" }
q21156
I18n.getstr
train
public function getstr($key, $params=[], $alternative=null, $lang=null){ if (!$lang) { $lang = $this->locale; } if (!$alternative){ $alternative = $key; } return \vsprintf(isset($this->_languages[$lang][$key]) ? $this->_languages[$lang][$key]:$alternati...
php
{ "resource": "" }
q21157
I18n.load
train
public function load($langfile, $lang=null) { if (!$lang) { $lang = $this->locale; } if ($path = $this->app->path($langfile)){ if (!isset($this->_languages[$lang])){ $this->_languages[$lang] = []; } $langtable = include($path); ...
php
{ "resource": "" }
q21158
I18n.data
train
public function data($lang=null) { if ($lang) { return isset($this->_languages[$lang]) ? $this->_languages[$lang] : []; } return $this->_languages; }
php
{ "resource": "" }
q21159
Client.hincrby
train
public function hincrby($collection, $key, $field, $by = 1) { $current = $this->hget($collection, $key, $field, 0); $newone = $current+$by; $this->hset($collection, $key, $field, $newone); return $newone; }
php
{ "resource": "" }
q21160
Client.hmget
train
public function hmget($key) { $set = $this->getKey($collection, $key, []); $fields = func_get_args(); $values = []; for ($i=1; $i<count($fields); $i++){ $field = $fields[$i]; $values[] = isset($set[$field]) ? $set[$field]:null; } return $v...
php
{ "resource": "" }
q21161
ContainerArray.offsetSet
train
public function offsetSet($key, $value) { if (strpos($key, '/')) { $keys = explode('/', $key); $mem = $this->props; foreach($keys as $keyname) { if (!isset($mem[$keyname])) { $mem[$keyname] = new ArrayObject([]); } ...
php
{ "resource": "" }
q21162
TokenRepository.findForUser
train
public function findForUser($id, $userId) { return Passport::token()->where('id', $id)->where('user_id', $userId)->first(); }
php
{ "resource": "" }
q21163
TokenRepository.findValidToken
train
public function findValidToken($user, $client) { return $client->tokens() ->whereUserId($user->getKey()) ->where('revoked', 0) ->where('expires_at', '>', Carbon::now()) ->latest('expires_at') ->firs...
php
{ "resource": "" }
q21164
ClientCommand.createClientCredentialsClient
train
protected function createClientCredentialsClient(ClientRepository $clients) { $name = $this->option('name') ?: $this->ask( 'What should we name the client?', config('app.name').' ClientCredentials Grant Client' ); $client = $clients->create( null, $name, ...
php
{ "resource": "" }
q21165
ClientCommand.outputClientDetails
train
protected function outputClientDetails(Client $client) { $this->line('<comment>Client ID:</comment> '.$client->id); $this->line('<comment>Client secret:</comment> '.$client->secret); }
php
{ "resource": "" }
q21166
ApiTokenCookieFactory.make
train
public function make($userId, $csrfToken) { $config = $this->config->get('session'); $expiration = Carbon::now()->addMinutes($config['lifetime']); return new Cookie( Passport::cookie(), $this->createToken($userId, $csrfToken, $expiration), $expiration, ...
php
{ "resource": "" }
q21167
ApiTokenCookieFactory.createToken
train
protected function createToken($userId, $csrfToken, Carbon $expiration) { return JWT::encode([ 'sub' => $userId, 'csrf' => $csrfToken, 'expiry' => $expiration->getTimestamp(), ], $this->encrypter->getKey()); }
php
{ "resource": "" }
q21168
PersonalAccessTokenFactory.make
train
public function make($userId, $name, array $scopes = []) { $response = $this->dispatchRequestToAuthorizationServer( $this->createRequest($this->clients->personalAccessClient(), $userId, $scopes) ); $token = tap($this->findAccessToken($response), function ($token) use ($userId, $...
php
{ "resource": "" }
q21169
PersonalAccessTokenFactory.dispatchRequestToAuthorizationServer
train
protected function dispatchRequestToAuthorizationServer(ServerRequest $request) { return json_decode($this->server->respondToAccessTokenRequest( $request, new Response )->getBody()->__toString(), true); }
php
{ "resource": "" }
q21170
PersonalAccessTokenFactory.findAccessToken
train
protected function findAccessToken(array $response) { return $this->tokens->find( $this->jwt->parse($response['access_token'])->getClaim('jti') ); }
php
{ "resource": "" }
q21171
TransientTokenController.refresh
train
public function refresh(Request $request) { return (new Response('Refreshed.'))->withCookie($this->cookieFactory->make( $request->user()->getKey(), $request->session()->token() )); }
php
{ "resource": "" }
q21172
RetrievesAuthRequestFromSession.getAuthRequestFromSession
train
protected function getAuthRequestFromSession(Request $request) { return tap($request->session()->get('authRequest'), function ($authRequest) use ($request) { if (! $authRequest) { throw new Exception('Authorization request was not present in the session.'); } ...
php
{ "resource": "" }
q21173
PassportServiceProvider.registerAuthorizationServer
train
protected function registerAuthorizationServer() { $this->app->singleton(AuthorizationServer::class, function () { return tap($this->makeAuthorizationServer(), function ($server) { $server->setDefaultScope(Passport::$defaultScope); $server->enableGrantType( ...
php
{ "resource": "" }
q21174
PassportServiceProvider.buildAuthCodeGrant
train
protected function buildAuthCodeGrant() { return new AuthCodeGrant( $this->app->make(Bridge\AuthCodeRepository::class), $this->app->make(Bridge\RefreshTokenRepository::class), new DateInterval('PT10M') ); }
php
{ "resource": "" }
q21175
PassportServiceProvider.makeRefreshTokenGrant
train
protected function makeRefreshTokenGrant() { $repository = $this->app->make(RefreshTokenRepository::class); return tap(new RefreshTokenGrant($repository), function ($grant) { $grant->setRefreshTokenTTL(Passport::refreshTokensExpireIn()); }); }
php
{ "resource": "" }
q21176
PassportServiceProvider.makeCryptKey
train
protected function makeCryptKey($type) { $key = str_replace('\\n', "\n", $this->app->make(Config::class)->get('passport.'.$type.'_key')); if (! $key) { $key = 'file://'.Passport::keyPath('oauth-'.$type.'.key'); } return new CryptKey($key, null, false); }
php
{ "resource": "" }
q21177
PassportServiceProvider.registerGuard
train
protected function registerGuard() { Auth::extend('passport', function ($app, $name, array $config) { return tap($this->makeGuard($config), function ($guard) { $this->app->refresh('request', $guard, 'setRequest'); }); }); }
php
{ "resource": "" }
q21178
PassportServiceProvider.makeGuard
train
protected function makeGuard(array $config) { return new RequestGuard(function ($request) use ($config) { return (new TokenGuard( $this->app->make(ResourceServer::class), Auth::createUserProvider($config['provider']), $this->app->make(TokenReposito...
php
{ "resource": "" }
q21179
PassportServiceProvider.deleteCookieOnLogout
train
protected function deleteCookieOnLogout() { Event::listen(Logout::class, function () { if (Request::hasCookie(Passport::cookie())) { Cookie::queue(Cookie::forget(Passport::cookie())); } }); }
php
{ "resource": "" }
q21180
AuthorizedAccessTokenController.forUser
train
public function forUser(Request $request) { $tokens = $this->tokenRepository->forUser($request->user()->getKey()); return $tokens->load('client')->filter(function ($token) { return ! $token->client->firstParty() && ! $token->revoked; })->values(); }
php
{ "resource": "" }
q21181
AuthorizedAccessTokenController.destroy
train
public function destroy(Request $request, $tokenId) { $token = $this->tokenRepository->findForUser( $tokenId, $request->user()->getKey() ); if (is_null($token)) { return new Response('', 404); } $token->revoke(); return new Response('', Resp...
php
{ "resource": "" }
q21182
TokenGuard.user
train
public function user(Request $request) { if ($request->bearerToken()) { return $this->authenticateViaBearerToken($request); } elseif ($request->cookie(Passport::cookie())) { return $this->authenticateViaCookie($request); } }
php
{ "resource": "" }
q21183
TokenGuard.client
train
public function client(Request $request) { if ($request->bearerToken()) { if (! $psr = $this->getPsrRequestViaBearerToken($request)) { return; } return $this->clients->findActive( $psr->getAttribute('oauth_client_id') ); ...
php
{ "resource": "" }
q21184
TokenGuard.getPsrRequestViaBearerToken
train
protected function getPsrRequestViaBearerToken($request) { // First, we will convert the Symfony request to a PSR-7 implementation which will // be compatible with the base OAuth2 library. The Symfony bridge can perform a // conversion for us to a Zend Diactoros implementation of the PSR-7 r...
php
{ "resource": "" }
q21185
TokenGuard.getTokenViaCookie
train
protected function getTokenViaCookie($request) { // If we need to retrieve the token from the cookie, it'll be encrypted so we must // first decrypt the cookie and then attempt to find the token value within the // database. If we can't decrypt the value we'll bail out with a null return. ...
php
{ "resource": "" }
q21186
ClientRepository.find
train
public function find($id) { $client = Passport::client(); return $client->where($client->getKeyName(), $id)->first(); }
php
{ "resource": "" }
q21187
ClientRepository.findActive
train
public function findActive($id) { $client = $this->find($id); return $client && ! $client->revoked ? $client : null; }
php
{ "resource": "" }
q21188
ClientRepository.findForUser
train
public function findForUser($clientId, $userId) { $client = Passport::client(); return $client ->where($client->getKeyName(), $clientId) ->where('user_id', $userId) ->first(); }
php
{ "resource": "" }
q21189
ClientRepository.activeForUser
train
public function activeForUser($userId) { return $this->forUser($userId)->reject(function ($client) { return $client->revoked; })->values(); }
php
{ "resource": "" }
q21190
ClientRepository.createPasswordGrantClient
train
public function createPasswordGrantClient($userId, $name, $redirect) { return $this->create($userId, $name, $redirect, false, true); }
php
{ "resource": "" }
q21191
ClientRepository.revoked
train
public function revoked($id) { $client = $this->find($id); return is_null($client) || $client->revoked; }
php
{ "resource": "" }
q21192
ClientController.forUser
train
public function forUser(Request $request) { $userId = $request->user()->getKey(); return $this->clients->activeForUser($userId)->makeVisible('secret'); }
php
{ "resource": "" }
q21193
Token.can
train
public function can($scope) { return in_array('*', $this->scopes) || array_key_exists($scope, array_flip($this->scopes)); }
php
{ "resource": "" }
q21194
RouteRegistrar.all
train
public function all() { $this->forAuthorization(); $this->forAccessTokens(); $this->forTransientTokens(); $this->forClients(); $this->forPersonalAccessTokens(); }
php
{ "resource": "" }
q21195
AuthorizationController.parseScopes
train
protected function parseScopes($authRequest) { return Passport::scopesFor( collect($authRequest->getScopes())->map(function ($scope) { return $scope->getIdentifier(); })->unique()->all() ); }
php
{ "resource": "" }
q21196
CreateFreshApiToken.alreadyContainsToken
train
protected function alreadyContainsToken($response) { foreach ($response->headers->getCookies() as $cookie) { if ($cookie->getName() === Passport::cookie()) { return true; } } return false; }
php
{ "resource": "" }
q21197
Passport.scopes
train
public static function scopes() { return collect(static::$scopes)->map(function ($description, $id) { return new Scope($id, $description); })->values(); }
php
{ "resource": "" }
q21198
Passport.refreshTokensExpireIn
train
public static function refreshTokensExpireIn(DateTimeInterface $date = null) { if (is_null($date)) { return static::$refreshTokensExpireAt ? Carbon::now()->diff(static::$refreshTokensExpireAt) : new DateInterval('P1Y'); } s...
php
{ "resource": "" }
q21199
Passport.personalAccessTokensExpireIn
train
public static function personalAccessTokensExpireIn(DateTimeInterface $date = null) { if (is_null($date)) { return static::$personalAccessTokensExpireAt ? Carbon::now()->diff(static::$personalAccessTokensExpireAt) : new DateInterval('P1Y'); } stat...
php
{ "resource": "" }