sentence1
stringlengths
52
3.87M
sentence2
stringlengths
1
47.2k
label
stringclasses
1 value
public function getFieldValue($name) { $value = null; $field = $this->getField($name); if (null !== $this->getField($name)) { $value = (array_key_exists('value', $field) && null !== $field['value']) ? $field['value'] : null; } return $value; }
@param string $name @return mixed|null
entailment
public function getGrantableRolesAllowableValues() { return [ self::GRANTABLE_ROLES_ACCOUNT_TAKE_1, self::GRANTABLE_ROLES_ACCOUNT_TAKE_2, self::GRANTABLE_ROLES_ACCOUNT_TAKE_3, self::GRANTABLE_ROLES_ACCOUNT_TAKE_4, self::GRANTABLE_ROLES_ACCOUNT_TAKE...
Gets allowable values of the enum @return string[]
entailment
public function getRolesAtBaseAllowableValues() { return [ self::ROLES_AT_BASE_ACCOUNT_TAKE_1, self::ROLES_AT_BASE_ACCOUNT_TAKE_2, self::ROLES_AT_BASE_ACCOUNT_TAKE_3, self::ROLES_AT_BASE_ACCOUNT_TAKE_4, self::ROLES_AT_BASE_ACCOUNT_TAKE_5, ...
Gets allowable values of the enum @return string[]
entailment
public function getGrantableRolesAtBaseAllowableValues() { return [ self::GRANTABLE_ROLES_AT_BASE_ACCOUNT_TAKE_1, self::GRANTABLE_ROLES_AT_BASE_ACCOUNT_TAKE_2, self::GRANTABLE_ROLES_AT_BASE_ACCOUNT_TAKE_3, self::GRANTABLE_ROLES_AT_BASE_ACCOUNT_TAKE_4, ...
Gets allowable values of the enum @return string[]
entailment
public function getRolesAtOtherAllowableValues() { return [ self::ROLES_AT_OTHER_ACCOUNT_TAKE_1, self::ROLES_AT_OTHER_ACCOUNT_TAKE_2, self::ROLES_AT_OTHER_ACCOUNT_TAKE_3, self::ROLES_AT_OTHER_ACCOUNT_TAKE_4, self::ROLES_AT_OTHER_ACCOUNT_TAKE_5, ...
Gets allowable values of the enum @return string[]
entailment
public function setRoles($roles) { $allowedValues = $this->getRolesAllowableValues(); if (!is_null($roles) && array_diff($roles, $allowedValues)) { throw new \InvalidArgumentException( sprintf( "Invalid value for 'roles', must be one of '%s'", ...
Sets roles @param string[] $roles roles array @return $this
entailment
public function setGrantableRoles($grantableRoles) { $allowedValues = $this->getGrantableRolesAllowableValues(); if (!is_null($grantableRoles) && array_diff($grantableRoles, $allowedValues)) { throw new \InvalidArgumentException( sprintf( "Invalid valu...
Sets grantableRoles @param string[] $grantableRoles grantable_roles array @return $this
entailment
public function setRolesAtHq($rolesAtHq) { $allowedValues = $this->getRolesAtHqAllowableValues(); if (!is_null($rolesAtHq) && array_diff($rolesAtHq, $allowedValues)) { throw new \InvalidArgumentException( sprintf( "Invalid value for 'rolesAtHq', must b...
Sets rolesAtHq @param string[] $rolesAtHq roles_at_hq array @return $this
entailment
public function setGrantableRolesAtHq($grantableRolesAtHq) { $allowedValues = $this->getGrantableRolesAtHqAllowableValues(); if (!is_null($grantableRolesAtHq) && array_diff($grantableRolesAtHq, $allowedValues)) { throw new \InvalidArgumentException( sprintf( ...
Sets grantableRolesAtHq @param string[] $grantableRolesAtHq grantable_roles_at_hq array @return $this
entailment
public function setRolesAtBase($rolesAtBase) { $allowedValues = $this->getRolesAtBaseAllowableValues(); if (!is_null($rolesAtBase) && array_diff($rolesAtBase, $allowedValues)) { throw new \InvalidArgumentException( sprintf( "Invalid value for 'rolesAtB...
Sets rolesAtBase @param string[] $rolesAtBase roles_at_base array @return $this
entailment
public function setGrantableRolesAtBase($grantableRolesAtBase) { $allowedValues = $this->getGrantableRolesAtBaseAllowableValues(); if (!is_null($grantableRolesAtBase) && array_diff($grantableRolesAtBase, $allowedValues)) { throw new \InvalidArgumentException( sprintf( ...
Sets grantableRolesAtBase @param string[] $grantableRolesAtBase grantable_roles_at_base array @return $this
entailment
public function setRolesAtOther($rolesAtOther) { $allowedValues = $this->getRolesAtOtherAllowableValues(); if (!is_null($rolesAtOther) && array_diff($rolesAtOther, $allowedValues)) { throw new \InvalidArgumentException( sprintf( "Invalid value for 'rol...
Sets rolesAtOther @param string[] $rolesAtOther roles_at_other array @return $this
entailment
public function setGrantableRolesAtOther($grantableRolesAtOther) { $allowedValues = $this->getGrantableRolesAtOtherAllowableValues(); if (!is_null($grantableRolesAtOther) && array_diff($grantableRolesAtOther, $allowedValues)) { throw new \InvalidArgumentException( sprintf...
Sets grantableRolesAtOther @param string[] $grantableRolesAtOther grantable_roles_at_other array @return $this
entailment
public function cacheGroups($num = 1000, $page = 1) { if ($this->cached != null) { return $this->cached; } $this->cached = $this->client->call( 'GET', 'components/groups', [ 'query' => [ 'per_page' => $num, ...
Cache Group for performance improvement. @param int $num @param int $page @return array|bool
entailment
public function indexGroups($num = 1000, $page = 1) { if ($this->cache != false) { return $this->cacheGroups($num, $page); } return $this->client->call( 'GET', 'components/groups', [ 'query' => [ 'per_page' ...
Get a defined number of Groups. @param int $num @param int $page @return array|bool
entailment
public function searchGroups($search, $by, $limit = 1, $num = 1000, $page = 1) { $groups = $this->indexGroups($num, $page)['data']; $filtered = array_filter( $groups, function ($group) use ($search, $by) { if (array_key_exists($by, $group)) { ...
Search if a defined number of Groups exists. @param string $search @param string $by @param int $num @param int $page @param int $limit @return mixed
entailment
protected function shouldPassThrough($request) { $excepts = [ admin_base_path('auth/login'), admin_base_path('auth/logout'), ]; foreach ($excepts as $except) { if ('/' !== $except) { $except = trim($except, '/'); } ...
Determine if the request has a URI that should pass through verification. @param \Illuminate\Http\Request $request @return bool
entailment
public function loadConfiguration(array $configProviders): array { $rawConfig = []; foreach ($configProviders as $configProvider) { $rawConfig = array_replace_recursive($rawConfig, $configProvider->readConfiguration()); } return $this->processor->processConfiguration($th...
@param ConfigProviderInterface[] $configProviders @return array
entailment
protected function setupExporter() { if ($scope = Input::get(Exporter::$queryName)) { $this->model()->usePaginate(false); call_user_func($this->builder, $this); (new Exporter($this))->resolve($this->exporter)->withScope($scope)->export(); } }
Setup grid exporter.
entailment
public function column($name, $label = '') { $relationName = $relationColumn = ''; if (false !== strpos($name, '.')) { list($relationName, $relationColumn) = explode('.', $name); $relation = $this->model()->eloquent()->$relationName(); $label = empty($label) ? ...
Add column to Grid. @param string $name @param string $label @return Column
entailment
protected function addColumn($column = '', $label = '') { $column = new Column($column, $label); $column->setGrid($this); return $this->columns[] = $column; }
Add column to grid. @param string $column @param string $label @return Column
entailment
protected function appendActionsColumn() { if (!$this->option('useActions')) { return; } $grid = $this; $callback = $this->actionsCallback; $column = $this->addColumn('__actions__', trans('admin.action')); $column->display(function ($value) use ($grid, $...
Add `actions` column for grid.
entailment
protected function prependRowSelectorColumn() { if (!$this->option('useRowSelector')) { return; } $grid = $this; $column = new Column(Column::SELECT_COLUMN_NAME, ' '); $column->setGrid($this); $column->display(function ($value) use ($grid, $column) { ...
Prepend checkbox column for grid.
entailment
public function build() { if ($this->builded) { return; } $data = $this->processFilter(); $this->prependRowSelectorColumn(); $this->appendActionsColumn(); Column::setOriginalGridData($data); $this->columns->map(function (Column $column) use (&$...
Build the grid.
entailment
public function exportUrl($scope = 1, $args = null) { $input = array_merge(Input::all(), Exporter::formatExportQuery($scope, $args)); return $this->resource().'?'.http_build_query($input); }
Get the export url. @param int $scope @param null $args @return string
entailment
protected function setDbColumns() { $connection = $this->model()->eloquent()->getConnectionName(); $this->dbColumns = collect(Schema::connection($connection)->getColumnListing($this->model()->getTable())); }
Get the table columns for grid.
entailment
protected function handleTableColumn($method, $label) { if (empty($this->dbColumns)) { $this->setDbColumns(); } if ($this->dbColumns->has($method)) { return $this->addColumn($method, $label); } return false; }
Handle table column for grid. @param string $method @param string $label @return bool|Column
entailment
protected function handleRelationColumn($method, $label) { $model = $this->model()->eloquent(); if (!method_exists($model, $method)) { return false; } if (!($relation = $model->$method()) instanceof Relation) { return false; } if ($relation ...
Handle relation column for grid. @param string $method @param string $label @return bool|Column
entailment
public static function registerColumnDisplayer() { $map = [ 'editable' => \Jblv\Admin\Grid\Displayers\Editable::class, 'switch' => \Jblv\Admin\Grid\Displayers\SwitchDisplay::class, 'switchGroup' => \Jblv\Admin\Grid\Displayers\SwitchGroup::class, 'select' => \J...
Register column displayers.
entailment
public static function add( $type, $control_id, $args ) { $control = static::_control( $type, $control_id, $args ); if ( $control ) { static::$controls[ $control->get_id() ] = $control; } return $control; }
Add Control @param string $type @param string $control_id @param array $args @return Control
entailment
protected static function _control( $type, $control_id, $args ) { $_type = explode( '-', $type ); foreach ( $_type as $key => $value ) { $_type[ $key ] = ucfirst( $value ); } $type = implode( '_', $_type ); $class = '\Inc2734\WP_Customizer_Framework\App\Control\\' . $type; if ( class_exists( $class ) ) {...
Create control @param string $type @param string $control_id @param array $args @see https://developer.wordpress.org/reference/classes/wp_customize_manager/add_control/ @see https://developer.wordpress.org/reference/classes/wp_customize_manager/add_setting/
entailment
public function create() { $roles = $this->roleRepositoryInterface->getAll() ->lists('name', 'slug'); return $this->view('users.create') ->with('roles', $roles); }
Create a new resource. @return Response
entailment
public function edit($id) { if (!$user = $this->userRepositoryInterface->getByIdWith($id, 'roles')) { Flash::error(trans('dashboard::dashboard.errors.user.found')); return redirect()->route('users.index'); } $currentRoles = $user->getRoles() ...
Show the form for editing the specified resource. @param int $id @return Response
entailment
public function delete($id) { try { $this->userRepositoryInterface->delete($id); } catch (UsersException $e) { Flash::error($e->getMessage()); return redirect()->route('users.index'); } Flash::success(trans('dashboard::dashboard.flash.user.delete...
Remove the specified resource from storage. @param int $id @return \Illuminate\Http\RedirectResponse
entailment
protected function prepareValue($key, $record) { $field = $this->fields->first(function (Field $field) use ($key) { return in_array($key, (array) $field->column(), true); }); if (method_exists($field, 'prepare')) { return $field->prepare($record); } ...
Do prepare work for each field. @param string $key @param string $record @return mixed
entailment
public function getTransactionReference() { if (isset($this->data->transaction) && isset($this->data->transaction->trxid)) { return (string) $this->data->transaction->trxid; } return null; }
{@inheritdoc}
entailment
public function getTransactionId() { if (isset($this->data->transaction) && isset($this->data->transaction->purchaseid)) { return (string) $this->data->transaction->purchaseid; } return $this->getEntranceCode(); }
{@inheritdoc}
entailment
public function getIssuerUrl() { if (isset($this->data->transaction) && isset($this->data->transaction->issuerurl)) { return urldecode($this->data->transaction->issuerurl); } return null; }
{@inheritdoc}
entailment
protected function buildNestedArray(array $nodes = [], $parentId = 0) { $branch = []; if (empty($nodes)) { $nodes = $this->allNodes(); } foreach ($nodes as $node) { if ($node[$this->parentColumn] === $parentId) { $children = $this->buildNeste...
Build Nested array. @param array $nodes @param int $parentId @return array
entailment
protected static function setBranchOrder(array $order) { static::$branchOrder = array_flip(array_flatten($order)); static::$branchOrder = array_map(function ($item) { return ++$item; }, static::$branchOrder); }
Set the order of branches in the tree. @param array $order
entailment
public function getModel($model) { if ($model instanceof EloquentModel) { return $model; } if (is_string($model) && class_exists($model)) { return $this->getModel(new $model()); } throw new InvalidArgumentException("$model is not a valid model"); ...
@param $model @return mixed
entailment
public static function css($css = null) { if (!is_null($css)) { self::$css = array_merge(self::$css, (array) $css); return; } $css = array_get(Form::collectFieldAssets(), 'css', []); static::$css = array_merge(static::$css, $css); return view('admi...
Add css or get all css. @param null $css @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View|void
entailment
public function render() { $variables = [ 'items' => $this->items, 'title' => $this->title, 'attributes' => $this->formatAttributes(), ]; return view($this->view, $variables)->render(); }
Render Carousel. @return string
entailment
private function match(TombstoneIndex $tombstoneIndex, VampireIndex $vampireIndex): array { $unmatched = []; /** @var Vampire $vampire */ foreach ($vampireIndex as $vampire) { $relatedTombstone = $this->matchVampireToTombstone($vampire, $tombstoneIndex); if ($related...
@param TombstoneIndex $tombstoneIndex @param VampireIndex $vampireIndex @return Vampire[]
entailment
private function createResult(TombstoneIndex $tombstoneIndex, array $unmatchedVampires): AnalyzerResult { $result = new AnalyzerResult(); $result->setDeleted($unmatchedVampires); foreach ($tombstoneIndex as $tombstone) { if ($tombstone->hasVampires()) { $result->...
@param TombstoneIndex $tombstoneIndex @param Vampire[] $unmatchedVampires @return AnalyzerResult
entailment
protected function uploadAndDeleteOriginal(UploadedFile $file) { $this->renameIfExists($file); $path = $this->storage->putFileAs($this->getDirectory(), $file, $this->name); $this->destroy(); return $path; }
Upload file and delete original file. @param UploadedFile $file @return mixed
entailment
public function render() { $this->setupDefaultOptions(); if (!empty($this->value)) { $this->attribute('data-initial-preview', $this->preview()); $this->attribute('data-initial-caption', $this->initialCaption($this->value)); $this->setupPreviewOptions(); ...
Render file upload field. @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
entailment
public static function formatExportQuery($scope = '', $args = null) { $query = ''; if ($scope === static::SCOPE_ALL) { $query = 'all'; } if ($scope === static::SCOPE_CURRENT_PAGE) { $query = "page:$args"; } if ($scope === static::SCOPE_SELEC...
Format query for export url. @param int $scope @param null $args @return array
entailment
protected function validateBreadcrumb(array $breadcrumb) { foreach ($breadcrumb as $item) { if (!is_array($item) || !array_has($item, 'text')) { throw new \Exception('Breadcrumb format error!'); } } return true; }
Validate content breadcrumb. @param array $breadcrumb @throws \Exception @return bool
entailment
public function withError($title = '', $message = '') { $error = new MessageBag(compact('title', 'message')); session()->flash('error', $error); return $this; }
Set error message for content. @param string $title @param string $message @return $this
entailment
protected function setHttpHeaders() { Yii::$app->getResponse()->getHeaders() ->set('Pragma', 'public') ->set('Expires', '0') ->set('Cache-Control', 'must-revalidate, post-check=0, pre-check=0') ->set('Content-Transfer-Encoding', 'binary') ->set('Co...
Sets the HTTP headers needed by image response.
entailment
protected function getExpression($equation) { if ($this->fixedVerifyCode !== null) { return $this->fixedVerifyCode; } return $equation['first'] ."~". $equation['operator'] ."~". $equation['second'] ."~="; }
Get expresion formula . @param array $equation @return string
entailment
protected function getValue($equation) { if ($this->fixedVerifyCode !== null) { return $this->fixedVerifyCode; } return eval('return '. $equation['first'] . $equation['operator'] . $equation['second'] .';'); }
Get value of formula @param array $equation @return int|float
entailment
public function prepare($files) { if (request()->has(static::FILE_DELETE_FLAG)) { return $this->destroy(request(static::FILE_DELETE_FLAG)); } $targets = array_map([$this, 'prepareForeach'], $files); return array_merge($this->original(), $targets); }
Prepare for saving. @param UploadedFile|array $files @return mixed|string
entailment
public function destroy($key) { $files = $this->original ?: []; $file = array_get($files, $key); if ($this->storage->exists($file)) { $this->storage->delete($file); } unset($files[$key]); return array_values($files); }
Destroy original files. @return string
entailment
public function render() { if ($this->options['enableListButton']) { $this->add($this->listButton()); } if ($this->options['enableBackButton']) { $this->add($this->backButton()); } return $this->tools->map(function ($tool) { if ($tool ins...
Render header tools bar. @return string
entailment
public function render() { if (!$this->grid->usePagination()) { return ''; } return $this->paginationRanger(). $this->paginationLinks(). $this->perPageSelector(); }
Render Paginator. @return string
entailment
protected function callDisplayCallbacks($value, $key) { foreach ($this->displayCallbacks as $callback) { $callback = $this->bindOriginalRow($callback, $key); $value = call_user_func($callback, $value); } return $value; }
Call all of the "display" callbacks column. @param mixed $value @param int $key @return mixed
entailment
protected function bindOriginalRow(Closure $callback, $key) { $originalRow = static::$originalGridData[$key]; return $callback->bindTo(static::$model->newFromBuilder($originalRow)); }
Set original grid data to column. @param Closure $callback @param int $key @return Closure
entailment
public function fill(array $data) { foreach ($data as $key => &$row) { $this->original = $value = array_get($row, $this->name); $value = $this->htmlEntityEncode($value); array_set($row, $this->name, $value); if ($this->isDefinedColumn()) { $...
Fill all data to every column. @param array $data @return mixed
entailment
protected function useDefinedColumn() { // clear all display callbacks. $this->displayCallbacks = []; $class = static::$defined[$this->name]; if ($class instanceof Closure) { $this->display($class); return; } if (!class_exists($class) || !i...
Use a defined column. @throws \Exception
entailment
protected function callBuiltinDisplayer($abstract, $arguments) { if ($abstract instanceof Closure) { return $this->display(function ($value) use ($abstract, $arguments) { return $abstract->call($this, ...array_merge([$value], $arguments)); }); } if (c...
Call Builtin displayer. @param string $abstract @param array $arguments @return Column
entailment
public function isSuccessful() { if (isset($this->data->transaction) && isset($this->data->transaction->status)) { if ((string) $this->data->transaction->status == 'Success') { return true; } } return false; }
{@inheritdoc}
entailment
public function getMessage() { if ($status = $this->getStatus()) { return $status; } elseif (!is_null($this->code)) { return $this->message; } return null; }
{@inheritdoc}
entailment
public function execute(InputInterface $input, OutputInterface $output) { $io = new OutputStyle($input, $output); $composerPath = $this->getComposerPathFromInput($input); $ladder = new Ladder($composerPath); $packages = $ladder->getOutdatedPackages(); $io->newLine(); ...
Execute the command. @param \Symfony\Component\Console\Input\InputInterface $input @param \Symfony\Component\Console\Output\OutputInterface $output @return int
entailment
public function siblings($index = null) { if (!is_null($index)) { return array_get($this->parent->filters(), $index); } return $this->parent->filters(); }
Get siblings of current filter. @param null $index @return AbstractFilter[]|mixed
entailment
public function previous($step = 1) { return $this->siblings( array_search($this, $this->parent->filters(), true) - $step ); }
Get previous filter. @param int $step @return AbstractFilter[]|mixed
entailment
public function next($step = 1) { return $this->siblings( array_search($this, $this->parent->filters(), true) + $step ); }
Get next filter. @param int $step @return AbstractFilter[]|mixed
entailment
public function condition($inputs) { $value = array_get($inputs, $this->column); if (!isset($value)) { return; } $this->value = $value; return $this->buildCondition($this->column, $this->value); }
Get query condition from filter. @param array $inputs @return array|mixed|null
entailment
public function initDatabase() { $this->call('migrate'); if (0 === Administrator::count()) { $this->call('db:seed', ['--class' => \Jblv\Admin\Auth\Database\AdminTablesSeeder::class]); } }
Create tables and seed it.
entailment
protected function initAdminDirectory() { $this->directory = config('admin.directory'); if (is_dir($this->directory)) { $this->line("<error>{$this->directory} directory already exists !</error> "); return; } $this->makeDir('/'); $this->line('<info>A...
Initialize the admin directory.
entailment
public function createAuthController() { $authController = $this->directory.'/Controllers/AuthController.php'; $contents = $this->getStub('AuthController'); $this->laravel['files']->put( $authController, str_replace('DummyNamespace', Admin::controllerNamespace(), $co...
Create AuthController.
entailment
public function createAdministratorController() { $controller = $this->directory.'/Controllers/AdministratorController.php'; $contents = $this->getStub('AdministratorController'); $this->laravel['files']->put( $controller, str_replace('DummyNamespace', Admin::control...
Create AdministratorController.
entailment
protected function createMenuFile() { $file = $this->directory.'/menu.php'; $contents = $this->getStub('menu'); $this->laravel['files']->put($file, $contents); $this->line('<info>Menu file was created:</info> '.str_replace(base_path(), '', $file)); }
Create menu file.
entailment
public function write($path, $contents, Config $config) { $autoRename = $config->get('autoRename', false); $mode = $config->get('mode', 'add'); return $this->upload($path, $contents, ['autorename' => $autoRename, 'mode' => $mode]); }
{@inheritdoc}
entailment
public function writeStream($path, $resource, Config $config) { $chunkSize = $config->get('chunkSize', 8000000); $autoRename = $config->get('autoRename', false); $mode = $config->get('mode', 'add'); return $this->uploadChunked($path, $resource, $chunkSize, ['autorename' => $autoRename, '...
{@inheritdoc}
entailment
public function read($path) { $location = $this->applyPathPrefix($path); try { $file = $this->client->download($location); // returns an object $contents = $file->getContents(); $obj = $file->getMetadata(); // the metadata on file contains the useful response ...
{@inheritdoc}
entailment
public function readStream($path) { $location = $this->applyPathPrefix($path); try { $tmpfile = tmpfile(); $localFile = $this->getStreamUri($tmpfile); $file = $this->client->download($location, $localFile); $obj = $this->normalizeResponse($file->getMetada...
{@inheritdoc}
entailment
public function rename($path, $newpath) { $path = $this->applyPathPrefix($path); $newpath = $this->applyPathPrefix($newpath); try { $this->client->move($path, $newpath); } catch (DropboxClientException $e) { return false; } return true; }
{@inheritdoc}
entailment
public function delete($path) { $location = $this->applyPathPrefix($path); try { $obj = $this->client->delete($location); } catch (DropboxClientException $e) { return false; } return true; }
{@inheritdoc}
entailment
public function createDir($path, Config $config) { $location = $this->applyPathPrefix($path); try { $result = $this->client->createFolder($location); return $this->normalizeResponse($result); } catch (DropboxClientException $e) { return false; } }
{@inheritdoc}
entailment
public function getMetadata($path) { $location = $this->applyPathPrefix($path); try { $file = $this->client->getMetadata($location, ["include_media_info" => true]); return $this->normalizeResponse($file); } catch (DropboxClientException $e) { return false; ...
{@inheritdoc}
entailment
public function listContents($directory = '', $recursive = false) { $listing = []; $directory = trim($directory, '/.'); $location = $this->applyPathPrefix($directory); try { $listFolderContents = $this->client->listFolder($location, ['recursive' => $recursive]); $...
{@inheritdoc}
entailment
protected function normalizeResponse($obj) { $result = ['path' => ltrim($this->removePathPrefix($obj->getPathDisplay()), '/')]; $objClass = get_class($obj); switch ($objClass) { case 'Kunnu\Dropbox\Models\FolderMetadata': $result['type'] = 'dir'; brea...
Normalize a Dropbox File Response. @param object $obj @return array
entailment
protected function upload($path, $contents, $opts = []) { $location = $this->applyPathPrefix($path); try { $tmpfile = tmpfile(); fwrite($tmpfile, $contents); $localFile = $this->getStreamUri($tmpfile); $obj = $this->client->simpleUpload($localFile, $locat...
This function uploads the file to the API using simple upload
entailment
protected function uploadChunked($path, $resource, $chunkSize = 8000000, $opts = []) { $location = $this->applyPathPrefix($path); try { $fileSize = Util::getStreamSize($resource); $localFile = $this->getStreamUri($resource); $file = $this->client->uploadChunked($loca...
This function uploads the file in chunks instead of whole file
entailment
public function handle(Request $request, Closure $next) { if (!$this->auth->check()) { Flash::error(trans('dashboard::dashboard.flash.access_denied')); return redirect()->route('auth.login'); } return $next($request); }
Check if a user is logged in. @param Request $request @param Closure $next @return \Illuminate\Http\RedirectResponse
entailment
public static function error() { $response = response(Admin::content()->withError(trans('admin.deny'))); Pjax::respond($response); }
Send error response page.
entailment
public function handle() { if (!$this->confirmToProceed()) { return; } // Reset all database migrations. $this->call('migrate:reset'); // Setup Filesystem instance. $files = new Filesystem; // Delete published assets from Laravel. $files...
Execute the console command. @return void
entailment
public function edit($id) { if (!$permission = $this->permissionRepositoryInterface->getById($id)) { Flash::error(trans('dashboard::dashboard.errors.permission.found')); return redirect()->route('permissions.index'); } return $this->view('permissions.edit')->with(['...
Show the form for editing the specified resource. @param int $id @return Response
entailment
public function update(Request $request, $id) { try { $this->permissionRepositoryInterface->update($request->all(), $id); } catch (FormValidationException $e) { Flash::error($e->getMessage()); return redirect() ->route('permissions.edit', ['id' => $...
Update the specified resource in storage. @param \Illuminate\Http\Request $request @param int $id @return $this|\Illuminate\Http\RedirectResponse
entailment
public function delete($id) { try { $this->permissionRepositoryInterface->delete($id); } catch (PermissionsException $e) { Flash::error($e->getMessage()); return redirect()->route('permissions.index'); } Flash::success(trans('dashboard::dashboard...
Remove the specified resource from storage. @param int $id @return \Illuminate\Http\RedirectResponse
entailment
public function getByIdWith($id, $type) { return $this->user->with($type) ->where('id', '=', $id) ->first(); }
{@inheritDoc}
entailment
public function create(array $data, $validate = true) { $this->rules = [ 'email' => 'required|unique:users', 'password' => 'required|confirmed', 'password_confirmation' => 'required', ]; if ($validate) { $this->validate(...
{@inheritDoc}
entailment
public function update(array $data, $id, $validate = true) { if (!$user = $this->getById($id)) { throw new UsersException(trans('dashboard::dashboard.errors.user.found')); } if ($user->email != $data['email']) { $this->rules['email'] = 'required|email|unique:users'; ...
{@inheritDoc}
entailment
public function updatePassword(array $data, $validate = true) { $user = $this->auth->authenticate($data); $this->rules = [ 'new_password' => 'required|confirmed', 'new_password_confirmation' => 'required', ]; if ($validate) { $this->vali...
{@inheritDoc}
entailment
public function delete($id) { if (!$user = $this->getById($id)) { throw new UsersException(trans('dashboard::dashboard.errors.user.found')); } $user->delete(); return; }
{@inheritDoc}
entailment
public function handle() { $this->showWelcomeMessage(); $this->userSetup(); $this->triggerPublish(); $this->call('dashboard:fresh'); $this->setupSeedStubs(); $this->triggerMigrations(); $this->createDefaultUser(); $this->info('Setup is complete. Keep c...
Execute the console command. @return mixed
entailment
public function can(string $permission): bool { if ($this->isAdministrator()) { return true; } if ($this->permissions->pluck('slug')->contains($permission)) { return true; } return $this->roles->pluck('permissions')->flatten()->pluck('slug')->contain...
Check if user has permission. @param $permission @return bool
entailment
public function _admin_enqueue_scripts() { $relative_path = '/vendor/inc2734/wp-customizer-framework/src/assets/js/wp-customizer-framework.js'; $src = get_template_directory_uri() . $relative_path; $path = get_template_directory() . $relative_path; wp_enqueue_script( 'inc2734-wp-customizer-framework', $...
Enqueue assets for admin page @return void
entailment