id
int32 0
241k
| repo
stringlengths 6
63
| path
stringlengths 5
140
| func_name
stringlengths 3
151
| original_string
stringlengths 84
13k
| language
stringclasses 1
value | code
stringlengths 84
13k
| code_tokens
list | docstring
stringlengths 3
47.2k
| docstring_tokens
list | sha
stringlengths 40
40
| url
stringlengths 91
247
|
|---|---|---|---|---|---|---|---|---|---|---|---|
220,900
|
CachetHQ/Cachet
|
app/Bus/Handlers/Commands/IncidentUpdate/UpdateIncidentUpdateCommandHandler.php
|
UpdateIncidentUpdateCommandHandler.handle
|
public function handle(UpdateIncidentUpdateCommand $command)
{
$command->update->update($this->filter($command));
event(new IncidentUpdateWasUpdatedEvent($this->auth->user(), $command->update));
return $command->update;
}
|
php
|
public function handle(UpdateIncidentUpdateCommand $command)
{
$command->update->update($this->filter($command));
event(new IncidentUpdateWasUpdatedEvent($this->auth->user(), $command->update));
return $command->update;
}
|
[
"public",
"function",
"handle",
"(",
"UpdateIncidentUpdateCommand",
"$",
"command",
")",
"{",
"$",
"command",
"->",
"update",
"->",
"update",
"(",
"$",
"this",
"->",
"filter",
"(",
"$",
"command",
")",
")",
";",
"event",
"(",
"new",
"IncidentUpdateWasUpdatedEvent",
"(",
"$",
"this",
"->",
"auth",
"->",
"user",
"(",
")",
",",
"$",
"command",
"->",
"update",
")",
")",
";",
"return",
"$",
"command",
"->",
"update",
";",
"}"
] |
Handle the update incident update command.
@param \CachetHQ\Cachet\Bus\Commands\IncidentUpdate\UpdateIncidentUpdateCommand $command
@return \CachetHQ\Cachet\Models\IncidentUpdate
|
[
"Handle",
"the",
"update",
"incident",
"update",
"command",
"."
] |
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
|
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Bus/Handlers/Commands/IncidentUpdate/UpdateIncidentUpdateCommandHandler.php#L51-L58
|
220,901
|
CachetHQ/Cachet
|
app/Bus/Handlers/Commands/Subscriber/UnsubscribeSubscriptionCommandHandler.php
|
UnsubscribeSubscriptionCommandHandler.handle
|
public function handle(UnsubscribeSubscriptionCommand $command)
{
$subscription = $command->subscription;
event(new SubscriberHasUnsubscribedEvent($subscription->subscriber));
$subscription->delete();
}
|
php
|
public function handle(UnsubscribeSubscriptionCommand $command)
{
$subscription = $command->subscription;
event(new SubscriberHasUnsubscribedEvent($subscription->subscriber));
$subscription->delete();
}
|
[
"public",
"function",
"handle",
"(",
"UnsubscribeSubscriptionCommand",
"$",
"command",
")",
"{",
"$",
"subscription",
"=",
"$",
"command",
"->",
"subscription",
";",
"event",
"(",
"new",
"SubscriberHasUnsubscribedEvent",
"(",
"$",
"subscription",
"->",
"subscriber",
")",
")",
";",
"$",
"subscription",
"->",
"delete",
"(",
")",
";",
"}"
] |
Handle the unsubscribe subscription command.
@param \CachetHQ\Cachet\Bus\Commands\Subscriber\UnsubscribeSubscriptionCommand $command
@return void
|
[
"Handle",
"the",
"unsubscribe",
"subscription",
"command",
"."
] |
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
|
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Bus/Handlers/Commands/Subscriber/UnsubscribeSubscriptionCommandHandler.php#L27-L34
|
220,902
|
CachetHQ/Cachet
|
app/Http/Controllers/Dashboard/UserController.php
|
UserController.postUser
|
public function postUser()
{
$userData = array_filter(Binput::only(['username', 'email', 'password', 'google2fa']));
$enable2FA = (bool) Arr::pull($userData, 'google2fa');
// Let's enable/disable auth
if ($enable2FA && !Auth::user()->hasTwoFactor) {
event(new UserEnabledTwoAuthEvent(Auth::user()));
$userData['google_2fa_secret'] = Google2FA::generateSecretKey();
} elseif (!$enable2FA) {
event(new UserDisabledTwoAuthEvent(Auth::user()));
$userData['google_2fa_secret'] = '';
}
try {
Auth::user()->update($userData);
} catch (ValidationException $e) {
return cachet_redirect('dashboard.user')
->withInput($userData)
->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.team.edit.failure')))
->withErrors($e->getMessageBag());
}
return cachet_redirect('dashboard.user')
->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.team.edit.success')));
}
|
php
|
public function postUser()
{
$userData = array_filter(Binput::only(['username', 'email', 'password', 'google2fa']));
$enable2FA = (bool) Arr::pull($userData, 'google2fa');
// Let's enable/disable auth
if ($enable2FA && !Auth::user()->hasTwoFactor) {
event(new UserEnabledTwoAuthEvent(Auth::user()));
$userData['google_2fa_secret'] = Google2FA::generateSecretKey();
} elseif (!$enable2FA) {
event(new UserDisabledTwoAuthEvent(Auth::user()));
$userData['google_2fa_secret'] = '';
}
try {
Auth::user()->update($userData);
} catch (ValidationException $e) {
return cachet_redirect('dashboard.user')
->withInput($userData)
->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.team.edit.failure')))
->withErrors($e->getMessageBag());
}
return cachet_redirect('dashboard.user')
->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.team.edit.success')));
}
|
[
"public",
"function",
"postUser",
"(",
")",
"{",
"$",
"userData",
"=",
"array_filter",
"(",
"Binput",
"::",
"only",
"(",
"[",
"'username'",
",",
"'email'",
",",
"'password'",
",",
"'google2fa'",
"]",
")",
")",
";",
"$",
"enable2FA",
"=",
"(",
"bool",
")",
"Arr",
"::",
"pull",
"(",
"$",
"userData",
",",
"'google2fa'",
")",
";",
"// Let's enable/disable auth",
"if",
"(",
"$",
"enable2FA",
"&&",
"!",
"Auth",
"::",
"user",
"(",
")",
"->",
"hasTwoFactor",
")",
"{",
"event",
"(",
"new",
"UserEnabledTwoAuthEvent",
"(",
"Auth",
"::",
"user",
"(",
")",
")",
")",
";",
"$",
"userData",
"[",
"'google_2fa_secret'",
"]",
"=",
"Google2FA",
"::",
"generateSecretKey",
"(",
")",
";",
"}",
"elseif",
"(",
"!",
"$",
"enable2FA",
")",
"{",
"event",
"(",
"new",
"UserDisabledTwoAuthEvent",
"(",
"Auth",
"::",
"user",
"(",
")",
")",
")",
";",
"$",
"userData",
"[",
"'google_2fa_secret'",
"]",
"=",
"''",
";",
"}",
"try",
"{",
"Auth",
"::",
"user",
"(",
")",
"->",
"update",
"(",
"$",
"userData",
")",
";",
"}",
"catch",
"(",
"ValidationException",
"$",
"e",
")",
"{",
"return",
"cachet_redirect",
"(",
"'dashboard.user'",
")",
"->",
"withInput",
"(",
"$",
"userData",
")",
"->",
"withTitle",
"(",
"sprintf",
"(",
"'%s %s'",
",",
"trans",
"(",
"'dashboard.notifications.whoops'",
")",
",",
"trans",
"(",
"'dashboard.team.edit.failure'",
")",
")",
")",
"->",
"withErrors",
"(",
"$",
"e",
"->",
"getMessageBag",
"(",
")",
")",
";",
"}",
"return",
"cachet_redirect",
"(",
"'dashboard.user'",
")",
"->",
"withSuccess",
"(",
"sprintf",
"(",
"'%s %s'",
",",
"trans",
"(",
"'dashboard.notifications.awesome'",
")",
",",
"trans",
"(",
"'dashboard.team.edit.success'",
")",
")",
")",
";",
"}"
] |
Updates the current user.
@return \Illuminate\View\View
|
[
"Updates",
"the",
"current",
"user",
"."
] |
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
|
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Http/Controllers/Dashboard/UserController.php#L44-L70
|
220,903
|
CachetHQ/Cachet
|
app/Http/Controllers/Dashboard/UserController.php
|
UserController.regenerateApiKey
|
public function regenerateApiKey(User $user)
{
$user->api_key = User::generateApiKey();
$user->save();
event(new UserRegeneratedApiTokenEvent($user));
return cachet_redirect('dashboard.user');
}
|
php
|
public function regenerateApiKey(User $user)
{
$user->api_key = User::generateApiKey();
$user->save();
event(new UserRegeneratedApiTokenEvent($user));
return cachet_redirect('dashboard.user');
}
|
[
"public",
"function",
"regenerateApiKey",
"(",
"User",
"$",
"user",
")",
"{",
"$",
"user",
"->",
"api_key",
"=",
"User",
"::",
"generateApiKey",
"(",
")",
";",
"$",
"user",
"->",
"save",
"(",
")",
";",
"event",
"(",
"new",
"UserRegeneratedApiTokenEvent",
"(",
"$",
"user",
")",
")",
";",
"return",
"cachet_redirect",
"(",
"'dashboard.user'",
")",
";",
"}"
] |
Regenerates the users API key.
@param \CachetHQ\Cachet\Models\User $user
@return \Illuminate\View\View
|
[
"Regenerates",
"the",
"users",
"API",
"key",
"."
] |
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
|
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Http/Controllers/Dashboard/UserController.php#L79-L87
|
220,904
|
CachetHQ/Cachet
|
app/Http/Controllers/SignupController.php
|
SignupController.getSignup
|
public function getSignup($code = null)
{
if ($code === null) {
throw new NotFoundHttpException();
}
$invite = Invite::where('code', '=', $code)->first();
if (!$invite || $invite->is_claimed) {
throw new BadRequestHttpException();
}
return View::make('signup')
->withCode($invite->code)
->withUsername(Binput::old('username'))
->withEmail(Binput::old('email', $invite->email));
}
|
php
|
public function getSignup($code = null)
{
if ($code === null) {
throw new NotFoundHttpException();
}
$invite = Invite::where('code', '=', $code)->first();
if (!$invite || $invite->is_claimed) {
throw new BadRequestHttpException();
}
return View::make('signup')
->withCode($invite->code)
->withUsername(Binput::old('username'))
->withEmail(Binput::old('email', $invite->email));
}
|
[
"public",
"function",
"getSignup",
"(",
"$",
"code",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"code",
"===",
"null",
")",
"{",
"throw",
"new",
"NotFoundHttpException",
"(",
")",
";",
"}",
"$",
"invite",
"=",
"Invite",
"::",
"where",
"(",
"'code'",
",",
"'='",
",",
"$",
"code",
")",
"->",
"first",
"(",
")",
";",
"if",
"(",
"!",
"$",
"invite",
"||",
"$",
"invite",
"->",
"is_claimed",
")",
"{",
"throw",
"new",
"BadRequestHttpException",
"(",
")",
";",
"}",
"return",
"View",
"::",
"make",
"(",
"'signup'",
")",
"->",
"withCode",
"(",
"$",
"invite",
"->",
"code",
")",
"->",
"withUsername",
"(",
"Binput",
"::",
"old",
"(",
"'username'",
")",
")",
"->",
"withEmail",
"(",
"Binput",
"::",
"old",
"(",
"'email'",
",",
"$",
"invite",
"->",
"email",
")",
")",
";",
"}"
] |
Handle the signup with invite.
@param string|null $code
@return \Illuminate\View\View
|
[
"Handle",
"the",
"signup",
"with",
"invite",
"."
] |
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
|
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Http/Controllers/SignupController.php#L34-L50
|
220,905
|
CachetHQ/Cachet
|
app/Http/Controllers/SignupController.php
|
SignupController.postSignup
|
public function postSignup($code = null)
{
if ($code === null) {
throw new NotFoundHttpException();
}
$invite = Invite::where('code', '=', $code)->first();
if (!$invite || $invite->is_claimed) {
throw new BadRequestHttpException();
}
try {
execute(new SignupUserCommand(
Binput::get('username'),
Binput::get('password'),
Binput::get('email'),
User::LEVEL_USER
));
} catch (ValidationException $e) {
return cachet_redirect('signup.invite', [$invite->code])
->withInput(Binput::except('password'))
->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('cachet.signup.failure')))
->withErrors($e->getMessageBag());
}
execute(new ClaimInviteCommand($invite));
return cachet_redirect('status-page')
->withSuccess(sprintf('<strong>%s</strong> %s', trans('dashboard.notifications.awesome'), trans('cachet.signup.success')));
}
|
php
|
public function postSignup($code = null)
{
if ($code === null) {
throw new NotFoundHttpException();
}
$invite = Invite::where('code', '=', $code)->first();
if (!$invite || $invite->is_claimed) {
throw new BadRequestHttpException();
}
try {
execute(new SignupUserCommand(
Binput::get('username'),
Binput::get('password'),
Binput::get('email'),
User::LEVEL_USER
));
} catch (ValidationException $e) {
return cachet_redirect('signup.invite', [$invite->code])
->withInput(Binput::except('password'))
->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('cachet.signup.failure')))
->withErrors($e->getMessageBag());
}
execute(new ClaimInviteCommand($invite));
return cachet_redirect('status-page')
->withSuccess(sprintf('<strong>%s</strong> %s', trans('dashboard.notifications.awesome'), trans('cachet.signup.success')));
}
|
[
"public",
"function",
"postSignup",
"(",
"$",
"code",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"code",
"===",
"null",
")",
"{",
"throw",
"new",
"NotFoundHttpException",
"(",
")",
";",
"}",
"$",
"invite",
"=",
"Invite",
"::",
"where",
"(",
"'code'",
",",
"'='",
",",
"$",
"code",
")",
"->",
"first",
"(",
")",
";",
"if",
"(",
"!",
"$",
"invite",
"||",
"$",
"invite",
"->",
"is_claimed",
")",
"{",
"throw",
"new",
"BadRequestHttpException",
"(",
")",
";",
"}",
"try",
"{",
"execute",
"(",
"new",
"SignupUserCommand",
"(",
"Binput",
"::",
"get",
"(",
"'username'",
")",
",",
"Binput",
"::",
"get",
"(",
"'password'",
")",
",",
"Binput",
"::",
"get",
"(",
"'email'",
")",
",",
"User",
"::",
"LEVEL_USER",
")",
")",
";",
"}",
"catch",
"(",
"ValidationException",
"$",
"e",
")",
"{",
"return",
"cachet_redirect",
"(",
"'signup.invite'",
",",
"[",
"$",
"invite",
"->",
"code",
"]",
")",
"->",
"withInput",
"(",
"Binput",
"::",
"except",
"(",
"'password'",
")",
")",
"->",
"withTitle",
"(",
"sprintf",
"(",
"'%s %s'",
",",
"trans",
"(",
"'dashboard.notifications.whoops'",
")",
",",
"trans",
"(",
"'cachet.signup.failure'",
")",
")",
")",
"->",
"withErrors",
"(",
"$",
"e",
"->",
"getMessageBag",
"(",
")",
")",
";",
"}",
"execute",
"(",
"new",
"ClaimInviteCommand",
"(",
"$",
"invite",
")",
")",
";",
"return",
"cachet_redirect",
"(",
"'status-page'",
")",
"->",
"withSuccess",
"(",
"sprintf",
"(",
"'<strong>%s</strong> %s'",
",",
"trans",
"(",
"'dashboard.notifications.awesome'",
")",
",",
"trans",
"(",
"'cachet.signup.success'",
")",
")",
")",
";",
"}"
] |
Handle a signup request.
@param string|null $code
@return \Illuminate\View\View
|
[
"Handle",
"a",
"signup",
"request",
"."
] |
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
|
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Http/Controllers/SignupController.php#L59-L89
|
220,906
|
CachetHQ/Cachet
|
app/Http/Controllers/Api/SubscriberController.php
|
SubscriberController.index
|
public function index()
{
$subscribers = Subscriber::paginate(Binput::get('per_page', 20));
return $this->paginator($subscribers, Request::instance());
}
|
php
|
public function index()
{
$subscribers = Subscriber::paginate(Binput::get('per_page', 20));
return $this->paginator($subscribers, Request::instance());
}
|
[
"public",
"function",
"index",
"(",
")",
"{",
"$",
"subscribers",
"=",
"Subscriber",
"::",
"paginate",
"(",
"Binput",
"::",
"get",
"(",
"'per_page'",
",",
"20",
")",
")",
";",
"return",
"$",
"this",
"->",
"paginator",
"(",
"$",
"subscribers",
",",
"Request",
"::",
"instance",
"(",
")",
")",
";",
"}"
] |
Get all subscribers.
@return \Illuminate\Http\JsonResponse
|
[
"Get",
"all",
"subscribers",
"."
] |
ae35e1f9d0ce643ca2dbc544fa4172861ee56288
|
https://github.com/CachetHQ/Cachet/blob/ae35e1f9d0ce643ca2dbc544fa4172861ee56288/app/Http/Controllers/Api/SubscriberController.php#L36-L41
|
220,907
|
tymondesigns/jwt-auth
|
src/Http/Parser/RouteParams.php
|
RouteParams.parse
|
public function parse(Request $request)
{
$route = $request->route();
// Route may not be an instance of Illuminate\Routing\Route
// (it's an array in Lumen <5.2) or not exist at all
// (if the request was never dispatched)
if (is_callable([$route, 'parameter'])) {
return $route->parameter($this->key);
}
}
|
php
|
public function parse(Request $request)
{
$route = $request->route();
// Route may not be an instance of Illuminate\Routing\Route
// (it's an array in Lumen <5.2) or not exist at all
// (if the request was never dispatched)
if (is_callable([$route, 'parameter'])) {
return $route->parameter($this->key);
}
}
|
[
"public",
"function",
"parse",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"route",
"=",
"$",
"request",
"->",
"route",
"(",
")",
";",
"// Route may not be an instance of Illuminate\\Routing\\Route",
"// (it's an array in Lumen <5.2) or not exist at all",
"// (if the request was never dispatched)",
"if",
"(",
"is_callable",
"(",
"[",
"$",
"route",
",",
"'parameter'",
"]",
")",
")",
"{",
"return",
"$",
"route",
"->",
"parameter",
"(",
"$",
"this",
"->",
"key",
")",
";",
"}",
"}"
] |
Try to get the token from the route parameters.
@param \Illuminate\Http\Request $request
@return null|string
|
[
"Try",
"to",
"get",
"the",
"token",
"from",
"the",
"route",
"parameters",
"."
] |
63698d304554e5d0bc3eb481cc260a9fc900e151
|
https://github.com/tymondesigns/jwt-auth/blob/63698d304554e5d0bc3eb481cc260a9fc900e151/src/Http/Parser/RouteParams.php#L28-L38
|
220,908
|
tymondesigns/jwt-auth
|
src/Providers/Storage/Illuminate.php
|
Illuminate.add
|
public function add($key, $value, $minutes)
{
// If the laravel version is 5.8 or higher then convert minutes to seconds.
if ($this->laravelVersion !== null
&& is_int($minutes)
&& version_compare($this->laravelVersion, '5.8', '>=')
) {
$minutes = $minutes * 60;
}
$this->cache()->put($key, $value, $minutes);
}
|
php
|
public function add($key, $value, $minutes)
{
// If the laravel version is 5.8 or higher then convert minutes to seconds.
if ($this->laravelVersion !== null
&& is_int($minutes)
&& version_compare($this->laravelVersion, '5.8', '>=')
) {
$minutes = $minutes * 60;
}
$this->cache()->put($key, $value, $minutes);
}
|
[
"public",
"function",
"add",
"(",
"$",
"key",
",",
"$",
"value",
",",
"$",
"minutes",
")",
"{",
"// If the laravel version is 5.8 or higher then convert minutes to seconds.",
"if",
"(",
"$",
"this",
"->",
"laravelVersion",
"!==",
"null",
"&&",
"is_int",
"(",
"$",
"minutes",
")",
"&&",
"version_compare",
"(",
"$",
"this",
"->",
"laravelVersion",
",",
"'5.8'",
",",
"'>='",
")",
")",
"{",
"$",
"minutes",
"=",
"$",
"minutes",
"*",
"60",
";",
"}",
"$",
"this",
"->",
"cache",
"(",
")",
"->",
"put",
"(",
"$",
"key",
",",
"$",
"value",
",",
"$",
"minutes",
")",
";",
"}"
] |
Add a new item into storage.
@param string $key
@param mixed $value
@param int $minutes
@return void
|
[
"Add",
"a",
"new",
"item",
"into",
"storage",
"."
] |
63698d304554e5d0bc3eb481cc260a9fc900e151
|
https://github.com/tymondesigns/jwt-auth/blob/63698d304554e5d0bc3eb481cc260a9fc900e151/src/Providers/Storage/Illuminate.php#L66-L77
|
220,909
|
tymondesigns/jwt-auth
|
src/Providers/Storage/Illuminate.php
|
Illuminate.cache
|
protected function cache()
{
if ($this->supportsTags === null) {
$this->determineTagSupport();
}
if ($this->supportsTags) {
return $this->cache->tags($this->tag);
}
return $this->cache;
}
|
php
|
protected function cache()
{
if ($this->supportsTags === null) {
$this->determineTagSupport();
}
if ($this->supportsTags) {
return $this->cache->tags($this->tag);
}
return $this->cache;
}
|
[
"protected",
"function",
"cache",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"supportsTags",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"determineTagSupport",
"(",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"supportsTags",
")",
"{",
"return",
"$",
"this",
"->",
"cache",
"->",
"tags",
"(",
"$",
"this",
"->",
"tag",
")",
";",
"}",
"return",
"$",
"this",
"->",
"cache",
";",
"}"
] |
Return the cache instance with tags attached.
@return \Illuminate\Contracts\Cache\Repository
|
[
"Return",
"the",
"cache",
"instance",
"with",
"tags",
"attached",
"."
] |
63698d304554e5d0bc3eb481cc260a9fc900e151
|
https://github.com/tymondesigns/jwt-auth/blob/63698d304554e5d0bc3eb481cc260a9fc900e151/src/Providers/Storage/Illuminate.php#L131-L142
|
220,910
|
tymondesigns/jwt-auth
|
src/Providers/Auth/Sentinel.php
|
Sentinel.byId
|
public function byId($id)
{
if ($user = $this->sentinel->getUserRepository()->findById($id)) {
$this->sentinel->setUser($user);
return true;
}
return false;
}
|
php
|
public function byId($id)
{
if ($user = $this->sentinel->getUserRepository()->findById($id)) {
$this->sentinel->setUser($user);
return true;
}
return false;
}
|
[
"public",
"function",
"byId",
"(",
"$",
"id",
")",
"{",
"if",
"(",
"$",
"user",
"=",
"$",
"this",
"->",
"sentinel",
"->",
"getUserRepository",
"(",
")",
"->",
"findById",
"(",
"$",
"id",
")",
")",
"{",
"$",
"this",
"->",
"sentinel",
"->",
"setUser",
"(",
"$",
"user",
")",
";",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] |
Authenticate a user via the id.
@param mixed $id
@return bool
|
[
"Authenticate",
"a",
"user",
"via",
"the",
"id",
"."
] |
63698d304554e5d0bc3eb481cc260a9fc900e151
|
https://github.com/tymondesigns/jwt-auth/blob/63698d304554e5d0bc3eb481cc260a9fc900e151/src/Providers/Auth/Sentinel.php#L57-L66
|
220,911
|
tymondesigns/jwt-auth
|
src/Payload.php
|
Payload.matches
|
public function matches(array $values, $strict = false)
{
if (empty($values)) {
return false;
}
$claims = $this->getClaims();
foreach ($values as $key => $value) {
if (! $claims->has($key) || ! $claims->get($key)->matches($value, $strict)) {
return false;
}
}
return true;
}
|
php
|
public function matches(array $values, $strict = false)
{
if (empty($values)) {
return false;
}
$claims = $this->getClaims();
foreach ($values as $key => $value) {
if (! $claims->has($key) || ! $claims->get($key)->matches($value, $strict)) {
return false;
}
}
return true;
}
|
[
"public",
"function",
"matches",
"(",
"array",
"$",
"values",
",",
"$",
"strict",
"=",
"false",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"values",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"claims",
"=",
"$",
"this",
"->",
"getClaims",
"(",
")",
";",
"foreach",
"(",
"$",
"values",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"$",
"claims",
"->",
"has",
"(",
"$",
"key",
")",
"||",
"!",
"$",
"claims",
"->",
"get",
"(",
"$",
"key",
")",
"->",
"matches",
"(",
"$",
"value",
",",
"$",
"strict",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}"
] |
Checks if a payload matches some expected values.
@param array $values
@param bool $strict
@return bool
|
[
"Checks",
"if",
"a",
"payload",
"matches",
"some",
"expected",
"values",
"."
] |
63698d304554e5d0bc3eb481cc260a9fc900e151
|
https://github.com/tymondesigns/jwt-auth/blob/63698d304554e5d0bc3eb481cc260a9fc900e151/src/Payload.php#L67-L82
|
220,912
|
tymondesigns/jwt-auth
|
src/Claims/Collection.php
|
Collection.getByClaimName
|
public function getByClaimName($name, callable $callback = null, $default = null)
{
return $this->filter(function (Claim $claim) use ($name) {
return $claim->getName() === $name;
})->first($callback, $default);
}
|
php
|
public function getByClaimName($name, callable $callback = null, $default = null)
{
return $this->filter(function (Claim $claim) use ($name) {
return $claim->getName() === $name;
})->first($callback, $default);
}
|
[
"public",
"function",
"getByClaimName",
"(",
"$",
"name",
",",
"callable",
"$",
"callback",
"=",
"null",
",",
"$",
"default",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"filter",
"(",
"function",
"(",
"Claim",
"$",
"claim",
")",
"use",
"(",
"$",
"name",
")",
"{",
"return",
"$",
"claim",
"->",
"getName",
"(",
")",
"===",
"$",
"name",
";",
"}",
")",
"->",
"first",
"(",
"$",
"callback",
",",
"$",
"default",
")",
";",
"}"
] |
Get a Claim instance by it's unique name.
@param string $name
@param callable $callback
@param mixed $default
@return \Tymon\JWTAuth\Claims\Claim
|
[
"Get",
"a",
"Claim",
"instance",
"by",
"it",
"s",
"unique",
"name",
"."
] |
63698d304554e5d0bc3eb481cc260a9fc900e151
|
https://github.com/tymondesigns/jwt-auth/blob/63698d304554e5d0bc3eb481cc260a9fc900e151/src/Claims/Collection.php#L40-L45
|
220,913
|
tymondesigns/jwt-auth
|
src/Claims/Collection.php
|
Collection.validate
|
public function validate($context = 'payload')
{
$args = func_get_args();
array_shift($args);
$this->each(function ($claim) use ($context, $args) {
call_user_func_array(
[$claim, 'validate'.Str::ucfirst($context)],
$args
);
});
return $this;
}
|
php
|
public function validate($context = 'payload')
{
$args = func_get_args();
array_shift($args);
$this->each(function ($claim) use ($context, $args) {
call_user_func_array(
[$claim, 'validate'.Str::ucfirst($context)],
$args
);
});
return $this;
}
|
[
"public",
"function",
"validate",
"(",
"$",
"context",
"=",
"'payload'",
")",
"{",
"$",
"args",
"=",
"func_get_args",
"(",
")",
";",
"array_shift",
"(",
"$",
"args",
")",
";",
"$",
"this",
"->",
"each",
"(",
"function",
"(",
"$",
"claim",
")",
"use",
"(",
"$",
"context",
",",
"$",
"args",
")",
"{",
"call_user_func_array",
"(",
"[",
"$",
"claim",
",",
"'validate'",
".",
"Str",
"::",
"ucfirst",
"(",
"$",
"context",
")",
"]",
",",
"$",
"args",
")",
";",
"}",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Validate each claim under a given context.
@param string $context
@return $this
|
[
"Validate",
"each",
"claim",
"under",
"a",
"given",
"context",
"."
] |
63698d304554e5d0bc3eb481cc260a9fc900e151
|
https://github.com/tymondesigns/jwt-auth/blob/63698d304554e5d0bc3eb481cc260a9fc900e151/src/Claims/Collection.php#L54-L67
|
220,914
|
tymondesigns/jwt-auth
|
src/Claims/Collection.php
|
Collection.sanitizeClaims
|
private function sanitizeClaims($items)
{
$claims = [];
foreach ($items as $key => $value) {
if (! is_string($key) && $value instanceof Claim) {
$key = $value->getName();
}
$claims[$key] = $value;
}
return $claims;
}
|
php
|
private function sanitizeClaims($items)
{
$claims = [];
foreach ($items as $key => $value) {
if (! is_string($key) && $value instanceof Claim) {
$key = $value->getName();
}
$claims[$key] = $value;
}
return $claims;
}
|
[
"private",
"function",
"sanitizeClaims",
"(",
"$",
"items",
")",
"{",
"$",
"claims",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"items",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"key",
")",
"&&",
"$",
"value",
"instanceof",
"Claim",
")",
"{",
"$",
"key",
"=",
"$",
"value",
"->",
"getName",
"(",
")",
";",
"}",
"$",
"claims",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"}",
"return",
"$",
"claims",
";",
"}"
] |
Ensure that the given claims array is keyed by the claim name.
@param mixed $items
@return array
|
[
"Ensure",
"that",
"the",
"given",
"claims",
"array",
"is",
"keyed",
"by",
"the",
"claim",
"name",
"."
] |
63698d304554e5d0bc3eb481cc260a9fc900e151
|
https://github.com/tymondesigns/jwt-auth/blob/63698d304554e5d0bc3eb481cc260a9fc900e151/src/Claims/Collection.php#L108-L120
|
220,915
|
tymondesigns/jwt-auth
|
src/Blacklist.php
|
Blacklist.has
|
public function has(Payload $payload)
{
$val = $this->storage->get($this->getKey($payload));
// exit early if the token was blacklisted forever,
if ($val === 'forever') {
return true;
}
// check whether the expiry + grace has past
return ! empty($val) && ! Utils::isFuture($val['valid_until']);
}
|
php
|
public function has(Payload $payload)
{
$val = $this->storage->get($this->getKey($payload));
// exit early if the token was blacklisted forever,
if ($val === 'forever') {
return true;
}
// check whether the expiry + grace has past
return ! empty($val) && ! Utils::isFuture($val['valid_until']);
}
|
[
"public",
"function",
"has",
"(",
"Payload",
"$",
"payload",
")",
"{",
"$",
"val",
"=",
"$",
"this",
"->",
"storage",
"->",
"get",
"(",
"$",
"this",
"->",
"getKey",
"(",
"$",
"payload",
")",
")",
";",
"// exit early if the token was blacklisted forever,",
"if",
"(",
"$",
"val",
"===",
"'forever'",
")",
"{",
"return",
"true",
";",
"}",
"// check whether the expiry + grace has past",
"return",
"!",
"empty",
"(",
"$",
"val",
")",
"&&",
"!",
"Utils",
"::",
"isFuture",
"(",
"$",
"val",
"[",
"'valid_until'",
"]",
")",
";",
"}"
] |
Determine whether the token has been blacklisted.
@param \Tymon\JWTAuth\Payload $payload
@return bool
|
[
"Determine",
"whether",
"the",
"token",
"has",
"been",
"blacklisted",
"."
] |
63698d304554e5d0bc3eb481cc260a9fc900e151
|
https://github.com/tymondesigns/jwt-auth/blob/63698d304554e5d0bc3eb481cc260a9fc900e151/src/Blacklist.php#L127-L138
|
220,916
|
tymondesigns/jwt-auth
|
src/Support/Utils.php
|
Utils.isPast
|
public static function isPast($timestamp, $leeway = 0)
{
$timestamp = static::timestamp($timestamp);
return $leeway > 0
? $timestamp->addSeconds($leeway)->isPast()
: $timestamp->isPast();
}
|
php
|
public static function isPast($timestamp, $leeway = 0)
{
$timestamp = static::timestamp($timestamp);
return $leeway > 0
? $timestamp->addSeconds($leeway)->isPast()
: $timestamp->isPast();
}
|
[
"public",
"static",
"function",
"isPast",
"(",
"$",
"timestamp",
",",
"$",
"leeway",
"=",
"0",
")",
"{",
"$",
"timestamp",
"=",
"static",
"::",
"timestamp",
"(",
"$",
"timestamp",
")",
";",
"return",
"$",
"leeway",
">",
"0",
"?",
"$",
"timestamp",
"->",
"addSeconds",
"(",
"$",
"leeway",
")",
"->",
"isPast",
"(",
")",
":",
"$",
"timestamp",
"->",
"isPast",
"(",
")",
";",
"}"
] |
Checks if a timestamp is in the past.
@param int $timestamp
@param int $leeway
@return bool
|
[
"Checks",
"if",
"a",
"timestamp",
"is",
"in",
"the",
"past",
"."
] |
63698d304554e5d0bc3eb481cc260a9fc900e151
|
https://github.com/tymondesigns/jwt-auth/blob/63698d304554e5d0bc3eb481cc260a9fc900e151/src/Support/Utils.php#L48-L55
|
220,917
|
tymondesigns/jwt-auth
|
src/Support/Utils.php
|
Utils.isFuture
|
public static function isFuture($timestamp, $leeway = 0)
{
$timestamp = static::timestamp($timestamp);
return $leeway > 0
? $timestamp->subSeconds($leeway)->isFuture()
: $timestamp->isFuture();
}
|
php
|
public static function isFuture($timestamp, $leeway = 0)
{
$timestamp = static::timestamp($timestamp);
return $leeway > 0
? $timestamp->subSeconds($leeway)->isFuture()
: $timestamp->isFuture();
}
|
[
"public",
"static",
"function",
"isFuture",
"(",
"$",
"timestamp",
",",
"$",
"leeway",
"=",
"0",
")",
"{",
"$",
"timestamp",
"=",
"static",
"::",
"timestamp",
"(",
"$",
"timestamp",
")",
";",
"return",
"$",
"leeway",
">",
"0",
"?",
"$",
"timestamp",
"->",
"subSeconds",
"(",
"$",
"leeway",
")",
"->",
"isFuture",
"(",
")",
":",
"$",
"timestamp",
"->",
"isFuture",
"(",
")",
";",
"}"
] |
Checks if a timestamp is in the future.
@param int $timestamp
@param int $leeway
@return bool
|
[
"Checks",
"if",
"a",
"timestamp",
"is",
"in",
"the",
"future",
"."
] |
63698d304554e5d0bc3eb481cc260a9fc900e151
|
https://github.com/tymondesigns/jwt-auth/blob/63698d304554e5d0bc3eb481cc260a9fc900e151/src/Support/Utils.php#L65-L72
|
220,918
|
tymondesigns/jwt-auth
|
src/JWTAuth.php
|
JWTAuth.attempt
|
public function attempt(array $credentials)
{
if (! $this->auth->byCredentials($credentials)) {
return false;
}
return $this->fromUser($this->user());
}
|
php
|
public function attempt(array $credentials)
{
if (! $this->auth->byCredentials($credentials)) {
return false;
}
return $this->fromUser($this->user());
}
|
[
"public",
"function",
"attempt",
"(",
"array",
"$",
"credentials",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"auth",
"->",
"byCredentials",
"(",
"$",
"credentials",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"$",
"this",
"->",
"fromUser",
"(",
"$",
"this",
"->",
"user",
"(",
")",
")",
";",
"}"
] |
Attempt to authenticate the user and return the token.
@param array $credentials
@return false|string
|
[
"Attempt",
"to",
"authenticate",
"the",
"user",
"and",
"return",
"the",
"token",
"."
] |
63698d304554e5d0bc3eb481cc260a9fc900e151
|
https://github.com/tymondesigns/jwt-auth/blob/63698d304554e5d0bc3eb481cc260a9fc900e151/src/JWTAuth.php#L48-L55
|
220,919
|
tymondesigns/jwt-auth
|
src/Factory.php
|
Factory.addClaims
|
protected function addClaims(array $claims)
{
foreach ($claims as $name => $value) {
$this->addClaim($name, $value);
}
return $this;
}
|
php
|
protected function addClaims(array $claims)
{
foreach ($claims as $name => $value) {
$this->addClaim($name, $value);
}
return $this;
}
|
[
"protected",
"function",
"addClaims",
"(",
"array",
"$",
"claims",
")",
"{",
"foreach",
"(",
"$",
"claims",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"addClaim",
"(",
"$",
"name",
",",
"$",
"value",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Add an array of claims to the Payload.
@param array $claims
@return $this
|
[
"Add",
"an",
"array",
"of",
"claims",
"to",
"the",
"Payload",
"."
] |
63698d304554e5d0bc3eb481cc260a9fc900e151
|
https://github.com/tymondesigns/jwt-auth/blob/63698d304554e5d0bc3eb481cc260a9fc900e151/src/Factory.php#L109-L116
|
220,920
|
tymondesigns/jwt-auth
|
src/JWT.php
|
JWT.fromSubject
|
public function fromSubject(JWTSubject $subject)
{
$payload = $this->makePayload($subject);
return $this->manager->encode($payload)->get();
}
|
php
|
public function fromSubject(JWTSubject $subject)
{
$payload = $this->makePayload($subject);
return $this->manager->encode($payload)->get();
}
|
[
"public",
"function",
"fromSubject",
"(",
"JWTSubject",
"$",
"subject",
")",
"{",
"$",
"payload",
"=",
"$",
"this",
"->",
"makePayload",
"(",
"$",
"subject",
")",
";",
"return",
"$",
"this",
"->",
"manager",
"->",
"encode",
"(",
"$",
"payload",
")",
"->",
"get",
"(",
")",
";",
"}"
] |
Generate a token for a given subject.
@param \Tymon\JWTAuth\Contracts\JWTSubject $subject
@return string
|
[
"Generate",
"a",
"token",
"for",
"a",
"given",
"subject",
"."
] |
63698d304554e5d0bc3eb481cc260a9fc900e151
|
https://github.com/tymondesigns/jwt-auth/blob/63698d304554e5d0bc3eb481cc260a9fc900e151/src/JWT.php#L74-L79
|
220,921
|
tymondesigns/jwt-auth
|
src/JWT.php
|
JWT.getClaimsForSubject
|
protected function getClaimsForSubject(JWTSubject $subject)
{
return array_merge([
'sub' => $subject->getJWTIdentifier(),
], $this->lockSubject ? ['prv' => $this->hashSubjectModel($subject)] : []);
}
|
php
|
protected function getClaimsForSubject(JWTSubject $subject)
{
return array_merge([
'sub' => $subject->getJWTIdentifier(),
], $this->lockSubject ? ['prv' => $this->hashSubjectModel($subject)] : []);
}
|
[
"protected",
"function",
"getClaimsForSubject",
"(",
"JWTSubject",
"$",
"subject",
")",
"{",
"return",
"array_merge",
"(",
"[",
"'sub'",
"=>",
"$",
"subject",
"->",
"getJWTIdentifier",
"(",
")",
",",
"]",
",",
"$",
"this",
"->",
"lockSubject",
"?",
"[",
"'prv'",
"=>",
"$",
"this",
"->",
"hashSubjectModel",
"(",
"$",
"subject",
")",
"]",
":",
"[",
"]",
")",
";",
"}"
] |
Get the claims associated with a given subject.
@param \Tymon\JWTAuth\Contracts\JWTSubject $subject
@return array
|
[
"Get",
"the",
"claims",
"associated",
"with",
"a",
"given",
"subject",
"."
] |
63698d304554e5d0bc3eb481cc260a9fc900e151
|
https://github.com/tymondesigns/jwt-auth/blob/63698d304554e5d0bc3eb481cc260a9fc900e151/src/JWT.php#L260-L265
|
220,922
|
tymondesigns/jwt-auth
|
src/JWT.php
|
JWT.checkSubjectModel
|
public function checkSubjectModel($model)
{
if (($prv = $this->payload()->get('prv')) === null) {
return true;
}
return $this->hashSubjectModel($model) === $prv;
}
|
php
|
public function checkSubjectModel($model)
{
if (($prv = $this->payload()->get('prv')) === null) {
return true;
}
return $this->hashSubjectModel($model) === $prv;
}
|
[
"public",
"function",
"checkSubjectModel",
"(",
"$",
"model",
")",
"{",
"if",
"(",
"(",
"$",
"prv",
"=",
"$",
"this",
"->",
"payload",
"(",
")",
"->",
"get",
"(",
"'prv'",
")",
")",
"===",
"null",
")",
"{",
"return",
"true",
";",
"}",
"return",
"$",
"this",
"->",
"hashSubjectModel",
"(",
"$",
"model",
")",
"===",
"$",
"prv",
";",
"}"
] |
Check if the subject model matches the one saved in the token.
@param string|object $model
@return bool
|
[
"Check",
"if",
"the",
"subject",
"model",
"matches",
"the",
"one",
"saved",
"in",
"the",
"token",
"."
] |
63698d304554e5d0bc3eb481cc260a9fc900e151
|
https://github.com/tymondesigns/jwt-auth/blob/63698d304554e5d0bc3eb481cc260a9fc900e151/src/JWT.php#L286-L293
|
220,923
|
tymondesigns/jwt-auth
|
src/Http/Parser/Cookies.php
|
Cookies.parse
|
public function parse(Request $request)
{
if ($this->decrypt && $request->hasCookie($this->key)) {
return Crypt::decrypt($request->cookie($this->key));
}
return $request->cookie($this->key);
}
|
php
|
public function parse(Request $request)
{
if ($this->decrypt && $request->hasCookie($this->key)) {
return Crypt::decrypt($request->cookie($this->key));
}
return $request->cookie($this->key);
}
|
[
"public",
"function",
"parse",
"(",
"Request",
"$",
"request",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"decrypt",
"&&",
"$",
"request",
"->",
"hasCookie",
"(",
"$",
"this",
"->",
"key",
")",
")",
"{",
"return",
"Crypt",
"::",
"decrypt",
"(",
"$",
"request",
"->",
"cookie",
"(",
"$",
"this",
"->",
"key",
")",
")",
";",
"}",
"return",
"$",
"request",
"->",
"cookie",
"(",
"$",
"this",
"->",
"key",
")",
";",
"}"
] |
Try to parse the token from the request cookies.
@param \Illuminate\Http\Request $request
@return null|string
|
[
"Try",
"to",
"parse",
"the",
"token",
"from",
"the",
"request",
"cookies",
"."
] |
63698d304554e5d0bc3eb481cc260a9fc900e151
|
https://github.com/tymondesigns/jwt-auth/blob/63698d304554e5d0bc3eb481cc260a9fc900e151/src/Http/Parser/Cookies.php#L41-L48
|
220,924
|
tymondesigns/jwt-auth
|
src/Http/Middleware/BaseMiddleware.php
|
BaseMiddleware.setAuthenticationHeader
|
protected function setAuthenticationHeader($response, $token = null)
{
$token = $token ?: $this->auth->refresh();
$response->headers->set('Authorization', 'Bearer '.$token);
return $response;
}
|
php
|
protected function setAuthenticationHeader($response, $token = null)
{
$token = $token ?: $this->auth->refresh();
$response->headers->set('Authorization', 'Bearer '.$token);
return $response;
}
|
[
"protected",
"function",
"setAuthenticationHeader",
"(",
"$",
"response",
",",
"$",
"token",
"=",
"null",
")",
"{",
"$",
"token",
"=",
"$",
"token",
"?",
":",
"$",
"this",
"->",
"auth",
"->",
"refresh",
"(",
")",
";",
"$",
"response",
"->",
"headers",
"->",
"set",
"(",
"'Authorization'",
",",
"'Bearer '",
".",
"$",
"token",
")",
";",
"return",
"$",
"response",
";",
"}"
] |
Set the authentication header.
@param \Illuminate\Http\Response|\Illuminate\Http\JsonResponse $response
@param string|null $token
@return \Illuminate\Http\Response|\Illuminate\Http\JsonResponse
|
[
"Set",
"the",
"authentication",
"header",
"."
] |
63698d304554e5d0bc3eb481cc260a9fc900e151
|
https://github.com/tymondesigns/jwt-auth/blob/63698d304554e5d0bc3eb481cc260a9fc900e151/src/Http/Middleware/BaseMiddleware.php#L86-L92
|
220,925
|
tymondesigns/jwt-auth
|
src/Providers/JWT/Lcobucci.php
|
Lcobucci.getSigner
|
protected function getSigner()
{
if (! array_key_exists($this->algo, $this->signers)) {
throw new JWTException('The given algorithm could not be found');
}
return new $this->signers[$this->algo];
}
|
php
|
protected function getSigner()
{
if (! array_key_exists($this->algo, $this->signers)) {
throw new JWTException('The given algorithm could not be found');
}
return new $this->signers[$this->algo];
}
|
[
"protected",
"function",
"getSigner",
"(",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"this",
"->",
"algo",
",",
"$",
"this",
"->",
"signers",
")",
")",
"{",
"throw",
"new",
"JWTException",
"(",
"'The given algorithm could not be found'",
")",
";",
"}",
"return",
"new",
"$",
"this",
"->",
"signers",
"[",
"$",
"this",
"->",
"algo",
"]",
";",
"}"
] |
Get the signer instance.
@throws \Tymon\JWTAuth\Exceptions\JWTException
@return \Lcobucci\JWT\Signer
|
[
"Get",
"the",
"signer",
"instance",
"."
] |
63698d304554e5d0bc3eb481cc260a9fc900e151
|
https://github.com/tymondesigns/jwt-auth/blob/63698d304554e5d0bc3eb481cc260a9fc900e151/src/Providers/JWT/Lcobucci.php#L152-L159
|
220,926
|
tymondesigns/jwt-auth
|
src/Claims/DatetimeTrait.php
|
DatetimeTrait.setValue
|
public function setValue($value)
{
if ($value instanceof DateInterval) {
$value = Utils::now()->add($value);
}
if ($value instanceof DateTimeInterface) {
$value = $value->getTimestamp();
}
return parent::setValue($value);
}
|
php
|
public function setValue($value)
{
if ($value instanceof DateInterval) {
$value = Utils::now()->add($value);
}
if ($value instanceof DateTimeInterface) {
$value = $value->getTimestamp();
}
return parent::setValue($value);
}
|
[
"public",
"function",
"setValue",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"value",
"instanceof",
"DateInterval",
")",
"{",
"$",
"value",
"=",
"Utils",
"::",
"now",
"(",
")",
"->",
"add",
"(",
"$",
"value",
")",
";",
"}",
"if",
"(",
"$",
"value",
"instanceof",
"DateTimeInterface",
")",
"{",
"$",
"value",
"=",
"$",
"value",
"->",
"getTimestamp",
"(",
")",
";",
"}",
"return",
"parent",
"::",
"setValue",
"(",
"$",
"value",
")",
";",
"}"
] |
Set the claim value, and call a validate method.
@param mixed $value
@throws \Tymon\JWTAuth\Exceptions\InvalidClaimException
@return $this
|
[
"Set",
"the",
"claim",
"value",
"and",
"call",
"a",
"validate",
"method",
"."
] |
63698d304554e5d0bc3eb481cc260a9fc900e151
|
https://github.com/tymondesigns/jwt-auth/blob/63698d304554e5d0bc3eb481cc260a9fc900e151/src/Claims/DatetimeTrait.php#L37-L48
|
220,927
|
tymondesigns/jwt-auth
|
src/JWTGuard.php
|
JWTGuard.logout
|
public function logout($forceForever = false)
{
$this->requireToken()->invalidate($forceForever);
$this->user = null;
$this->jwt->unsetToken();
}
|
php
|
public function logout($forceForever = false)
{
$this->requireToken()->invalidate($forceForever);
$this->user = null;
$this->jwt->unsetToken();
}
|
[
"public",
"function",
"logout",
"(",
"$",
"forceForever",
"=",
"false",
")",
"{",
"$",
"this",
"->",
"requireToken",
"(",
")",
"->",
"invalidate",
"(",
"$",
"forceForever",
")",
";",
"$",
"this",
"->",
"user",
"=",
"null",
";",
"$",
"this",
"->",
"jwt",
"->",
"unsetToken",
"(",
")",
";",
"}"
] |
Logout the user, thus invalidating the token.
@param bool $forceForever
@return void
|
[
"Logout",
"the",
"user",
"thus",
"invalidating",
"the",
"token",
"."
] |
63698d304554e5d0bc3eb481cc260a9fc900e151
|
https://github.com/tymondesigns/jwt-auth/blob/63698d304554e5d0bc3eb481cc260a9fc900e151/src/JWTGuard.php#L155-L161
|
220,928
|
tymondesigns/jwt-auth
|
src/JWTGuard.php
|
JWTGuard.refresh
|
public function refresh($forceForever = false, $resetClaims = false)
{
return $this->requireToken()->refresh($forceForever, $resetClaims);
}
|
php
|
public function refresh($forceForever = false, $resetClaims = false)
{
return $this->requireToken()->refresh($forceForever, $resetClaims);
}
|
[
"public",
"function",
"refresh",
"(",
"$",
"forceForever",
"=",
"false",
",",
"$",
"resetClaims",
"=",
"false",
")",
"{",
"return",
"$",
"this",
"->",
"requireToken",
"(",
")",
"->",
"refresh",
"(",
"$",
"forceForever",
",",
"$",
"resetClaims",
")",
";",
"}"
] |
Refresh the token.
@param bool $forceForever
@param bool $resetClaims
@return string
|
[
"Refresh",
"the",
"token",
"."
] |
63698d304554e5d0bc3eb481cc260a9fc900e151
|
https://github.com/tymondesigns/jwt-auth/blob/63698d304554e5d0bc3eb481cc260a9fc900e151/src/JWTGuard.php#L171-L174
|
220,929
|
tymondesigns/jwt-auth
|
src/JWTGuard.php
|
JWTGuard.validateSubject
|
protected function validateSubject()
{
// If the provider doesn't have the necessary method
// to get the underlying model name then allow.
if (! method_exists($this->provider, 'getModel')) {
return true;
}
return $this->jwt->checkSubjectModel($this->provider->getModel());
}
|
php
|
protected function validateSubject()
{
// If the provider doesn't have the necessary method
// to get the underlying model name then allow.
if (! method_exists($this->provider, 'getModel')) {
return true;
}
return $this->jwt->checkSubjectModel($this->provider->getModel());
}
|
[
"protected",
"function",
"validateSubject",
"(",
")",
"{",
"// If the provider doesn't have the necessary method",
"// to get the underlying model name then allow.",
"if",
"(",
"!",
"method_exists",
"(",
"$",
"this",
"->",
"provider",
",",
"'getModel'",
")",
")",
"{",
"return",
"true",
";",
"}",
"return",
"$",
"this",
"->",
"jwt",
"->",
"checkSubjectModel",
"(",
"$",
"this",
"->",
"provider",
"->",
"getModel",
"(",
")",
")",
";",
"}"
] |
Ensure the JWTSubject matches what is in the token.
@return bool
|
[
"Ensure",
"the",
"JWTSubject",
"matches",
"what",
"is",
"in",
"the",
"token",
"."
] |
63698d304554e5d0bc3eb481cc260a9fc900e151
|
https://github.com/tymondesigns/jwt-auth/blob/63698d304554e5d0bc3eb481cc260a9fc900e151/src/JWTGuard.php#L398-L407
|
220,930
|
tymondesigns/jwt-auth
|
src/Providers/AbstractServiceProvider.php
|
AbstractServiceProvider.extendAuthGuard
|
protected function extendAuthGuard()
{
$this->app['auth']->extend('jwt', function ($app, $name, array $config) {
$guard = new JWTGuard(
$app['tymon.jwt'],
$app['auth']->createUserProvider($config['provider']),
$app['request']
);
$app->refresh('request', $guard, 'setRequest');
return $guard;
});
}
|
php
|
protected function extendAuthGuard()
{
$this->app['auth']->extend('jwt', function ($app, $name, array $config) {
$guard = new JWTGuard(
$app['tymon.jwt'],
$app['auth']->createUserProvider($config['provider']),
$app['request']
);
$app->refresh('request', $guard, 'setRequest');
return $guard;
});
}
|
[
"protected",
"function",
"extendAuthGuard",
"(",
")",
"{",
"$",
"this",
"->",
"app",
"[",
"'auth'",
"]",
"->",
"extend",
"(",
"'jwt'",
",",
"function",
"(",
"$",
"app",
",",
"$",
"name",
",",
"array",
"$",
"config",
")",
"{",
"$",
"guard",
"=",
"new",
"JWTGuard",
"(",
"$",
"app",
"[",
"'tymon.jwt'",
"]",
",",
"$",
"app",
"[",
"'auth'",
"]",
"->",
"createUserProvider",
"(",
"$",
"config",
"[",
"'provider'",
"]",
")",
",",
"$",
"app",
"[",
"'request'",
"]",
")",
";",
"$",
"app",
"->",
"refresh",
"(",
"'request'",
",",
"$",
"guard",
",",
"'setRequest'",
")",
";",
"return",
"$",
"guard",
";",
"}",
")",
";",
"}"
] |
Extend Laravel's Auth.
@return void
|
[
"Extend",
"Laravel",
"s",
"Auth",
"."
] |
63698d304554e5d0bc3eb481cc260a9fc900e151
|
https://github.com/tymondesigns/jwt-auth/blob/63698d304554e5d0bc3eb481cc260a9fc900e151/src/Providers/AbstractServiceProvider.php#L96-L109
|
220,931
|
tymondesigns/jwt-auth
|
src/Providers/AbstractServiceProvider.php
|
AbstractServiceProvider.registerJWT
|
protected function registerJWT()
{
$this->app->singleton('tymon.jwt', function ($app) {
return (new JWT(
$app['tymon.jwt.manager'],
$app['tymon.jwt.parser']
))->lockSubject($this->config('lock_subject'));
});
}
|
php
|
protected function registerJWT()
{
$this->app->singleton('tymon.jwt', function ($app) {
return (new JWT(
$app['tymon.jwt.manager'],
$app['tymon.jwt.parser']
))->lockSubject($this->config('lock_subject'));
});
}
|
[
"protected",
"function",
"registerJWT",
"(",
")",
"{",
"$",
"this",
"->",
"app",
"->",
"singleton",
"(",
"'tymon.jwt'",
",",
"function",
"(",
"$",
"app",
")",
"{",
"return",
"(",
"new",
"JWT",
"(",
"$",
"app",
"[",
"'tymon.jwt.manager'",
"]",
",",
"$",
"app",
"[",
"'tymon.jwt.parser'",
"]",
")",
")",
"->",
"lockSubject",
"(",
"$",
"this",
"->",
"config",
"(",
"'lock_subject'",
")",
")",
";",
"}",
")",
";",
"}"
] |
Register the bindings for the main JWT class.
@return void
|
[
"Register",
"the",
"bindings",
"for",
"the",
"main",
"JWT",
"class",
"."
] |
63698d304554e5d0bc3eb481cc260a9fc900e151
|
https://github.com/tymondesigns/jwt-auth/blob/63698d304554e5d0bc3eb481cc260a9fc900e151/src/Providers/AbstractServiceProvider.php#L254-L262
|
220,932
|
tymondesigns/jwt-auth
|
src/Providers/AbstractServiceProvider.php
|
AbstractServiceProvider.registerPayloadValidator
|
protected function registerPayloadValidator()
{
$this->app->singleton('tymon.jwt.validators.payload', function () {
return (new PayloadValidator)
->setRefreshTTL($this->config('refresh_ttl'))
->setRequiredClaims($this->config('required_claims'));
});
}
|
php
|
protected function registerPayloadValidator()
{
$this->app->singleton('tymon.jwt.validators.payload', function () {
return (new PayloadValidator)
->setRefreshTTL($this->config('refresh_ttl'))
->setRequiredClaims($this->config('required_claims'));
});
}
|
[
"protected",
"function",
"registerPayloadValidator",
"(",
")",
"{",
"$",
"this",
"->",
"app",
"->",
"singleton",
"(",
"'tymon.jwt.validators.payload'",
",",
"function",
"(",
")",
"{",
"return",
"(",
"new",
"PayloadValidator",
")",
"->",
"setRefreshTTL",
"(",
"$",
"this",
"->",
"config",
"(",
"'refresh_ttl'",
")",
")",
"->",
"setRequiredClaims",
"(",
"$",
"this",
"->",
"config",
"(",
"'required_claims'",
")",
")",
";",
"}",
")",
";",
"}"
] |
Register the bindings for the payload validator.
@return void
|
[
"Register",
"the",
"bindings",
"for",
"the",
"payload",
"validator",
"."
] |
63698d304554e5d0bc3eb481cc260a9fc900e151
|
https://github.com/tymondesigns/jwt-auth/blob/63698d304554e5d0bc3eb481cc260a9fc900e151/src/Providers/AbstractServiceProvider.php#L300-L307
|
220,933
|
tymondesigns/jwt-auth
|
src/Providers/AbstractServiceProvider.php
|
AbstractServiceProvider.getConfigInstance
|
protected function getConfigInstance($key)
{
$instance = $this->config($key);
if (is_string($instance)) {
return $this->app->make($instance);
}
return $instance;
}
|
php
|
protected function getConfigInstance($key)
{
$instance = $this->config($key);
if (is_string($instance)) {
return $this->app->make($instance);
}
return $instance;
}
|
[
"protected",
"function",
"getConfigInstance",
"(",
"$",
"key",
")",
"{",
"$",
"instance",
"=",
"$",
"this",
"->",
"config",
"(",
"$",
"key",
")",
";",
"if",
"(",
"is_string",
"(",
"$",
"instance",
")",
")",
"{",
"return",
"$",
"this",
"->",
"app",
"->",
"make",
"(",
"$",
"instance",
")",
";",
"}",
"return",
"$",
"instance",
";",
"}"
] |
Get an instantiable configuration instance.
@param string $key
@return mixed
|
[
"Get",
"an",
"instantiable",
"configuration",
"instance",
"."
] |
63698d304554e5d0bc3eb481cc260a9fc900e151
|
https://github.com/tymondesigns/jwt-auth/blob/63698d304554e5d0bc3eb481cc260a9fc900e151/src/Providers/AbstractServiceProvider.php#L372-L381
|
220,934
|
tymondesigns/jwt-auth
|
src/Claims/Claim.php
|
Claim.matches
|
public function matches($value, $strict = true)
{
return $strict ? $this->value === $value : $this->value == $value;
}
|
php
|
public function matches($value, $strict = true)
{
return $strict ? $this->value === $value : $this->value == $value;
}
|
[
"public",
"function",
"matches",
"(",
"$",
"value",
",",
"$",
"strict",
"=",
"true",
")",
"{",
"return",
"$",
"strict",
"?",
"$",
"this",
"->",
"value",
"===",
"$",
"value",
":",
"$",
"this",
"->",
"value",
"==",
"$",
"value",
";",
"}"
] |
Checks if the value matches the claim.
@param mixed $value
@param bool $strict
@return bool
|
[
"Checks",
"if",
"the",
"value",
"matches",
"the",
"claim",
"."
] |
63698d304554e5d0bc3eb481cc260a9fc900e151
|
https://github.com/tymondesigns/jwt-auth/blob/63698d304554e5d0bc3eb481cc260a9fc900e151/src/Claims/Claim.php#L137-L140
|
220,935
|
tymondesigns/jwt-auth
|
src/Http/Parser/AuthHeaders.php
|
AuthHeaders.parse
|
public function parse(Request $request)
{
$header = $request->headers->get($this->header) ?: $this->fromAltHeaders($request);
if ($header && preg_match('/'.$this->prefix.'\s*(\S+)\b/i', $header, $matches)) {
return $matches[1];
}
}
|
php
|
public function parse(Request $request)
{
$header = $request->headers->get($this->header) ?: $this->fromAltHeaders($request);
if ($header && preg_match('/'.$this->prefix.'\s*(\S+)\b/i', $header, $matches)) {
return $matches[1];
}
}
|
[
"public",
"function",
"parse",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"header",
"=",
"$",
"request",
"->",
"headers",
"->",
"get",
"(",
"$",
"this",
"->",
"header",
")",
"?",
":",
"$",
"this",
"->",
"fromAltHeaders",
"(",
"$",
"request",
")",
";",
"if",
"(",
"$",
"header",
"&&",
"preg_match",
"(",
"'/'",
".",
"$",
"this",
"->",
"prefix",
".",
"'\\s*(\\S+)\\b/i'",
",",
"$",
"header",
",",
"$",
"matches",
")",
")",
"{",
"return",
"$",
"matches",
"[",
"1",
"]",
";",
"}",
"}"
] |
Try to parse the token from the request header.
@param \Illuminate\Http\Request $request
@return null|string
|
[
"Try",
"to",
"parse",
"the",
"token",
"from",
"the",
"request",
"header",
"."
] |
63698d304554e5d0bc3eb481cc260a9fc900e151
|
https://github.com/tymondesigns/jwt-auth/blob/63698d304554e5d0bc3eb481cc260a9fc900e151/src/Http/Parser/AuthHeaders.php#L52-L59
|
220,936
|
tymondesigns/jwt-auth
|
src/Manager.php
|
Manager.buildRefreshClaims
|
protected function buildRefreshClaims(Payload $payload)
{
// assign the payload values as variables for use later
extract($payload->toArray());
// persist the relevant claims
return array_merge(
$this->customClaims,
compact($this->persistentClaims, 'sub', 'iat')
);
}
|
php
|
protected function buildRefreshClaims(Payload $payload)
{
// assign the payload values as variables for use later
extract($payload->toArray());
// persist the relevant claims
return array_merge(
$this->customClaims,
compact($this->persistentClaims, 'sub', 'iat')
);
}
|
[
"protected",
"function",
"buildRefreshClaims",
"(",
"Payload",
"$",
"payload",
")",
"{",
"// assign the payload values as variables for use later",
"extract",
"(",
"$",
"payload",
"->",
"toArray",
"(",
")",
")",
";",
"// persist the relevant claims",
"return",
"array_merge",
"(",
"$",
"this",
"->",
"customClaims",
",",
"compact",
"(",
"$",
"this",
"->",
"persistentClaims",
",",
"'sub'",
",",
"'iat'",
")",
")",
";",
"}"
] |
Build the claims to go into the refreshed token.
@param \Tymon\JWTAuth\Payload $payload
@return array
|
[
"Build",
"the",
"claims",
"to",
"go",
"into",
"the",
"refreshed",
"token",
"."
] |
63698d304554e5d0bc3eb481cc260a9fc900e151
|
https://github.com/tymondesigns/jwt-auth/blob/63698d304554e5d0bc3eb481cc260a9fc900e151/src/Manager.php#L170-L180
|
220,937
|
tymondesigns/jwt-auth
|
src/Http/Parser/Parser.php
|
Parser.parseToken
|
public function parseToken()
{
foreach ($this->chain as $parser) {
if ($response = $parser->parse($this->request)) {
return $response;
}
}
}
|
php
|
public function parseToken()
{
foreach ($this->chain as $parser) {
if ($response = $parser->parse($this->request)) {
return $response;
}
}
}
|
[
"public",
"function",
"parseToken",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"chain",
"as",
"$",
"parser",
")",
"{",
"if",
"(",
"$",
"response",
"=",
"$",
"parser",
"->",
"parse",
"(",
"$",
"this",
"->",
"request",
")",
")",
"{",
"return",
"$",
"response",
";",
"}",
"}",
"}"
] |
Iterate through the parsers and attempt to retrieve
a value, otherwise return null.
@return string|null
|
[
"Iterate",
"through",
"the",
"parsers",
"and",
"attempt",
"to",
"retrieve",
"a",
"value",
"otherwise",
"return",
"null",
"."
] |
63698d304554e5d0bc3eb481cc260a9fc900e151
|
https://github.com/tymondesigns/jwt-auth/blob/63698d304554e5d0bc3eb481cc260a9fc900e151/src/Http/Parser/Parser.php#L88-L95
|
220,938
|
Crinsane/LaravelShoppingcart
|
src/CanBeBought.php
|
CanBeBought.getBuyableDescription
|
public function getBuyableDescription($options = null)
{
if(property_exists($this, 'name')) return $this->name;
if(property_exists($this, 'title')) return $this->title;
if(property_exists($this, 'description')) return $this->description;
return null;
}
|
php
|
public function getBuyableDescription($options = null)
{
if(property_exists($this, 'name')) return $this->name;
if(property_exists($this, 'title')) return $this->title;
if(property_exists($this, 'description')) return $this->description;
return null;
}
|
[
"public",
"function",
"getBuyableDescription",
"(",
"$",
"options",
"=",
"null",
")",
"{",
"if",
"(",
"property_exists",
"(",
"$",
"this",
",",
"'name'",
")",
")",
"return",
"$",
"this",
"->",
"name",
";",
"if",
"(",
"property_exists",
"(",
"$",
"this",
",",
"'title'",
")",
")",
"return",
"$",
"this",
"->",
"title",
";",
"if",
"(",
"property_exists",
"(",
"$",
"this",
",",
"'description'",
")",
")",
"return",
"$",
"this",
"->",
"description",
";",
"return",
"null",
";",
"}"
] |
Get the description or title of the Buyable item.
@return string
|
[
"Get",
"the",
"description",
"or",
"title",
"of",
"the",
"Buyable",
"item",
"."
] |
f460ab7312cce32cb428cf39a500a2d16600b1d6
|
https://github.com/Crinsane/LaravelShoppingcart/blob/f460ab7312cce32cb428cf39a500a2d16600b1d6/src/CanBeBought.php#L23-L30
|
220,939
|
Crinsane/LaravelShoppingcart
|
src/CartItem.php
|
CartItem.price
|
public function price($decimals = null, $decimalPoint = null, $thousandSeperator = null)
{
return $this->numberFormat($this->price, $decimals, $decimalPoint, $thousandSeperator);
}
|
php
|
public function price($decimals = null, $decimalPoint = null, $thousandSeperator = null)
{
return $this->numberFormat($this->price, $decimals, $decimalPoint, $thousandSeperator);
}
|
[
"public",
"function",
"price",
"(",
"$",
"decimals",
"=",
"null",
",",
"$",
"decimalPoint",
"=",
"null",
",",
"$",
"thousandSeperator",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"numberFormat",
"(",
"$",
"this",
"->",
"price",
",",
"$",
"decimals",
",",
"$",
"decimalPoint",
",",
"$",
"thousandSeperator",
")",
";",
"}"
] |
Returns the formatted price without TAX.
@param int $decimals
@param string $decimalPoint
@param string $thousandSeperator
@return string
|
[
"Returns",
"the",
"formatted",
"price",
"without",
"TAX",
"."
] |
f460ab7312cce32cb428cf39a500a2d16600b1d6
|
https://github.com/Crinsane/LaravelShoppingcart/blob/f460ab7312cce32cb428cf39a500a2d16600b1d6/src/CartItem.php#L102-L105
|
220,940
|
Crinsane/LaravelShoppingcart
|
src/CartItem.php
|
CartItem.priceTax
|
public function priceTax($decimals = null, $decimalPoint = null, $thousandSeperator = null)
{
return $this->numberFormat($this->priceTax, $decimals, $decimalPoint, $thousandSeperator);
}
|
php
|
public function priceTax($decimals = null, $decimalPoint = null, $thousandSeperator = null)
{
return $this->numberFormat($this->priceTax, $decimals, $decimalPoint, $thousandSeperator);
}
|
[
"public",
"function",
"priceTax",
"(",
"$",
"decimals",
"=",
"null",
",",
"$",
"decimalPoint",
"=",
"null",
",",
"$",
"thousandSeperator",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"numberFormat",
"(",
"$",
"this",
"->",
"priceTax",
",",
"$",
"decimals",
",",
"$",
"decimalPoint",
",",
"$",
"thousandSeperator",
")",
";",
"}"
] |
Returns the formatted price with TAX.
@param int $decimals
@param string $decimalPoint
@param string $thousandSeperator
@return string
|
[
"Returns",
"the",
"formatted",
"price",
"with",
"TAX",
"."
] |
f460ab7312cce32cb428cf39a500a2d16600b1d6
|
https://github.com/Crinsane/LaravelShoppingcart/blob/f460ab7312cce32cb428cf39a500a2d16600b1d6/src/CartItem.php#L115-L118
|
220,941
|
Crinsane/LaravelShoppingcart
|
src/CartItem.php
|
CartItem.subtotal
|
public function subtotal($decimals = null, $decimalPoint = null, $thousandSeperator = null)
{
return $this->numberFormat($this->subtotal, $decimals, $decimalPoint, $thousandSeperator);
}
|
php
|
public function subtotal($decimals = null, $decimalPoint = null, $thousandSeperator = null)
{
return $this->numberFormat($this->subtotal, $decimals, $decimalPoint, $thousandSeperator);
}
|
[
"public",
"function",
"subtotal",
"(",
"$",
"decimals",
"=",
"null",
",",
"$",
"decimalPoint",
"=",
"null",
",",
"$",
"thousandSeperator",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"numberFormat",
"(",
"$",
"this",
"->",
"subtotal",
",",
"$",
"decimals",
",",
"$",
"decimalPoint",
",",
"$",
"thousandSeperator",
")",
";",
"}"
] |
Returns the formatted subtotal.
Subtotal is price for whole CartItem without TAX
@param int $decimals
@param string $decimalPoint
@param string $thousandSeperator
@return string
|
[
"Returns",
"the",
"formatted",
"subtotal",
".",
"Subtotal",
"is",
"price",
"for",
"whole",
"CartItem",
"without",
"TAX"
] |
f460ab7312cce32cb428cf39a500a2d16600b1d6
|
https://github.com/Crinsane/LaravelShoppingcart/blob/f460ab7312cce32cb428cf39a500a2d16600b1d6/src/CartItem.php#L129-L132
|
220,942
|
Crinsane/LaravelShoppingcart
|
src/CartItem.php
|
CartItem.total
|
public function total($decimals = null, $decimalPoint = null, $thousandSeperator = null)
{
return $this->numberFormat($this->total, $decimals, $decimalPoint, $thousandSeperator);
}
|
php
|
public function total($decimals = null, $decimalPoint = null, $thousandSeperator = null)
{
return $this->numberFormat($this->total, $decimals, $decimalPoint, $thousandSeperator);
}
|
[
"public",
"function",
"total",
"(",
"$",
"decimals",
"=",
"null",
",",
"$",
"decimalPoint",
"=",
"null",
",",
"$",
"thousandSeperator",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"numberFormat",
"(",
"$",
"this",
"->",
"total",
",",
"$",
"decimals",
",",
"$",
"decimalPoint",
",",
"$",
"thousandSeperator",
")",
";",
"}"
] |
Returns the formatted total.
Total is price for whole CartItem with TAX
@param int $decimals
@param string $decimalPoint
@param string $thousandSeperator
@return string
|
[
"Returns",
"the",
"formatted",
"total",
".",
"Total",
"is",
"price",
"for",
"whole",
"CartItem",
"with",
"TAX"
] |
f460ab7312cce32cb428cf39a500a2d16600b1d6
|
https://github.com/Crinsane/LaravelShoppingcart/blob/f460ab7312cce32cb428cf39a500a2d16600b1d6/src/CartItem.php#L143-L146
|
220,943
|
Crinsane/LaravelShoppingcart
|
src/CartItem.php
|
CartItem.setQuantity
|
public function setQuantity($qty)
{
if(empty($qty) || ! is_numeric($qty))
throw new \InvalidArgumentException('Please supply a valid quantity.');
$this->qty = $qty;
}
|
php
|
public function setQuantity($qty)
{
if(empty($qty) || ! is_numeric($qty))
throw new \InvalidArgumentException('Please supply a valid quantity.');
$this->qty = $qty;
}
|
[
"public",
"function",
"setQuantity",
"(",
"$",
"qty",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"qty",
")",
"||",
"!",
"is_numeric",
"(",
"$",
"qty",
")",
")",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Please supply a valid quantity.'",
")",
";",
"$",
"this",
"->",
"qty",
"=",
"$",
"qty",
";",
"}"
] |
Set the quantity for this cart item.
@param int|float $qty
|
[
"Set",
"the",
"quantity",
"for",
"this",
"cart",
"item",
"."
] |
f460ab7312cce32cb428cf39a500a2d16600b1d6
|
https://github.com/Crinsane/LaravelShoppingcart/blob/f460ab7312cce32cb428cf39a500a2d16600b1d6/src/CartItem.php#L179-L185
|
220,944
|
Crinsane/LaravelShoppingcart
|
src/CartItem.php
|
CartItem.updateFromBuyable
|
public function updateFromBuyable(Buyable $item)
{
$this->id = $item->getBuyableIdentifier($this->options);
$this->name = $item->getBuyableDescription($this->options);
$this->price = $item->getBuyablePrice($this->options);
$this->priceTax = $this->price + $this->tax;
}
|
php
|
public function updateFromBuyable(Buyable $item)
{
$this->id = $item->getBuyableIdentifier($this->options);
$this->name = $item->getBuyableDescription($this->options);
$this->price = $item->getBuyablePrice($this->options);
$this->priceTax = $this->price + $this->tax;
}
|
[
"public",
"function",
"updateFromBuyable",
"(",
"Buyable",
"$",
"item",
")",
"{",
"$",
"this",
"->",
"id",
"=",
"$",
"item",
"->",
"getBuyableIdentifier",
"(",
"$",
"this",
"->",
"options",
")",
";",
"$",
"this",
"->",
"name",
"=",
"$",
"item",
"->",
"getBuyableDescription",
"(",
"$",
"this",
"->",
"options",
")",
";",
"$",
"this",
"->",
"price",
"=",
"$",
"item",
"->",
"getBuyablePrice",
"(",
"$",
"this",
"->",
"options",
")",
";",
"$",
"this",
"->",
"priceTax",
"=",
"$",
"this",
"->",
"price",
"+",
"$",
"this",
"->",
"tax",
";",
"}"
] |
Update the cart item from a Buyable.
@param \Gloudemans\Shoppingcart\Contracts\Buyable $item
@return void
|
[
"Update",
"the",
"cart",
"item",
"from",
"a",
"Buyable",
"."
] |
f460ab7312cce32cb428cf39a500a2d16600b1d6
|
https://github.com/Crinsane/LaravelShoppingcart/blob/f460ab7312cce32cb428cf39a500a2d16600b1d6/src/CartItem.php#L193-L199
|
220,945
|
Crinsane/LaravelShoppingcart
|
src/CartItem.php
|
CartItem.updateFromArray
|
public function updateFromArray(array $attributes)
{
$this->id = array_get($attributes, 'id', $this->id);
$this->qty = array_get($attributes, 'qty', $this->qty);
$this->name = array_get($attributes, 'name', $this->name);
$this->price = array_get($attributes, 'price', $this->price);
$this->priceTax = $this->price + $this->tax;
$this->options = new CartItemOptions(array_get($attributes, 'options', $this->options));
$this->rowId = $this->generateRowId($this->id, $this->options->all());
}
|
php
|
public function updateFromArray(array $attributes)
{
$this->id = array_get($attributes, 'id', $this->id);
$this->qty = array_get($attributes, 'qty', $this->qty);
$this->name = array_get($attributes, 'name', $this->name);
$this->price = array_get($attributes, 'price', $this->price);
$this->priceTax = $this->price + $this->tax;
$this->options = new CartItemOptions(array_get($attributes, 'options', $this->options));
$this->rowId = $this->generateRowId($this->id, $this->options->all());
}
|
[
"public",
"function",
"updateFromArray",
"(",
"array",
"$",
"attributes",
")",
"{",
"$",
"this",
"->",
"id",
"=",
"array_get",
"(",
"$",
"attributes",
",",
"'id'",
",",
"$",
"this",
"->",
"id",
")",
";",
"$",
"this",
"->",
"qty",
"=",
"array_get",
"(",
"$",
"attributes",
",",
"'qty'",
",",
"$",
"this",
"->",
"qty",
")",
";",
"$",
"this",
"->",
"name",
"=",
"array_get",
"(",
"$",
"attributes",
",",
"'name'",
",",
"$",
"this",
"->",
"name",
")",
";",
"$",
"this",
"->",
"price",
"=",
"array_get",
"(",
"$",
"attributes",
",",
"'price'",
",",
"$",
"this",
"->",
"price",
")",
";",
"$",
"this",
"->",
"priceTax",
"=",
"$",
"this",
"->",
"price",
"+",
"$",
"this",
"->",
"tax",
";",
"$",
"this",
"->",
"options",
"=",
"new",
"CartItemOptions",
"(",
"array_get",
"(",
"$",
"attributes",
",",
"'options'",
",",
"$",
"this",
"->",
"options",
")",
")",
";",
"$",
"this",
"->",
"rowId",
"=",
"$",
"this",
"->",
"generateRowId",
"(",
"$",
"this",
"->",
"id",
",",
"$",
"this",
"->",
"options",
"->",
"all",
"(",
")",
")",
";",
"}"
] |
Update the cart item from an array.
@param array $attributes
@return void
|
[
"Update",
"the",
"cart",
"item",
"from",
"an",
"array",
"."
] |
f460ab7312cce32cb428cf39a500a2d16600b1d6
|
https://github.com/Crinsane/LaravelShoppingcart/blob/f460ab7312cce32cb428cf39a500a2d16600b1d6/src/CartItem.php#L207-L217
|
220,946
|
Crinsane/LaravelShoppingcart
|
src/CartItem.php
|
CartItem.numberFormat
|
private function numberFormat($value, $decimals, $decimalPoint, $thousandSeperator)
{
if (is_null($decimals)){
$decimals = is_null(config('cart.format.decimals')) ? 2 : config('cart.format.decimals');
}
if (is_null($decimalPoint)){
$decimalPoint = is_null(config('cart.format.decimal_point')) ? '.' : config('cart.format.decimal_point');
}
if (is_null($thousandSeperator)){
$thousandSeperator = is_null(config('cart.format.thousand_seperator')) ? ',' : config('cart.format.thousand_seperator');
}
return number_format($value, $decimals, $decimalPoint, $thousandSeperator);
}
|
php
|
private function numberFormat($value, $decimals, $decimalPoint, $thousandSeperator)
{
if (is_null($decimals)){
$decimals = is_null(config('cart.format.decimals')) ? 2 : config('cart.format.decimals');
}
if (is_null($decimalPoint)){
$decimalPoint = is_null(config('cart.format.decimal_point')) ? '.' : config('cart.format.decimal_point');
}
if (is_null($thousandSeperator)){
$thousandSeperator = is_null(config('cart.format.thousand_seperator')) ? ',' : config('cart.format.thousand_seperator');
}
return number_format($value, $decimals, $decimalPoint, $thousandSeperator);
}
|
[
"private",
"function",
"numberFormat",
"(",
"$",
"value",
",",
"$",
"decimals",
",",
"$",
"decimalPoint",
",",
"$",
"thousandSeperator",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"decimals",
")",
")",
"{",
"$",
"decimals",
"=",
"is_null",
"(",
"config",
"(",
"'cart.format.decimals'",
")",
")",
"?",
"2",
":",
"config",
"(",
"'cart.format.decimals'",
")",
";",
"}",
"if",
"(",
"is_null",
"(",
"$",
"decimalPoint",
")",
")",
"{",
"$",
"decimalPoint",
"=",
"is_null",
"(",
"config",
"(",
"'cart.format.decimal_point'",
")",
")",
"?",
"'.'",
":",
"config",
"(",
"'cart.format.decimal_point'",
")",
";",
"}",
"if",
"(",
"is_null",
"(",
"$",
"thousandSeperator",
")",
")",
"{",
"$",
"thousandSeperator",
"=",
"is_null",
"(",
"config",
"(",
"'cart.format.thousand_seperator'",
")",
")",
"?",
"','",
":",
"config",
"(",
"'cart.format.thousand_seperator'",
")",
";",
"}",
"return",
"number_format",
"(",
"$",
"value",
",",
"$",
"decimals",
",",
"$",
"decimalPoint",
",",
"$",
"thousandSeperator",
")",
";",
"}"
] |
Get the formatted number.
@param float $value
@param int $decimals
@param string $decimalPoint
@param string $thousandSeperator
@return string
|
[
"Get",
"the",
"formatted",
"number",
"."
] |
f460ab7312cce32cb428cf39a500a2d16600b1d6
|
https://github.com/Crinsane/LaravelShoppingcart/blob/f460ab7312cce32cb428cf39a500a2d16600b1d6/src/CartItem.php#L376-L391
|
220,947
|
Crinsane/LaravelShoppingcart
|
src/Cart.php
|
Cart.instance
|
public function instance($instance = null)
{
$instance = $instance ?: self::DEFAULT_INSTANCE;
$this->instance = sprintf('%s.%s', 'cart', $instance);
return $this;
}
|
php
|
public function instance($instance = null)
{
$instance = $instance ?: self::DEFAULT_INSTANCE;
$this->instance = sprintf('%s.%s', 'cart', $instance);
return $this;
}
|
[
"public",
"function",
"instance",
"(",
"$",
"instance",
"=",
"null",
")",
"{",
"$",
"instance",
"=",
"$",
"instance",
"?",
":",
"self",
"::",
"DEFAULT_INSTANCE",
";",
"$",
"this",
"->",
"instance",
"=",
"sprintf",
"(",
"'%s.%s'",
",",
"'cart'",
",",
"$",
"instance",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Set the current cart instance.
@param string|null $instance
@return \Gloudemans\Shoppingcart\Cart
|
[
"Set",
"the",
"current",
"cart",
"instance",
"."
] |
f460ab7312cce32cb428cf39a500a2d16600b1d6
|
https://github.com/Crinsane/LaravelShoppingcart/blob/f460ab7312cce32cb428cf39a500a2d16600b1d6/src/Cart.php#L60-L67
|
220,948
|
Crinsane/LaravelShoppingcart
|
src/Cart.php
|
Cart.remove
|
public function remove($rowId)
{
$cartItem = $this->get($rowId);
$content = $this->getContent();
$content->pull($cartItem->rowId);
$this->events->fire('cart.removed', $cartItem);
$this->session->put($this->instance, $content);
}
|
php
|
public function remove($rowId)
{
$cartItem = $this->get($rowId);
$content = $this->getContent();
$content->pull($cartItem->rowId);
$this->events->fire('cart.removed', $cartItem);
$this->session->put($this->instance, $content);
}
|
[
"public",
"function",
"remove",
"(",
"$",
"rowId",
")",
"{",
"$",
"cartItem",
"=",
"$",
"this",
"->",
"get",
"(",
"$",
"rowId",
")",
";",
"$",
"content",
"=",
"$",
"this",
"->",
"getContent",
"(",
")",
";",
"$",
"content",
"->",
"pull",
"(",
"$",
"cartItem",
"->",
"rowId",
")",
";",
"$",
"this",
"->",
"events",
"->",
"fire",
"(",
"'cart.removed'",
",",
"$",
"cartItem",
")",
";",
"$",
"this",
"->",
"session",
"->",
"put",
"(",
"$",
"this",
"->",
"instance",
",",
"$",
"content",
")",
";",
"}"
] |
Remove the cart item with the given rowId from the cart.
@param string $rowId
@return void
|
[
"Remove",
"the",
"cart",
"item",
"with",
"the",
"given",
"rowId",
"from",
"the",
"cart",
"."
] |
f460ab7312cce32cb428cf39a500a2d16600b1d6
|
https://github.com/Crinsane/LaravelShoppingcart/blob/f460ab7312cce32cb428cf39a500a2d16600b1d6/src/Cart.php#L164-L175
|
220,949
|
Crinsane/LaravelShoppingcart
|
src/Cart.php
|
Cart.content
|
public function content()
{
if (is_null($this->session->get($this->instance))) {
return new Collection([]);
}
return $this->session->get($this->instance);
}
|
php
|
public function content()
{
if (is_null($this->session->get($this->instance))) {
return new Collection([]);
}
return $this->session->get($this->instance);
}
|
[
"public",
"function",
"content",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"session",
"->",
"get",
"(",
"$",
"this",
"->",
"instance",
")",
")",
")",
"{",
"return",
"new",
"Collection",
"(",
"[",
"]",
")",
";",
"}",
"return",
"$",
"this",
"->",
"session",
"->",
"get",
"(",
"$",
"this",
"->",
"instance",
")",
";",
"}"
] |
Get the content of the cart.
@return \Illuminate\Support\Collection
|
[
"Get",
"the",
"content",
"of",
"the",
"cart",
"."
] |
f460ab7312cce32cb428cf39a500a2d16600b1d6
|
https://github.com/Crinsane/LaravelShoppingcart/blob/f460ab7312cce32cb428cf39a500a2d16600b1d6/src/Cart.php#L208-L215
|
220,950
|
Crinsane/LaravelShoppingcart
|
src/Cart.php
|
Cart.associate
|
public function associate($rowId, $model)
{
if(is_string($model) && ! class_exists($model)) {
throw new UnknownModelException("The supplied model {$model} does not exist.");
}
$cartItem = $this->get($rowId);
$cartItem->associate($model);
$content = $this->getContent();
$content->put($cartItem->rowId, $cartItem);
$this->session->put($this->instance, $content);
}
|
php
|
public function associate($rowId, $model)
{
if(is_string($model) && ! class_exists($model)) {
throw new UnknownModelException("The supplied model {$model} does not exist.");
}
$cartItem = $this->get($rowId);
$cartItem->associate($model);
$content = $this->getContent();
$content->put($cartItem->rowId, $cartItem);
$this->session->put($this->instance, $content);
}
|
[
"public",
"function",
"associate",
"(",
"$",
"rowId",
",",
"$",
"model",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"model",
")",
"&&",
"!",
"class_exists",
"(",
"$",
"model",
")",
")",
"{",
"throw",
"new",
"UnknownModelException",
"(",
"\"The supplied model {$model} does not exist.\"",
")",
";",
"}",
"$",
"cartItem",
"=",
"$",
"this",
"->",
"get",
"(",
"$",
"rowId",
")",
";",
"$",
"cartItem",
"->",
"associate",
"(",
"$",
"model",
")",
";",
"$",
"content",
"=",
"$",
"this",
"->",
"getContent",
"(",
")",
";",
"$",
"content",
"->",
"put",
"(",
"$",
"cartItem",
"->",
"rowId",
",",
"$",
"cartItem",
")",
";",
"$",
"this",
"->",
"session",
"->",
"put",
"(",
"$",
"this",
"->",
"instance",
",",
"$",
"content",
")",
";",
"}"
] |
Associate the cart item with the given rowId with the given model.
@param string $rowId
@param mixed $model
@return void
|
[
"Associate",
"the",
"cart",
"item",
"with",
"the",
"given",
"rowId",
"with",
"the",
"given",
"model",
"."
] |
f460ab7312cce32cb428cf39a500a2d16600b1d6
|
https://github.com/Crinsane/LaravelShoppingcart/blob/f460ab7312cce32cb428cf39a500a2d16600b1d6/src/Cart.php#L306-L321
|
220,951
|
Crinsane/LaravelShoppingcart
|
src/Cart.php
|
Cart.setTax
|
public function setTax($rowId, $taxRate)
{
$cartItem = $this->get($rowId);
$cartItem->setTaxRate($taxRate);
$content = $this->getContent();
$content->put($cartItem->rowId, $cartItem);
$this->session->put($this->instance, $content);
}
|
php
|
public function setTax($rowId, $taxRate)
{
$cartItem = $this->get($rowId);
$cartItem->setTaxRate($taxRate);
$content = $this->getContent();
$content->put($cartItem->rowId, $cartItem);
$this->session->put($this->instance, $content);
}
|
[
"public",
"function",
"setTax",
"(",
"$",
"rowId",
",",
"$",
"taxRate",
")",
"{",
"$",
"cartItem",
"=",
"$",
"this",
"->",
"get",
"(",
"$",
"rowId",
")",
";",
"$",
"cartItem",
"->",
"setTaxRate",
"(",
"$",
"taxRate",
")",
";",
"$",
"content",
"=",
"$",
"this",
"->",
"getContent",
"(",
")",
";",
"$",
"content",
"->",
"put",
"(",
"$",
"cartItem",
"->",
"rowId",
",",
"$",
"cartItem",
")",
";",
"$",
"this",
"->",
"session",
"->",
"put",
"(",
"$",
"this",
"->",
"instance",
",",
"$",
"content",
")",
";",
"}"
] |
Set the tax rate for the cart item with the given rowId.
@param string $rowId
@param int|float $taxRate
@return void
|
[
"Set",
"the",
"tax",
"rate",
"for",
"the",
"cart",
"item",
"with",
"the",
"given",
"rowId",
"."
] |
f460ab7312cce32cb428cf39a500a2d16600b1d6
|
https://github.com/Crinsane/LaravelShoppingcart/blob/f460ab7312cce32cb428cf39a500a2d16600b1d6/src/Cart.php#L330-L341
|
220,952
|
Crinsane/LaravelShoppingcart
|
src/Cart.php
|
Cart.store
|
public function store($identifier)
{
$content = $this->getContent();
if ($this->storedCartWithIdentifierExists($identifier)) {
throw new CartAlreadyStoredException("A cart with identifier {$identifier} was already stored.");
}
$this->getConnection()->table($this->getTableName())->insert([
'identifier' => $identifier,
'instance' => $this->currentInstance(),
'content' => serialize($content)
]);
$this->events->fire('cart.stored');
}
|
php
|
public function store($identifier)
{
$content = $this->getContent();
if ($this->storedCartWithIdentifierExists($identifier)) {
throw new CartAlreadyStoredException("A cart with identifier {$identifier} was already stored.");
}
$this->getConnection()->table($this->getTableName())->insert([
'identifier' => $identifier,
'instance' => $this->currentInstance(),
'content' => serialize($content)
]);
$this->events->fire('cart.stored');
}
|
[
"public",
"function",
"store",
"(",
"$",
"identifier",
")",
"{",
"$",
"content",
"=",
"$",
"this",
"->",
"getContent",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"storedCartWithIdentifierExists",
"(",
"$",
"identifier",
")",
")",
"{",
"throw",
"new",
"CartAlreadyStoredException",
"(",
"\"A cart with identifier {$identifier} was already stored.\"",
")",
";",
"}",
"$",
"this",
"->",
"getConnection",
"(",
")",
"->",
"table",
"(",
"$",
"this",
"->",
"getTableName",
"(",
")",
")",
"->",
"insert",
"(",
"[",
"'identifier'",
"=>",
"$",
"identifier",
",",
"'instance'",
"=>",
"$",
"this",
"->",
"currentInstance",
"(",
")",
",",
"'content'",
"=>",
"serialize",
"(",
"$",
"content",
")",
"]",
")",
";",
"$",
"this",
"->",
"events",
"->",
"fire",
"(",
"'cart.stored'",
")",
";",
"}"
] |
Store an the current instance of the cart.
@param mixed $identifier
@return void
|
[
"Store",
"an",
"the",
"current",
"instance",
"of",
"the",
"cart",
"."
] |
f460ab7312cce32cb428cf39a500a2d16600b1d6
|
https://github.com/Crinsane/LaravelShoppingcart/blob/f460ab7312cce32cb428cf39a500a2d16600b1d6/src/Cart.php#L349-L364
|
220,953
|
Crinsane/LaravelShoppingcart
|
src/Cart.php
|
Cart.restore
|
public function restore($identifier)
{
if( ! $this->storedCartWithIdentifierExists($identifier)) {
return;
}
$stored = $this->getConnection()->table($this->getTableName())
->where('identifier', $identifier)->first();
$storedContent = unserialize($stored->content);
$currentInstance = $this->currentInstance();
$this->instance($stored->instance);
$content = $this->getContent();
foreach ($storedContent as $cartItem) {
$content->put($cartItem->rowId, $cartItem);
}
$this->events->fire('cart.restored');
$this->session->put($this->instance, $content);
$this->instance($currentInstance);
$this->getConnection()->table($this->getTableName())
->where('identifier', $identifier)->delete();
}
|
php
|
public function restore($identifier)
{
if( ! $this->storedCartWithIdentifierExists($identifier)) {
return;
}
$stored = $this->getConnection()->table($this->getTableName())
->where('identifier', $identifier)->first();
$storedContent = unserialize($stored->content);
$currentInstance = $this->currentInstance();
$this->instance($stored->instance);
$content = $this->getContent();
foreach ($storedContent as $cartItem) {
$content->put($cartItem->rowId, $cartItem);
}
$this->events->fire('cart.restored');
$this->session->put($this->instance, $content);
$this->instance($currentInstance);
$this->getConnection()->table($this->getTableName())
->where('identifier', $identifier)->delete();
}
|
[
"public",
"function",
"restore",
"(",
"$",
"identifier",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"storedCartWithIdentifierExists",
"(",
"$",
"identifier",
")",
")",
"{",
"return",
";",
"}",
"$",
"stored",
"=",
"$",
"this",
"->",
"getConnection",
"(",
")",
"->",
"table",
"(",
"$",
"this",
"->",
"getTableName",
"(",
")",
")",
"->",
"where",
"(",
"'identifier'",
",",
"$",
"identifier",
")",
"->",
"first",
"(",
")",
";",
"$",
"storedContent",
"=",
"unserialize",
"(",
"$",
"stored",
"->",
"content",
")",
";",
"$",
"currentInstance",
"=",
"$",
"this",
"->",
"currentInstance",
"(",
")",
";",
"$",
"this",
"->",
"instance",
"(",
"$",
"stored",
"->",
"instance",
")",
";",
"$",
"content",
"=",
"$",
"this",
"->",
"getContent",
"(",
")",
";",
"foreach",
"(",
"$",
"storedContent",
"as",
"$",
"cartItem",
")",
"{",
"$",
"content",
"->",
"put",
"(",
"$",
"cartItem",
"->",
"rowId",
",",
"$",
"cartItem",
")",
";",
"}",
"$",
"this",
"->",
"events",
"->",
"fire",
"(",
"'cart.restored'",
")",
";",
"$",
"this",
"->",
"session",
"->",
"put",
"(",
"$",
"this",
"->",
"instance",
",",
"$",
"content",
")",
";",
"$",
"this",
"->",
"instance",
"(",
"$",
"currentInstance",
")",
";",
"$",
"this",
"->",
"getConnection",
"(",
")",
"->",
"table",
"(",
"$",
"this",
"->",
"getTableName",
"(",
")",
")",
"->",
"where",
"(",
"'identifier'",
",",
"$",
"identifier",
")",
"->",
"delete",
"(",
")",
";",
"}"
] |
Restore the cart with the given identifier.
@param mixed $identifier
@return void
|
[
"Restore",
"the",
"cart",
"with",
"the",
"given",
"identifier",
"."
] |
f460ab7312cce32cb428cf39a500a2d16600b1d6
|
https://github.com/Crinsane/LaravelShoppingcart/blob/f460ab7312cce32cb428cf39a500a2d16600b1d6/src/Cart.php#L372-L401
|
220,954
|
Crinsane/LaravelShoppingcart
|
src/Cart.php
|
Cart.getContent
|
protected function getContent()
{
$content = $this->session->has($this->instance)
? $this->session->get($this->instance)
: new Collection;
return $content;
}
|
php
|
protected function getContent()
{
$content = $this->session->has($this->instance)
? $this->session->get($this->instance)
: new Collection;
return $content;
}
|
[
"protected",
"function",
"getContent",
"(",
")",
"{",
"$",
"content",
"=",
"$",
"this",
"->",
"session",
"->",
"has",
"(",
"$",
"this",
"->",
"instance",
")",
"?",
"$",
"this",
"->",
"session",
"->",
"get",
"(",
"$",
"this",
"->",
"instance",
")",
":",
"new",
"Collection",
";",
"return",
"$",
"content",
";",
"}"
] |
Get the carts content, if there is no cart content set yet, return a new empty Collection
@return \Illuminate\Support\Collection
|
[
"Get",
"the",
"carts",
"content",
"if",
"there",
"is",
"no",
"cart",
"content",
"set",
"yet",
"return",
"a",
"new",
"empty",
"Collection"
] |
f460ab7312cce32cb428cf39a500a2d16600b1d6
|
https://github.com/Crinsane/LaravelShoppingcart/blob/f460ab7312cce32cb428cf39a500a2d16600b1d6/src/Cart.php#L431-L438
|
220,955
|
Crinsane/LaravelShoppingcart
|
src/Cart.php
|
Cart.createCartItem
|
private function createCartItem($id, $name, $qty, $price, array $options)
{
if ($id instanceof Buyable) {
$cartItem = CartItem::fromBuyable($id, $qty ?: []);
$cartItem->setQuantity($name ?: 1);
$cartItem->associate($id);
} elseif (is_array($id)) {
$cartItem = CartItem::fromArray($id);
$cartItem->setQuantity($id['qty']);
} else {
$cartItem = CartItem::fromAttributes($id, $name, $price, $options);
$cartItem->setQuantity($qty);
}
$cartItem->setTaxRate(config('cart.tax'));
return $cartItem;
}
|
php
|
private function createCartItem($id, $name, $qty, $price, array $options)
{
if ($id instanceof Buyable) {
$cartItem = CartItem::fromBuyable($id, $qty ?: []);
$cartItem->setQuantity($name ?: 1);
$cartItem->associate($id);
} elseif (is_array($id)) {
$cartItem = CartItem::fromArray($id);
$cartItem->setQuantity($id['qty']);
} else {
$cartItem = CartItem::fromAttributes($id, $name, $price, $options);
$cartItem->setQuantity($qty);
}
$cartItem->setTaxRate(config('cart.tax'));
return $cartItem;
}
|
[
"private",
"function",
"createCartItem",
"(",
"$",
"id",
",",
"$",
"name",
",",
"$",
"qty",
",",
"$",
"price",
",",
"array",
"$",
"options",
")",
"{",
"if",
"(",
"$",
"id",
"instanceof",
"Buyable",
")",
"{",
"$",
"cartItem",
"=",
"CartItem",
"::",
"fromBuyable",
"(",
"$",
"id",
",",
"$",
"qty",
"?",
":",
"[",
"]",
")",
";",
"$",
"cartItem",
"->",
"setQuantity",
"(",
"$",
"name",
"?",
":",
"1",
")",
";",
"$",
"cartItem",
"->",
"associate",
"(",
"$",
"id",
")",
";",
"}",
"elseif",
"(",
"is_array",
"(",
"$",
"id",
")",
")",
"{",
"$",
"cartItem",
"=",
"CartItem",
"::",
"fromArray",
"(",
"$",
"id",
")",
";",
"$",
"cartItem",
"->",
"setQuantity",
"(",
"$",
"id",
"[",
"'qty'",
"]",
")",
";",
"}",
"else",
"{",
"$",
"cartItem",
"=",
"CartItem",
"::",
"fromAttributes",
"(",
"$",
"id",
",",
"$",
"name",
",",
"$",
"price",
",",
"$",
"options",
")",
";",
"$",
"cartItem",
"->",
"setQuantity",
"(",
"$",
"qty",
")",
";",
"}",
"$",
"cartItem",
"->",
"setTaxRate",
"(",
"config",
"(",
"'cart.tax'",
")",
")",
";",
"return",
"$",
"cartItem",
";",
"}"
] |
Create a new CartItem from the supplied attributes.
@param mixed $id
@param mixed $name
@param int|float $qty
@param float $price
@param array $options
@return \Gloudemans\Shoppingcart\CartItem
|
[
"Create",
"a",
"new",
"CartItem",
"from",
"the",
"supplied",
"attributes",
"."
] |
f460ab7312cce32cb428cf39a500a2d16600b1d6
|
https://github.com/Crinsane/LaravelShoppingcart/blob/f460ab7312cce32cb428cf39a500a2d16600b1d6/src/Cart.php#L450-L467
|
220,956
|
Crinsane/LaravelShoppingcart
|
src/Cart.php
|
Cart.isMulti
|
private function isMulti($item)
{
if ( ! is_array($item)) return false;
return is_array(head($item)) || head($item) instanceof Buyable;
}
|
php
|
private function isMulti($item)
{
if ( ! is_array($item)) return false;
return is_array(head($item)) || head($item) instanceof Buyable;
}
|
[
"private",
"function",
"isMulti",
"(",
"$",
"item",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"item",
")",
")",
"return",
"false",
";",
"return",
"is_array",
"(",
"head",
"(",
"$",
"item",
")",
")",
"||",
"head",
"(",
"$",
"item",
")",
"instanceof",
"Buyable",
";",
"}"
] |
Check if the item is a multidimensional array or an array of Buyables.
@param mixed $item
@return bool
|
[
"Check",
"if",
"the",
"item",
"is",
"a",
"multidimensional",
"array",
"or",
"an",
"array",
"of",
"Buyables",
"."
] |
f460ab7312cce32cb428cf39a500a2d16600b1d6
|
https://github.com/Crinsane/LaravelShoppingcart/blob/f460ab7312cce32cb428cf39a500a2d16600b1d6/src/Cart.php#L475-L480
|
220,957
|
InfyOmLabs/laravel-generator
|
src/Utils/TableFieldsGenerator.php
|
TableFieldsGenerator.prepareFieldsFromTable
|
public function prepareFieldsFromTable()
{
foreach ($this->columns as $column) {
$type = $column->getType()->getName();
switch ($type) {
case 'integer':
$field = $this->generateIntFieldInput($column, 'integer');
break;
case 'smallint':
$field = $this->generateIntFieldInput($column, 'smallInteger');
break;
case 'bigint':
$field = $this->generateIntFieldInput($column, 'bigInteger');
break;
case 'boolean':
$name = title_case(str_replace('_', ' ', $column->getName()));
$field = $this->generateField($column, 'boolean', 'checkbox,1');
break;
case 'datetime':
$field = $this->generateField($column, 'datetime', 'date');
break;
case 'datetimetz':
$field = $this->generateField($column, 'dateTimeTz', 'date');
break;
case 'date':
$field = $this->generateField($column, 'date', 'date');
break;
case 'time':
$field = $this->generateField($column, 'time', 'text');
break;
case 'decimal':
$field = $this->generateNumberInput($column, 'decimal');
break;
case 'float':
$field = $this->generateNumberInput($column, 'float');
break;
case 'string':
$field = $this->generateField($column, 'string', 'text');
break;
case 'text':
$field = $this->generateField($column, 'text', 'textarea');
break;
default:
$field = $this->generateField($column, 'string', 'text');
break;
}
if (strtolower($field->name) == 'password') {
$field->htmlType = 'password';
} elseif (strtolower($field->name) == 'email') {
$field->htmlType = 'email';
} elseif (in_array($field->name, $this->timestamps)) {
$field->isSearchable = false;
$field->isFillable = false;
$field->inForm = false;
$field->inIndex = false;
}
$field->isNotNull = (bool) $column->getNotNull();
$field->description = $column->getComment(); // get comments from table
$this->fields[] = $field;
}
}
|
php
|
public function prepareFieldsFromTable()
{
foreach ($this->columns as $column) {
$type = $column->getType()->getName();
switch ($type) {
case 'integer':
$field = $this->generateIntFieldInput($column, 'integer');
break;
case 'smallint':
$field = $this->generateIntFieldInput($column, 'smallInteger');
break;
case 'bigint':
$field = $this->generateIntFieldInput($column, 'bigInteger');
break;
case 'boolean':
$name = title_case(str_replace('_', ' ', $column->getName()));
$field = $this->generateField($column, 'boolean', 'checkbox,1');
break;
case 'datetime':
$field = $this->generateField($column, 'datetime', 'date');
break;
case 'datetimetz':
$field = $this->generateField($column, 'dateTimeTz', 'date');
break;
case 'date':
$field = $this->generateField($column, 'date', 'date');
break;
case 'time':
$field = $this->generateField($column, 'time', 'text');
break;
case 'decimal':
$field = $this->generateNumberInput($column, 'decimal');
break;
case 'float':
$field = $this->generateNumberInput($column, 'float');
break;
case 'string':
$field = $this->generateField($column, 'string', 'text');
break;
case 'text':
$field = $this->generateField($column, 'text', 'textarea');
break;
default:
$field = $this->generateField($column, 'string', 'text');
break;
}
if (strtolower($field->name) == 'password') {
$field->htmlType = 'password';
} elseif (strtolower($field->name) == 'email') {
$field->htmlType = 'email';
} elseif (in_array($field->name, $this->timestamps)) {
$field->isSearchable = false;
$field->isFillable = false;
$field->inForm = false;
$field->inIndex = false;
}
$field->isNotNull = (bool) $column->getNotNull();
$field->description = $column->getComment(); // get comments from table
$this->fields[] = $field;
}
}
|
[
"public",
"function",
"prepareFieldsFromTable",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"columns",
"as",
"$",
"column",
")",
"{",
"$",
"type",
"=",
"$",
"column",
"->",
"getType",
"(",
")",
"->",
"getName",
"(",
")",
";",
"switch",
"(",
"$",
"type",
")",
"{",
"case",
"'integer'",
":",
"$",
"field",
"=",
"$",
"this",
"->",
"generateIntFieldInput",
"(",
"$",
"column",
",",
"'integer'",
")",
";",
"break",
";",
"case",
"'smallint'",
":",
"$",
"field",
"=",
"$",
"this",
"->",
"generateIntFieldInput",
"(",
"$",
"column",
",",
"'smallInteger'",
")",
";",
"break",
";",
"case",
"'bigint'",
":",
"$",
"field",
"=",
"$",
"this",
"->",
"generateIntFieldInput",
"(",
"$",
"column",
",",
"'bigInteger'",
")",
";",
"break",
";",
"case",
"'boolean'",
":",
"$",
"name",
"=",
"title_case",
"(",
"str_replace",
"(",
"'_'",
",",
"' '",
",",
"$",
"column",
"->",
"getName",
"(",
")",
")",
")",
";",
"$",
"field",
"=",
"$",
"this",
"->",
"generateField",
"(",
"$",
"column",
",",
"'boolean'",
",",
"'checkbox,1'",
")",
";",
"break",
";",
"case",
"'datetime'",
":",
"$",
"field",
"=",
"$",
"this",
"->",
"generateField",
"(",
"$",
"column",
",",
"'datetime'",
",",
"'date'",
")",
";",
"break",
";",
"case",
"'datetimetz'",
":",
"$",
"field",
"=",
"$",
"this",
"->",
"generateField",
"(",
"$",
"column",
",",
"'dateTimeTz'",
",",
"'date'",
")",
";",
"break",
";",
"case",
"'date'",
":",
"$",
"field",
"=",
"$",
"this",
"->",
"generateField",
"(",
"$",
"column",
",",
"'date'",
",",
"'date'",
")",
";",
"break",
";",
"case",
"'time'",
":",
"$",
"field",
"=",
"$",
"this",
"->",
"generateField",
"(",
"$",
"column",
",",
"'time'",
",",
"'text'",
")",
";",
"break",
";",
"case",
"'decimal'",
":",
"$",
"field",
"=",
"$",
"this",
"->",
"generateNumberInput",
"(",
"$",
"column",
",",
"'decimal'",
")",
";",
"break",
";",
"case",
"'float'",
":",
"$",
"field",
"=",
"$",
"this",
"->",
"generateNumberInput",
"(",
"$",
"column",
",",
"'float'",
")",
";",
"break",
";",
"case",
"'string'",
":",
"$",
"field",
"=",
"$",
"this",
"->",
"generateField",
"(",
"$",
"column",
",",
"'string'",
",",
"'text'",
")",
";",
"break",
";",
"case",
"'text'",
":",
"$",
"field",
"=",
"$",
"this",
"->",
"generateField",
"(",
"$",
"column",
",",
"'text'",
",",
"'textarea'",
")",
";",
"break",
";",
"default",
":",
"$",
"field",
"=",
"$",
"this",
"->",
"generateField",
"(",
"$",
"column",
",",
"'string'",
",",
"'text'",
")",
";",
"break",
";",
"}",
"if",
"(",
"strtolower",
"(",
"$",
"field",
"->",
"name",
")",
"==",
"'password'",
")",
"{",
"$",
"field",
"->",
"htmlType",
"=",
"'password'",
";",
"}",
"elseif",
"(",
"strtolower",
"(",
"$",
"field",
"->",
"name",
")",
"==",
"'email'",
")",
"{",
"$",
"field",
"->",
"htmlType",
"=",
"'email'",
";",
"}",
"elseif",
"(",
"in_array",
"(",
"$",
"field",
"->",
"name",
",",
"$",
"this",
"->",
"timestamps",
")",
")",
"{",
"$",
"field",
"->",
"isSearchable",
"=",
"false",
";",
"$",
"field",
"->",
"isFillable",
"=",
"false",
";",
"$",
"field",
"->",
"inForm",
"=",
"false",
";",
"$",
"field",
"->",
"inIndex",
"=",
"false",
";",
"}",
"$",
"field",
"->",
"isNotNull",
"=",
"(",
"bool",
")",
"$",
"column",
"->",
"getNotNull",
"(",
")",
";",
"$",
"field",
"->",
"description",
"=",
"$",
"column",
"->",
"getComment",
"(",
")",
";",
"// get comments from table",
"$",
"this",
"->",
"fields",
"[",
"]",
"=",
"$",
"field",
";",
"}",
"}"
] |
Prepares array of GeneratorField from table columns.
|
[
"Prepares",
"array",
"of",
"GeneratorField",
"from",
"table",
"columns",
"."
] |
2dc3d4d62f735e3216fcda242f70c9e073154312
|
https://github.com/InfyOmLabs/laravel-generator/blob/2dc3d4d62f735e3216fcda242f70c9e073154312/src/Utils/TableFieldsGenerator.php#L92-L155
|
220,958
|
InfyOmLabs/laravel-generator
|
src/Utils/TableFieldsGenerator.php
|
TableFieldsGenerator.getPrimaryKeyOfTable
|
public static function getPrimaryKeyOfTable($tableName)
{
$schema = DB::getDoctrineSchemaManager();
$column = $schema->listTableDetails($tableName)->getPrimaryKey();
return $column ? $column->getColumns()[0] : '';
}
|
php
|
public static function getPrimaryKeyOfTable($tableName)
{
$schema = DB::getDoctrineSchemaManager();
$column = $schema->listTableDetails($tableName)->getPrimaryKey();
return $column ? $column->getColumns()[0] : '';
}
|
[
"public",
"static",
"function",
"getPrimaryKeyOfTable",
"(",
"$",
"tableName",
")",
"{",
"$",
"schema",
"=",
"DB",
"::",
"getDoctrineSchemaManager",
"(",
")",
";",
"$",
"column",
"=",
"$",
"schema",
"->",
"listTableDetails",
"(",
"$",
"tableName",
")",
"->",
"getPrimaryKey",
"(",
")",
";",
"return",
"$",
"column",
"?",
"$",
"column",
"->",
"getColumns",
"(",
")",
"[",
"0",
"]",
":",
"''",
";",
"}"
] |
Get primary key of given table.
@param string $tableName
@return string|null The column name of the (simple) primary key
|
[
"Get",
"primary",
"key",
"of",
"given",
"table",
"."
] |
2dc3d4d62f735e3216fcda242f70c9e073154312
|
https://github.com/InfyOmLabs/laravel-generator/blob/2dc3d4d62f735e3216fcda242f70c9e073154312/src/Utils/TableFieldsGenerator.php#L164-L170
|
220,959
|
InfyOmLabs/laravel-generator
|
src/Utils/TableFieldsGenerator.php
|
TableFieldsGenerator.getTimestampFieldNames
|
public static function getTimestampFieldNames()
{
if (!config('infyom.laravel_generator.timestamps.enabled', true)) {
return [];
}
$createdAtName = config('infyom.laravel_generator.timestamps.created_at', 'created_at');
$updatedAtName = config('infyom.laravel_generator.timestamps.updated_at', 'updated_at');
$deletedAtName = config('infyom.laravel_generator.timestamps.deleted_at', 'deleted_at');
return [$createdAtName, $updatedAtName, $deletedAtName];
}
|
php
|
public static function getTimestampFieldNames()
{
if (!config('infyom.laravel_generator.timestamps.enabled', true)) {
return [];
}
$createdAtName = config('infyom.laravel_generator.timestamps.created_at', 'created_at');
$updatedAtName = config('infyom.laravel_generator.timestamps.updated_at', 'updated_at');
$deletedAtName = config('infyom.laravel_generator.timestamps.deleted_at', 'deleted_at');
return [$createdAtName, $updatedAtName, $deletedAtName];
}
|
[
"public",
"static",
"function",
"getTimestampFieldNames",
"(",
")",
"{",
"if",
"(",
"!",
"config",
"(",
"'infyom.laravel_generator.timestamps.enabled'",
",",
"true",
")",
")",
"{",
"return",
"[",
"]",
";",
"}",
"$",
"createdAtName",
"=",
"config",
"(",
"'infyom.laravel_generator.timestamps.created_at'",
",",
"'created_at'",
")",
";",
"$",
"updatedAtName",
"=",
"config",
"(",
"'infyom.laravel_generator.timestamps.updated_at'",
",",
"'updated_at'",
")",
";",
"$",
"deletedAtName",
"=",
"config",
"(",
"'infyom.laravel_generator.timestamps.deleted_at'",
",",
"'deleted_at'",
")",
";",
"return",
"[",
"$",
"createdAtName",
",",
"$",
"updatedAtName",
",",
"$",
"deletedAtName",
"]",
";",
"}"
] |
Get timestamp columns from config.
@return array the set of [created_at column name, updated_at column name]
|
[
"Get",
"timestamp",
"columns",
"from",
"config",
"."
] |
2dc3d4d62f735e3216fcda242f70c9e073154312
|
https://github.com/InfyOmLabs/laravel-generator/blob/2dc3d4d62f735e3216fcda242f70c9e073154312/src/Utils/TableFieldsGenerator.php#L177-L188
|
220,960
|
InfyOmLabs/laravel-generator
|
src/Utils/TableFieldsGenerator.php
|
TableFieldsGenerator.generateIntFieldInput
|
private function generateIntFieldInput($column, $dbType)
{
$field = new GeneratorField();
$field->name = $column->getName();
$field->parseDBType($dbType);
$field->htmlType = 'number';
if ($column->getAutoincrement()) {
$field->dbInput .= ',true';
} else {
$field->dbInput .= ',false';
}
if ($column->getUnsigned()) {
$field->dbInput .= ',true';
}
return $this->checkForPrimary($field);
}
|
php
|
private function generateIntFieldInput($column, $dbType)
{
$field = new GeneratorField();
$field->name = $column->getName();
$field->parseDBType($dbType);
$field->htmlType = 'number';
if ($column->getAutoincrement()) {
$field->dbInput .= ',true';
} else {
$field->dbInput .= ',false';
}
if ($column->getUnsigned()) {
$field->dbInput .= ',true';
}
return $this->checkForPrimary($field);
}
|
[
"private",
"function",
"generateIntFieldInput",
"(",
"$",
"column",
",",
"$",
"dbType",
")",
"{",
"$",
"field",
"=",
"new",
"GeneratorField",
"(",
")",
";",
"$",
"field",
"->",
"name",
"=",
"$",
"column",
"->",
"getName",
"(",
")",
";",
"$",
"field",
"->",
"parseDBType",
"(",
"$",
"dbType",
")",
";",
"$",
"field",
"->",
"htmlType",
"=",
"'number'",
";",
"if",
"(",
"$",
"column",
"->",
"getAutoincrement",
"(",
")",
")",
"{",
"$",
"field",
"->",
"dbInput",
".=",
"',true'",
";",
"}",
"else",
"{",
"$",
"field",
"->",
"dbInput",
".=",
"',false'",
";",
"}",
"if",
"(",
"$",
"column",
"->",
"getUnsigned",
"(",
")",
")",
"{",
"$",
"field",
"->",
"dbInput",
".=",
"',true'",
";",
"}",
"return",
"$",
"this",
"->",
"checkForPrimary",
"(",
"$",
"field",
")",
";",
"}"
] |
Generates integer text field for database.
@param string $dbType
@param \Doctrine\DBAL\Schema\Column $column
@return GeneratorField
|
[
"Generates",
"integer",
"text",
"field",
"for",
"database",
"."
] |
2dc3d4d62f735e3216fcda242f70c9e073154312
|
https://github.com/InfyOmLabs/laravel-generator/blob/2dc3d4d62f735e3216fcda242f70c9e073154312/src/Utils/TableFieldsGenerator.php#L198-L216
|
220,961
|
InfyOmLabs/laravel-generator
|
src/Utils/TableFieldsGenerator.php
|
TableFieldsGenerator.checkForPrimary
|
private function checkForPrimary(GeneratorField $field)
{
if ($field->name == $this->primaryKey) {
$field->isPrimary = true;
$field->isFillable = false;
$field->isSearchable = false;
$field->inIndex = false;
$field->inForm = false;
}
return $field;
}
|
php
|
private function checkForPrimary(GeneratorField $field)
{
if ($field->name == $this->primaryKey) {
$field->isPrimary = true;
$field->isFillable = false;
$field->isSearchable = false;
$field->inIndex = false;
$field->inForm = false;
}
return $field;
}
|
[
"private",
"function",
"checkForPrimary",
"(",
"GeneratorField",
"$",
"field",
")",
"{",
"if",
"(",
"$",
"field",
"->",
"name",
"==",
"$",
"this",
"->",
"primaryKey",
")",
"{",
"$",
"field",
"->",
"isPrimary",
"=",
"true",
";",
"$",
"field",
"->",
"isFillable",
"=",
"false",
";",
"$",
"field",
"->",
"isSearchable",
"=",
"false",
";",
"$",
"field",
"->",
"inIndex",
"=",
"false",
";",
"$",
"field",
"->",
"inForm",
"=",
"false",
";",
"}",
"return",
"$",
"field",
";",
"}"
] |
Check if key is primary key and sets field options.
@param GeneratorField $field
@return GeneratorField
|
[
"Check",
"if",
"key",
"is",
"primary",
"key",
"and",
"sets",
"field",
"options",
"."
] |
2dc3d4d62f735e3216fcda242f70c9e073154312
|
https://github.com/InfyOmLabs/laravel-generator/blob/2dc3d4d62f735e3216fcda242f70c9e073154312/src/Utils/TableFieldsGenerator.php#L225-L236
|
220,962
|
InfyOmLabs/laravel-generator
|
src/Utils/TableFieldsGenerator.php
|
TableFieldsGenerator.generateField
|
private function generateField($column, $dbType, $htmlType)
{
$field = new GeneratorField();
$field->name = $column->getName();
$field->parseDBType($dbType);
$field->parseHtmlInput($htmlType);
return $this->checkForPrimary($field);
}
|
php
|
private function generateField($column, $dbType, $htmlType)
{
$field = new GeneratorField();
$field->name = $column->getName();
$field->parseDBType($dbType);
$field->parseHtmlInput($htmlType);
return $this->checkForPrimary($field);
}
|
[
"private",
"function",
"generateField",
"(",
"$",
"column",
",",
"$",
"dbType",
",",
"$",
"htmlType",
")",
"{",
"$",
"field",
"=",
"new",
"GeneratorField",
"(",
")",
";",
"$",
"field",
"->",
"name",
"=",
"$",
"column",
"->",
"getName",
"(",
")",
";",
"$",
"field",
"->",
"parseDBType",
"(",
"$",
"dbType",
")",
";",
"$",
"field",
"->",
"parseHtmlInput",
"(",
"$",
"htmlType",
")",
";",
"return",
"$",
"this",
"->",
"checkForPrimary",
"(",
"$",
"field",
")",
";",
"}"
] |
Generates field.
@param \Doctrine\DBAL\Schema\Column $column
@param $dbType
@param $htmlType
@return GeneratorField
|
[
"Generates",
"field",
"."
] |
2dc3d4d62f735e3216fcda242f70c9e073154312
|
https://github.com/InfyOmLabs/laravel-generator/blob/2dc3d4d62f735e3216fcda242f70c9e073154312/src/Utils/TableFieldsGenerator.php#L247-L255
|
220,963
|
InfyOmLabs/laravel-generator
|
src/Utils/TableFieldsGenerator.php
|
TableFieldsGenerator.generateNumberInput
|
private function generateNumberInput($column, $dbType)
{
$field = new GeneratorField();
$field->name = $column->getName();
$field->parseDBType($dbType.','.$column->getPrecision().','.$column->getScale());
$field->htmlType = 'number';
return $this->checkForPrimary($field);
}
|
php
|
private function generateNumberInput($column, $dbType)
{
$field = new GeneratorField();
$field->name = $column->getName();
$field->parseDBType($dbType.','.$column->getPrecision().','.$column->getScale());
$field->htmlType = 'number';
return $this->checkForPrimary($field);
}
|
[
"private",
"function",
"generateNumberInput",
"(",
"$",
"column",
",",
"$",
"dbType",
")",
"{",
"$",
"field",
"=",
"new",
"GeneratorField",
"(",
")",
";",
"$",
"field",
"->",
"name",
"=",
"$",
"column",
"->",
"getName",
"(",
")",
";",
"$",
"field",
"->",
"parseDBType",
"(",
"$",
"dbType",
".",
"','",
".",
"$",
"column",
"->",
"getPrecision",
"(",
")",
".",
"','",
".",
"$",
"column",
"->",
"getScale",
"(",
")",
")",
";",
"$",
"field",
"->",
"htmlType",
"=",
"'number'",
";",
"return",
"$",
"this",
"->",
"checkForPrimary",
"(",
"$",
"field",
")",
";",
"}"
] |
Generates number field.
@param \Doctrine\DBAL\Schema\Column $column
@param string $dbType
@return GeneratorField
|
[
"Generates",
"number",
"field",
"."
] |
2dc3d4d62f735e3216fcda242f70c9e073154312
|
https://github.com/InfyOmLabs/laravel-generator/blob/2dc3d4d62f735e3216fcda242f70c9e073154312/src/Utils/TableFieldsGenerator.php#L265-L273
|
220,964
|
InfyOmLabs/laravel-generator
|
src/Utils/TableFieldsGenerator.php
|
TableFieldsGenerator.prepareForeignKeys
|
public function prepareForeignKeys()
{
$tables = $this->schemaManager->listTables();
$fields = [];
foreach ($tables as $table) {
$primaryKey = $table->getPrimaryKey();
if ($primaryKey) {
$primaryKey = $primaryKey->getColumns()[0];
}
$formattedForeignKeys = [];
$tableForeignKeys = $table->getForeignKeys();
foreach ($tableForeignKeys as $tableForeignKey) {
$generatorForeignKey = new GeneratorForeignKey();
$generatorForeignKey->name = $tableForeignKey->getName();
$generatorForeignKey->localField = $tableForeignKey->getLocalColumns()[0];
$generatorForeignKey->foreignField = $tableForeignKey->getForeignColumns()[0];
$generatorForeignKey->foreignTable = $tableForeignKey->getForeignTableName();
$generatorForeignKey->onUpdate = $tableForeignKey->onUpdate();
$generatorForeignKey->onDelete = $tableForeignKey->onDelete();
$formattedForeignKeys[] = $generatorForeignKey;
}
$generatorTable = new GeneratorTable();
$generatorTable->primaryKey = $primaryKey;
$generatorTable->foreignKeys = $formattedForeignKeys;
$fields[$table->getName()] = $generatorTable;
}
return $fields;
}
|
php
|
public function prepareForeignKeys()
{
$tables = $this->schemaManager->listTables();
$fields = [];
foreach ($tables as $table) {
$primaryKey = $table->getPrimaryKey();
if ($primaryKey) {
$primaryKey = $primaryKey->getColumns()[0];
}
$formattedForeignKeys = [];
$tableForeignKeys = $table->getForeignKeys();
foreach ($tableForeignKeys as $tableForeignKey) {
$generatorForeignKey = new GeneratorForeignKey();
$generatorForeignKey->name = $tableForeignKey->getName();
$generatorForeignKey->localField = $tableForeignKey->getLocalColumns()[0];
$generatorForeignKey->foreignField = $tableForeignKey->getForeignColumns()[0];
$generatorForeignKey->foreignTable = $tableForeignKey->getForeignTableName();
$generatorForeignKey->onUpdate = $tableForeignKey->onUpdate();
$generatorForeignKey->onDelete = $tableForeignKey->onDelete();
$formattedForeignKeys[] = $generatorForeignKey;
}
$generatorTable = new GeneratorTable();
$generatorTable->primaryKey = $primaryKey;
$generatorTable->foreignKeys = $formattedForeignKeys;
$fields[$table->getName()] = $generatorTable;
}
return $fields;
}
|
[
"public",
"function",
"prepareForeignKeys",
"(",
")",
"{",
"$",
"tables",
"=",
"$",
"this",
"->",
"schemaManager",
"->",
"listTables",
"(",
")",
";",
"$",
"fields",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"tables",
"as",
"$",
"table",
")",
"{",
"$",
"primaryKey",
"=",
"$",
"table",
"->",
"getPrimaryKey",
"(",
")",
";",
"if",
"(",
"$",
"primaryKey",
")",
"{",
"$",
"primaryKey",
"=",
"$",
"primaryKey",
"->",
"getColumns",
"(",
")",
"[",
"0",
"]",
";",
"}",
"$",
"formattedForeignKeys",
"=",
"[",
"]",
";",
"$",
"tableForeignKeys",
"=",
"$",
"table",
"->",
"getForeignKeys",
"(",
")",
";",
"foreach",
"(",
"$",
"tableForeignKeys",
"as",
"$",
"tableForeignKey",
")",
"{",
"$",
"generatorForeignKey",
"=",
"new",
"GeneratorForeignKey",
"(",
")",
";",
"$",
"generatorForeignKey",
"->",
"name",
"=",
"$",
"tableForeignKey",
"->",
"getName",
"(",
")",
";",
"$",
"generatorForeignKey",
"->",
"localField",
"=",
"$",
"tableForeignKey",
"->",
"getLocalColumns",
"(",
")",
"[",
"0",
"]",
";",
"$",
"generatorForeignKey",
"->",
"foreignField",
"=",
"$",
"tableForeignKey",
"->",
"getForeignColumns",
"(",
")",
"[",
"0",
"]",
";",
"$",
"generatorForeignKey",
"->",
"foreignTable",
"=",
"$",
"tableForeignKey",
"->",
"getForeignTableName",
"(",
")",
";",
"$",
"generatorForeignKey",
"->",
"onUpdate",
"=",
"$",
"tableForeignKey",
"->",
"onUpdate",
"(",
")",
";",
"$",
"generatorForeignKey",
"->",
"onDelete",
"=",
"$",
"tableForeignKey",
"->",
"onDelete",
"(",
")",
";",
"$",
"formattedForeignKeys",
"[",
"]",
"=",
"$",
"generatorForeignKey",
";",
"}",
"$",
"generatorTable",
"=",
"new",
"GeneratorTable",
"(",
")",
";",
"$",
"generatorTable",
"->",
"primaryKey",
"=",
"$",
"primaryKey",
";",
"$",
"generatorTable",
"->",
"foreignKeys",
"=",
"$",
"formattedForeignKeys",
";",
"$",
"fields",
"[",
"$",
"table",
"->",
"getName",
"(",
")",
"]",
"=",
"$",
"generatorTable",
";",
"}",
"return",
"$",
"fields",
";",
"}"
] |
Prepares foreign keys from table with required details.
@return GeneratorTable[]
|
[
"Prepares",
"foreign",
"keys",
"from",
"table",
"with",
"required",
"details",
"."
] |
2dc3d4d62f735e3216fcda242f70c9e073154312
|
https://github.com/InfyOmLabs/laravel-generator/blob/2dc3d4d62f735e3216fcda242f70c9e073154312/src/Utils/TableFieldsGenerator.php#L289-L322
|
220,965
|
InfyOmLabs/laravel-generator
|
src/Utils/TableFieldsGenerator.php
|
TableFieldsGenerator.checkForRelations
|
private function checkForRelations($tables)
{
// get Model table name and table details from tables list
$modelTableName = $this->tableName;
$modelTable = $tables[$modelTableName];
unset($tables[$modelTableName]);
$this->relations = [];
// detects many to one rules for model table
$manyToOneRelations = $this->detectManyToOne($tables, $modelTable);
if (count($manyToOneRelations) > 0) {
$this->relations = array_merge($this->relations, $manyToOneRelations);
}
foreach ($tables as $tableName => $table) {
$foreignKeys = $table->foreignKeys;
$primary = $table->primaryKey;
// if foreign key count is 2 then check if many to many relationship is there
if (count($foreignKeys) == 2) {
$manyToManyRelation = $this->isManyToMany($tables, $tableName, $modelTable, $modelTableName);
if ($manyToManyRelation) {
$this->relations[] = $manyToManyRelation;
continue;
}
}
// iterate each foreign key and check for relationship
foreach ($foreignKeys as $foreignKey) {
// check if foreign key is on the model table for which we are using generator command
if ($foreignKey->foreignTable == $modelTableName) {
// detect if one to one relationship is there
$isOneToOne = $this->isOneToOne($primary, $foreignKey, $modelTable->primaryKey);
if ($isOneToOne) {
$modelName = model_name_from_table_name($tableName);
$this->relations[] = GeneratorFieldRelation::parseRelation('1t1,'.$modelName);
continue;
}
// detect if one to many relationship is there
$isOneToMany = $this->isOneToMany($primary, $foreignKey, $modelTable->primaryKey);
if ($isOneToMany) {
$modelName = model_name_from_table_name($tableName);
$this->relations[] = GeneratorFieldRelation::parseRelation('1tm,'.$modelName);
continue;
}
}
}
}
}
|
php
|
private function checkForRelations($tables)
{
// get Model table name and table details from tables list
$modelTableName = $this->tableName;
$modelTable = $tables[$modelTableName];
unset($tables[$modelTableName]);
$this->relations = [];
// detects many to one rules for model table
$manyToOneRelations = $this->detectManyToOne($tables, $modelTable);
if (count($manyToOneRelations) > 0) {
$this->relations = array_merge($this->relations, $manyToOneRelations);
}
foreach ($tables as $tableName => $table) {
$foreignKeys = $table->foreignKeys;
$primary = $table->primaryKey;
// if foreign key count is 2 then check if many to many relationship is there
if (count($foreignKeys) == 2) {
$manyToManyRelation = $this->isManyToMany($tables, $tableName, $modelTable, $modelTableName);
if ($manyToManyRelation) {
$this->relations[] = $manyToManyRelation;
continue;
}
}
// iterate each foreign key and check for relationship
foreach ($foreignKeys as $foreignKey) {
// check if foreign key is on the model table for which we are using generator command
if ($foreignKey->foreignTable == $modelTableName) {
// detect if one to one relationship is there
$isOneToOne = $this->isOneToOne($primary, $foreignKey, $modelTable->primaryKey);
if ($isOneToOne) {
$modelName = model_name_from_table_name($tableName);
$this->relations[] = GeneratorFieldRelation::parseRelation('1t1,'.$modelName);
continue;
}
// detect if one to many relationship is there
$isOneToMany = $this->isOneToMany($primary, $foreignKey, $modelTable->primaryKey);
if ($isOneToMany) {
$modelName = model_name_from_table_name($tableName);
$this->relations[] = GeneratorFieldRelation::parseRelation('1tm,'.$modelName);
continue;
}
}
}
}
}
|
[
"private",
"function",
"checkForRelations",
"(",
"$",
"tables",
")",
"{",
"// get Model table name and table details from tables list",
"$",
"modelTableName",
"=",
"$",
"this",
"->",
"tableName",
";",
"$",
"modelTable",
"=",
"$",
"tables",
"[",
"$",
"modelTableName",
"]",
";",
"unset",
"(",
"$",
"tables",
"[",
"$",
"modelTableName",
"]",
")",
";",
"$",
"this",
"->",
"relations",
"=",
"[",
"]",
";",
"// detects many to one rules for model table",
"$",
"manyToOneRelations",
"=",
"$",
"this",
"->",
"detectManyToOne",
"(",
"$",
"tables",
",",
"$",
"modelTable",
")",
";",
"if",
"(",
"count",
"(",
"$",
"manyToOneRelations",
")",
">",
"0",
")",
"{",
"$",
"this",
"->",
"relations",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"relations",
",",
"$",
"manyToOneRelations",
")",
";",
"}",
"foreach",
"(",
"$",
"tables",
"as",
"$",
"tableName",
"=>",
"$",
"table",
")",
"{",
"$",
"foreignKeys",
"=",
"$",
"table",
"->",
"foreignKeys",
";",
"$",
"primary",
"=",
"$",
"table",
"->",
"primaryKey",
";",
"// if foreign key count is 2 then check if many to many relationship is there",
"if",
"(",
"count",
"(",
"$",
"foreignKeys",
")",
"==",
"2",
")",
"{",
"$",
"manyToManyRelation",
"=",
"$",
"this",
"->",
"isManyToMany",
"(",
"$",
"tables",
",",
"$",
"tableName",
",",
"$",
"modelTable",
",",
"$",
"modelTableName",
")",
";",
"if",
"(",
"$",
"manyToManyRelation",
")",
"{",
"$",
"this",
"->",
"relations",
"[",
"]",
"=",
"$",
"manyToManyRelation",
";",
"continue",
";",
"}",
"}",
"// iterate each foreign key and check for relationship",
"foreach",
"(",
"$",
"foreignKeys",
"as",
"$",
"foreignKey",
")",
"{",
"// check if foreign key is on the model table for which we are using generator command",
"if",
"(",
"$",
"foreignKey",
"->",
"foreignTable",
"==",
"$",
"modelTableName",
")",
"{",
"// detect if one to one relationship is there",
"$",
"isOneToOne",
"=",
"$",
"this",
"->",
"isOneToOne",
"(",
"$",
"primary",
",",
"$",
"foreignKey",
",",
"$",
"modelTable",
"->",
"primaryKey",
")",
";",
"if",
"(",
"$",
"isOneToOne",
")",
"{",
"$",
"modelName",
"=",
"model_name_from_table_name",
"(",
"$",
"tableName",
")",
";",
"$",
"this",
"->",
"relations",
"[",
"]",
"=",
"GeneratorFieldRelation",
"::",
"parseRelation",
"(",
"'1t1,'",
".",
"$",
"modelName",
")",
";",
"continue",
";",
"}",
"// detect if one to many relationship is there",
"$",
"isOneToMany",
"=",
"$",
"this",
"->",
"isOneToMany",
"(",
"$",
"primary",
",",
"$",
"foreignKey",
",",
"$",
"modelTable",
"->",
"primaryKey",
")",
";",
"if",
"(",
"$",
"isOneToMany",
")",
"{",
"$",
"modelName",
"=",
"model_name_from_table_name",
"(",
"$",
"tableName",
")",
";",
"$",
"this",
"->",
"relations",
"[",
"]",
"=",
"GeneratorFieldRelation",
"::",
"parseRelation",
"(",
"'1tm,'",
".",
"$",
"modelName",
")",
";",
"continue",
";",
"}",
"}",
"}",
"}",
"}"
] |
Prepares relations array from table foreign keys.
@param GeneratorTable[] $tables
|
[
"Prepares",
"relations",
"array",
"from",
"table",
"foreign",
"keys",
"."
] |
2dc3d4d62f735e3216fcda242f70c9e073154312
|
https://github.com/InfyOmLabs/laravel-generator/blob/2dc3d4d62f735e3216fcda242f70c9e073154312/src/Utils/TableFieldsGenerator.php#L329-L381
|
220,966
|
InfyOmLabs/laravel-generator
|
src/Utils/TableFieldsGenerator.php
|
TableFieldsGenerator.isManyToMany
|
private function isManyToMany($tables, $tableName, $modelTable, $modelTableName)
{
// get table details
$table = $tables[$tableName];
$isAnyKeyOnModelTable = false;
// many to many model table name
$manyToManyTable = '';
$foreignKeys = $table->foreignKeys;
$primary = $table->primaryKey;
// check if any foreign key is there from model table
foreach ($foreignKeys as $foreignKey) {
if ($foreignKey->foreignTable == $modelTableName) {
$isAnyKeyOnModelTable = true;
}
}
// if foreign key is there
if ($isAnyKeyOnModelTable) {
foreach ($foreignKeys as $foreignKey) {
$foreignField = $foreignKey->foreignField;
$foreignTableName = $foreignKey->foreignTable;
// if foreign table is model table
if ($foreignTableName == $modelTableName) {
$foreignTable = $modelTable;
} else {
$foreignTable = $tables[$foreignTableName];
// get the many to many model table name
$manyToManyTable = $foreignTableName;
}
// if foreign field is not primary key of foreign table
// then it can not be many to many
if ($foreignField != $foreignTable->primaryKey) {
return false;
break;
}
// if foreign field is primary key of this table
// then it can not be many to many
if ($foreignField == $primary) {
return false;
}
}
}
$modelName = model_name_from_table_name($manyToManyTable);
return GeneratorFieldRelation::parseRelation('mtm,'.$modelName.','.$tableName);
}
|
php
|
private function isManyToMany($tables, $tableName, $modelTable, $modelTableName)
{
// get table details
$table = $tables[$tableName];
$isAnyKeyOnModelTable = false;
// many to many model table name
$manyToManyTable = '';
$foreignKeys = $table->foreignKeys;
$primary = $table->primaryKey;
// check if any foreign key is there from model table
foreach ($foreignKeys as $foreignKey) {
if ($foreignKey->foreignTable == $modelTableName) {
$isAnyKeyOnModelTable = true;
}
}
// if foreign key is there
if ($isAnyKeyOnModelTable) {
foreach ($foreignKeys as $foreignKey) {
$foreignField = $foreignKey->foreignField;
$foreignTableName = $foreignKey->foreignTable;
// if foreign table is model table
if ($foreignTableName == $modelTableName) {
$foreignTable = $modelTable;
} else {
$foreignTable = $tables[$foreignTableName];
// get the many to many model table name
$manyToManyTable = $foreignTableName;
}
// if foreign field is not primary key of foreign table
// then it can not be many to many
if ($foreignField != $foreignTable->primaryKey) {
return false;
break;
}
// if foreign field is primary key of this table
// then it can not be many to many
if ($foreignField == $primary) {
return false;
}
}
}
$modelName = model_name_from_table_name($manyToManyTable);
return GeneratorFieldRelation::parseRelation('mtm,'.$modelName.','.$tableName);
}
|
[
"private",
"function",
"isManyToMany",
"(",
"$",
"tables",
",",
"$",
"tableName",
",",
"$",
"modelTable",
",",
"$",
"modelTableName",
")",
"{",
"// get table details",
"$",
"table",
"=",
"$",
"tables",
"[",
"$",
"tableName",
"]",
";",
"$",
"isAnyKeyOnModelTable",
"=",
"false",
";",
"// many to many model table name",
"$",
"manyToManyTable",
"=",
"''",
";",
"$",
"foreignKeys",
"=",
"$",
"table",
"->",
"foreignKeys",
";",
"$",
"primary",
"=",
"$",
"table",
"->",
"primaryKey",
";",
"// check if any foreign key is there from model table",
"foreach",
"(",
"$",
"foreignKeys",
"as",
"$",
"foreignKey",
")",
"{",
"if",
"(",
"$",
"foreignKey",
"->",
"foreignTable",
"==",
"$",
"modelTableName",
")",
"{",
"$",
"isAnyKeyOnModelTable",
"=",
"true",
";",
"}",
"}",
"// if foreign key is there",
"if",
"(",
"$",
"isAnyKeyOnModelTable",
")",
"{",
"foreach",
"(",
"$",
"foreignKeys",
"as",
"$",
"foreignKey",
")",
"{",
"$",
"foreignField",
"=",
"$",
"foreignKey",
"->",
"foreignField",
";",
"$",
"foreignTableName",
"=",
"$",
"foreignKey",
"->",
"foreignTable",
";",
"// if foreign table is model table",
"if",
"(",
"$",
"foreignTableName",
"==",
"$",
"modelTableName",
")",
"{",
"$",
"foreignTable",
"=",
"$",
"modelTable",
";",
"}",
"else",
"{",
"$",
"foreignTable",
"=",
"$",
"tables",
"[",
"$",
"foreignTableName",
"]",
";",
"// get the many to many model table name",
"$",
"manyToManyTable",
"=",
"$",
"foreignTableName",
";",
"}",
"// if foreign field is not primary key of foreign table",
"// then it can not be many to many",
"if",
"(",
"$",
"foreignField",
"!=",
"$",
"foreignTable",
"->",
"primaryKey",
")",
"{",
"return",
"false",
";",
"break",
";",
"}",
"// if foreign field is primary key of this table",
"// then it can not be many to many",
"if",
"(",
"$",
"foreignField",
"==",
"$",
"primary",
")",
"{",
"return",
"false",
";",
"}",
"}",
"}",
"$",
"modelName",
"=",
"model_name_from_table_name",
"(",
"$",
"manyToManyTable",
")",
";",
"return",
"GeneratorFieldRelation",
"::",
"parseRelation",
"(",
"'mtm,'",
".",
"$",
"modelName",
".",
"','",
".",
"$",
"tableName",
")",
";",
"}"
] |
Detects many to many relationship
If table has only two foreign keys
Both foreign keys are primary key in foreign table
Also one is from model table and one is from diff table.
@param GeneratorTable[] $tables
@param string $tableName
@param GeneratorTable $modelTable
@param string $modelTableName
@return bool|GeneratorFieldRelation
|
[
"Detects",
"many",
"to",
"many",
"relationship",
"If",
"table",
"has",
"only",
"two",
"foreign",
"keys",
"Both",
"foreign",
"keys",
"are",
"primary",
"key",
"in",
"foreign",
"table",
"Also",
"one",
"is",
"from",
"model",
"table",
"and",
"one",
"is",
"from",
"diff",
"table",
"."
] |
2dc3d4d62f735e3216fcda242f70c9e073154312
|
https://github.com/InfyOmLabs/laravel-generator/blob/2dc3d4d62f735e3216fcda242f70c9e073154312/src/Utils/TableFieldsGenerator.php#L396-L449
|
220,967
|
InfyOmLabs/laravel-generator
|
src/Utils/TableFieldsGenerator.php
|
TableFieldsGenerator.isOneToOne
|
private function isOneToOne($primaryKey, $foreignKey, $modelTablePrimary)
{
if ($foreignKey->foreignField == $modelTablePrimary) {
if ($foreignKey->localField == $primaryKey) {
return true;
}
}
return false;
}
|
php
|
private function isOneToOne($primaryKey, $foreignKey, $modelTablePrimary)
{
if ($foreignKey->foreignField == $modelTablePrimary) {
if ($foreignKey->localField == $primaryKey) {
return true;
}
}
return false;
}
|
[
"private",
"function",
"isOneToOne",
"(",
"$",
"primaryKey",
",",
"$",
"foreignKey",
",",
"$",
"modelTablePrimary",
")",
"{",
"if",
"(",
"$",
"foreignKey",
"->",
"foreignField",
"==",
"$",
"modelTablePrimary",
")",
"{",
"if",
"(",
"$",
"foreignKey",
"->",
"localField",
"==",
"$",
"primaryKey",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
Detects if one to one relationship is there
If foreign key of table is primary key of foreign table
Also foreign key field is primary key of this table.
@param string $primaryKey
@param GeneratorForeignKey $foreignKey
@param string $modelTablePrimary
@return bool
|
[
"Detects",
"if",
"one",
"to",
"one",
"relationship",
"is",
"there",
"If",
"foreign",
"key",
"of",
"table",
"is",
"primary",
"key",
"of",
"foreign",
"table",
"Also",
"foreign",
"key",
"field",
"is",
"primary",
"key",
"of",
"this",
"table",
"."
] |
2dc3d4d62f735e3216fcda242f70c9e073154312
|
https://github.com/InfyOmLabs/laravel-generator/blob/2dc3d4d62f735e3216fcda242f70c9e073154312/src/Utils/TableFieldsGenerator.php#L462-L471
|
220,968
|
InfyOmLabs/laravel-generator
|
src/Utils/TableFieldsGenerator.php
|
TableFieldsGenerator.isOneToMany
|
private function isOneToMany($primaryKey, $foreignKey, $modelTablePrimary)
{
if ($foreignKey->foreignField == $modelTablePrimary) {
if ($foreignKey->localField != $primaryKey) {
return true;
}
}
return false;
}
|
php
|
private function isOneToMany($primaryKey, $foreignKey, $modelTablePrimary)
{
if ($foreignKey->foreignField == $modelTablePrimary) {
if ($foreignKey->localField != $primaryKey) {
return true;
}
}
return false;
}
|
[
"private",
"function",
"isOneToMany",
"(",
"$",
"primaryKey",
",",
"$",
"foreignKey",
",",
"$",
"modelTablePrimary",
")",
"{",
"if",
"(",
"$",
"foreignKey",
"->",
"foreignField",
"==",
"$",
"modelTablePrimary",
")",
"{",
"if",
"(",
"$",
"foreignKey",
"->",
"localField",
"!=",
"$",
"primaryKey",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
Detects if one to many relationship is there
If foreign key of table is primary key of foreign table
Also foreign key field is not primary key of this table.
@param string $primaryKey
@param GeneratorForeignKey $foreignKey
@param string $modelTablePrimary
@return bool
|
[
"Detects",
"if",
"one",
"to",
"many",
"relationship",
"is",
"there",
"If",
"foreign",
"key",
"of",
"table",
"is",
"primary",
"key",
"of",
"foreign",
"table",
"Also",
"foreign",
"key",
"field",
"is",
"not",
"primary",
"key",
"of",
"this",
"table",
"."
] |
2dc3d4d62f735e3216fcda242f70c9e073154312
|
https://github.com/InfyOmLabs/laravel-generator/blob/2dc3d4d62f735e3216fcda242f70c9e073154312/src/Utils/TableFieldsGenerator.php#L484-L493
|
220,969
|
InfyOmLabs/laravel-generator
|
src/Criteria/LimitOffsetCriteria.php
|
LimitOffsetCriteria.apply
|
public function apply($model, \Prettus\Repository\Contracts\RepositoryInterface $repository)
{
$limit = $this->request->get('limit', null);
$offset = $this->request->get('offset', null);
if ($limit) {
$model = $model->limit($limit);
}
if ($offset && $limit) {
$model = $model->skip($offset);
}
return $model;
}
|
php
|
public function apply($model, \Prettus\Repository\Contracts\RepositoryInterface $repository)
{
$limit = $this->request->get('limit', null);
$offset = $this->request->get('offset', null);
if ($limit) {
$model = $model->limit($limit);
}
if ($offset && $limit) {
$model = $model->skip($offset);
}
return $model;
}
|
[
"public",
"function",
"apply",
"(",
"$",
"model",
",",
"\\",
"Prettus",
"\\",
"Repository",
"\\",
"Contracts",
"\\",
"RepositoryInterface",
"$",
"repository",
")",
"{",
"$",
"limit",
"=",
"$",
"this",
"->",
"request",
"->",
"get",
"(",
"'limit'",
",",
"null",
")",
";",
"$",
"offset",
"=",
"$",
"this",
"->",
"request",
"->",
"get",
"(",
"'offset'",
",",
"null",
")",
";",
"if",
"(",
"$",
"limit",
")",
"{",
"$",
"model",
"=",
"$",
"model",
"->",
"limit",
"(",
"$",
"limit",
")",
";",
"}",
"if",
"(",
"$",
"offset",
"&&",
"$",
"limit",
")",
"{",
"$",
"model",
"=",
"$",
"model",
"->",
"skip",
"(",
"$",
"offset",
")",
";",
"}",
"return",
"$",
"model",
";",
"}"
] |
Apply criteria in query repository.
@param $model
@param \Prettus\Repository\Contracts\RepositoryInterface $repository
@return mixed
|
[
"Apply",
"criteria",
"in",
"query",
"repository",
"."
] |
2dc3d4d62f735e3216fcda242f70c9e073154312
|
https://github.com/InfyOmLabs/laravel-generator/blob/2dc3d4d62f735e3216fcda242f70c9e073154312/src/Criteria/LimitOffsetCriteria.php#L28-L42
|
220,970
|
barryvdh/laravel-ide-helper
|
src/Generator.php
|
Generator.generate
|
public function generate($format = 'php')
{
// Check if the generator for this format exists
$method = 'generate'.ucfirst($format).'Helper';
if (method_exists($this, $method)) {
return $this->$method();
}
return $this->generatePhpHelper();
}
|
php
|
public function generate($format = 'php')
{
// Check if the generator for this format exists
$method = 'generate'.ucfirst($format).'Helper';
if (method_exists($this, $method)) {
return $this->$method();
}
return $this->generatePhpHelper();
}
|
[
"public",
"function",
"generate",
"(",
"$",
"format",
"=",
"'php'",
")",
"{",
"// Check if the generator for this format exists",
"$",
"method",
"=",
"'generate'",
".",
"ucfirst",
"(",
"$",
"format",
")",
".",
"'Helper'",
";",
"if",
"(",
"method_exists",
"(",
"$",
"this",
",",
"$",
"method",
")",
")",
"{",
"return",
"$",
"this",
"->",
"$",
"method",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"generatePhpHelper",
"(",
")",
";",
"}"
] |
Generate the helper file contents;
@param string $format The format to generate the helper in (php/json)
@return string;
|
[
"Generate",
"the",
"helper",
"file",
"contents",
";"
] |
87ebe458e9b5787e6b65b9c4b62df9c2b13be7fe
|
https://github.com/barryvdh/laravel-ide-helper/blob/87ebe458e9b5787e6b65b9c4b62df9c2b13be7fe/src/Generator.php#L69-L78
|
220,971
|
barryvdh/laravel-ide-helper
|
src/Generator.php
|
Generator.getValidAliases
|
protected function getValidAliases()
{
$aliases = new Collection();
// Get all aliases
foreach ($this->getAliases() as $name => $facade) {
// Skip the Redis facade, if not available (otherwise Fatal PHP Error)
if ($facade == 'Illuminate\Support\Facades\Redis' && $name == 'Redis' && !class_exists('Predis\Client')) {
continue;
}
$magicMethods = array_key_exists($name, $this->magic) ? $this->magic[$name] : array();
$alias = new Alias($this->config, $name, $facade, $magicMethods, $this->interfaces);
if ($alias->isValid()) {
//Add extra methods, from other classes (magic static calls)
if (array_key_exists($name, $this->extra)) {
$alias->addClass($this->extra[$name]);
}
$aliases[] = $alias;
}
}
return $aliases;
}
|
php
|
protected function getValidAliases()
{
$aliases = new Collection();
// Get all aliases
foreach ($this->getAliases() as $name => $facade) {
// Skip the Redis facade, if not available (otherwise Fatal PHP Error)
if ($facade == 'Illuminate\Support\Facades\Redis' && $name == 'Redis' && !class_exists('Predis\Client')) {
continue;
}
$magicMethods = array_key_exists($name, $this->magic) ? $this->magic[$name] : array();
$alias = new Alias($this->config, $name, $facade, $magicMethods, $this->interfaces);
if ($alias->isValid()) {
//Add extra methods, from other classes (magic static calls)
if (array_key_exists($name, $this->extra)) {
$alias->addClass($this->extra[$name]);
}
$aliases[] = $alias;
}
}
return $aliases;
}
|
[
"protected",
"function",
"getValidAliases",
"(",
")",
"{",
"$",
"aliases",
"=",
"new",
"Collection",
"(",
")",
";",
"// Get all aliases",
"foreach",
"(",
"$",
"this",
"->",
"getAliases",
"(",
")",
"as",
"$",
"name",
"=>",
"$",
"facade",
")",
"{",
"// Skip the Redis facade, if not available (otherwise Fatal PHP Error)",
"if",
"(",
"$",
"facade",
"==",
"'Illuminate\\Support\\Facades\\Redis'",
"&&",
"$",
"name",
"==",
"'Redis'",
"&&",
"!",
"class_exists",
"(",
"'Predis\\Client'",
")",
")",
"{",
"continue",
";",
"}",
"$",
"magicMethods",
"=",
"array_key_exists",
"(",
"$",
"name",
",",
"$",
"this",
"->",
"magic",
")",
"?",
"$",
"this",
"->",
"magic",
"[",
"$",
"name",
"]",
":",
"array",
"(",
")",
";",
"$",
"alias",
"=",
"new",
"Alias",
"(",
"$",
"this",
"->",
"config",
",",
"$",
"name",
",",
"$",
"facade",
",",
"$",
"magicMethods",
",",
"$",
"this",
"->",
"interfaces",
")",
";",
"if",
"(",
"$",
"alias",
"->",
"isValid",
"(",
")",
")",
"{",
"//Add extra methods, from other classes (magic static calls)",
"if",
"(",
"array_key_exists",
"(",
"$",
"name",
",",
"$",
"this",
"->",
"extra",
")",
")",
"{",
"$",
"alias",
"->",
"addClass",
"(",
"$",
"this",
"->",
"extra",
"[",
"$",
"name",
"]",
")",
";",
"}",
"$",
"aliases",
"[",
"]",
"=",
"$",
"alias",
";",
"}",
"}",
"return",
"$",
"aliases",
";",
"}"
] |
Find all aliases that are valid for us to render
@return Collection
|
[
"Find",
"all",
"aliases",
"that",
"are",
"valid",
"for",
"us",
"to",
"render"
] |
87ebe458e9b5787e6b65b9c4b62df9c2b13be7fe
|
https://github.com/barryvdh/laravel-ide-helper/blob/87ebe458e9b5787e6b65b9c4b62df9c2b13be7fe/src/Generator.php#L194-L218
|
220,972
|
barryvdh/laravel-ide-helper
|
src/Alias.php
|
Alias.addClass
|
public function addClass($classes)
{
$classes = (array)$classes;
foreach ($classes as $class) {
if (class_exists($class) || interface_exists($class)) {
$this->classes[] = $class;
} else {
echo "Class not exists: $class\r\n";
}
}
}
|
php
|
public function addClass($classes)
{
$classes = (array)$classes;
foreach ($classes as $class) {
if (class_exists($class) || interface_exists($class)) {
$this->classes[] = $class;
} else {
echo "Class not exists: $class\r\n";
}
}
}
|
[
"public",
"function",
"addClass",
"(",
"$",
"classes",
")",
"{",
"$",
"classes",
"=",
"(",
"array",
")",
"$",
"classes",
";",
"foreach",
"(",
"$",
"classes",
"as",
"$",
"class",
")",
"{",
"if",
"(",
"class_exists",
"(",
"$",
"class",
")",
"||",
"interface_exists",
"(",
"$",
"class",
")",
")",
"{",
"$",
"this",
"->",
"classes",
"[",
"]",
"=",
"$",
"class",
";",
"}",
"else",
"{",
"echo",
"\"Class not exists: $class\\r\\n\"",
";",
"}",
"}",
"}"
] |
Add one or more classes to analyze
@param array|string $classes
|
[
"Add",
"one",
"or",
"more",
"classes",
"to",
"analyze"
] |
87ebe458e9b5787e6b65b9c4b62df9c2b13be7fe
|
https://github.com/barryvdh/laravel-ide-helper/blob/87ebe458e9b5787e6b65b9c4b62df9c2b13be7fe/src/Alias.php#L91-L101
|
220,973
|
barryvdh/laravel-ide-helper
|
src/Alias.php
|
Alias.getMethods
|
public function getMethods()
{
if (count($this->methods) > 0) {
return $this->methods;
}
$this->addMagicMethods();
$this->detectMethods();
return $this->methods;
}
|
php
|
public function getMethods()
{
if (count($this->methods) > 0) {
return $this->methods;
}
$this->addMagicMethods();
$this->detectMethods();
return $this->methods;
}
|
[
"public",
"function",
"getMethods",
"(",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"methods",
")",
">",
"0",
")",
"{",
"return",
"$",
"this",
"->",
"methods",
";",
"}",
"$",
"this",
"->",
"addMagicMethods",
"(",
")",
";",
"$",
"this",
"->",
"detectMethods",
"(",
")",
";",
"return",
"$",
"this",
"->",
"methods",
";",
"}"
] |
Get the methods found by this Alias
@return array|Method[]
|
[
"Get",
"the",
"methods",
"found",
"by",
"this",
"Alias"
] |
87ebe458e9b5787e6b65b9c4b62df9c2b13be7fe
|
https://github.com/barryvdh/laravel-ide-helper/blob/87ebe458e9b5787e6b65b9c4b62df9c2b13be7fe/src/Alias.php#L184-L193
|
220,974
|
barryvdh/laravel-ide-helper
|
src/Alias.php
|
Alias.detectNamespace
|
protected function detectNamespace()
{
if (strpos($this->alias, '\\')) {
$nsParts = explode('\\', $this->alias);
$this->short = array_pop($nsParts);
$this->namespace = implode('\\', $nsParts);
} else {
$this->short = $this->alias;
}
}
|
php
|
protected function detectNamespace()
{
if (strpos($this->alias, '\\')) {
$nsParts = explode('\\', $this->alias);
$this->short = array_pop($nsParts);
$this->namespace = implode('\\', $nsParts);
} else {
$this->short = $this->alias;
}
}
|
[
"protected",
"function",
"detectNamespace",
"(",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"this",
"->",
"alias",
",",
"'\\\\'",
")",
")",
"{",
"$",
"nsParts",
"=",
"explode",
"(",
"'\\\\'",
",",
"$",
"this",
"->",
"alias",
")",
";",
"$",
"this",
"->",
"short",
"=",
"array_pop",
"(",
"$",
"nsParts",
")",
";",
"$",
"this",
"->",
"namespace",
"=",
"implode",
"(",
"'\\\\'",
",",
"$",
"nsParts",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"short",
"=",
"$",
"this",
"->",
"alias",
";",
"}",
"}"
] |
Detect the namespace
|
[
"Detect",
"the",
"namespace"
] |
87ebe458e9b5787e6b65b9c4b62df9c2b13be7fe
|
https://github.com/barryvdh/laravel-ide-helper/blob/87ebe458e9b5787e6b65b9c4b62df9c2b13be7fe/src/Alias.php#L222-L231
|
220,975
|
barryvdh/laravel-ide-helper
|
src/Alias.php
|
Alias.detectExtendsNamespace
|
protected function detectExtendsNamespace()
{
if (strpos($this->extends, '\\') !== false) {
$nsParts = explode('\\', $this->extends);
$this->extendsClass = array_pop($nsParts);
$this->extendsNamespace = implode('\\', $nsParts);
}
}
|
php
|
protected function detectExtendsNamespace()
{
if (strpos($this->extends, '\\') !== false) {
$nsParts = explode('\\', $this->extends);
$this->extendsClass = array_pop($nsParts);
$this->extendsNamespace = implode('\\', $nsParts);
}
}
|
[
"protected",
"function",
"detectExtendsNamespace",
"(",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"this",
"->",
"extends",
",",
"'\\\\'",
")",
"!==",
"false",
")",
"{",
"$",
"nsParts",
"=",
"explode",
"(",
"'\\\\'",
",",
"$",
"this",
"->",
"extends",
")",
";",
"$",
"this",
"->",
"extendsClass",
"=",
"array_pop",
"(",
"$",
"nsParts",
")",
";",
"$",
"this",
"->",
"extendsNamespace",
"=",
"implode",
"(",
"'\\\\'",
",",
"$",
"nsParts",
")",
";",
"}",
"}"
] |
Detect the extends namespace
|
[
"Detect",
"the",
"extends",
"namespace"
] |
87ebe458e9b5787e6b65b9c4b62df9c2b13be7fe
|
https://github.com/barryvdh/laravel-ide-helper/blob/87ebe458e9b5787e6b65b9c4b62df9c2b13be7fe/src/Alias.php#L236-L243
|
220,976
|
barryvdh/laravel-ide-helper
|
src/Alias.php
|
Alias.detectClassType
|
protected function detectClassType()
{
//Some classes extend the facade
if (interface_exists($this->facade)) {
$this->classType = 'interface';
$this->extends = $this->facade;
} else {
$this->classType = 'class';
if (class_exists($this->facade)) {
$this->extends = $this->facade;
}
}
}
|
php
|
protected function detectClassType()
{
//Some classes extend the facade
if (interface_exists($this->facade)) {
$this->classType = 'interface';
$this->extends = $this->facade;
} else {
$this->classType = 'class';
if (class_exists($this->facade)) {
$this->extends = $this->facade;
}
}
}
|
[
"protected",
"function",
"detectClassType",
"(",
")",
"{",
"//Some classes extend the facade",
"if",
"(",
"interface_exists",
"(",
"$",
"this",
"->",
"facade",
")",
")",
"{",
"$",
"this",
"->",
"classType",
"=",
"'interface'",
";",
"$",
"this",
"->",
"extends",
"=",
"$",
"this",
"->",
"facade",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"classType",
"=",
"'class'",
";",
"if",
"(",
"class_exists",
"(",
"$",
"this",
"->",
"facade",
")",
")",
"{",
"$",
"this",
"->",
"extends",
"=",
"$",
"this",
"->",
"facade",
";",
"}",
"}",
"}"
] |
Detect the class type
|
[
"Detect",
"the",
"class",
"type"
] |
87ebe458e9b5787e6b65b9c4b62df9c2b13be7fe
|
https://github.com/barryvdh/laravel-ide-helper/blob/87ebe458e9b5787e6b65b9c4b62df9c2b13be7fe/src/Alias.php#L248-L260
|
220,977
|
barryvdh/laravel-ide-helper
|
src/Alias.php
|
Alias.detectRoot
|
protected function detectRoot()
{
$facade = $this->facade;
try {
//If possible, get the facade root
if (method_exists($facade, 'getFacadeRoot')) {
$root = get_class($facade::getFacadeRoot());
} else {
$root = $facade;
}
//If it doesn't exist, skip it
if (!class_exists($root) && !interface_exists($root)) {
return;
}
$this->root = $root;
//When the database connection is not set, some classes will be skipped
} catch (\PDOException $e) {
$this->error(
"PDOException: " . $e->getMessage() .
"\nPlease configure your database connection correctly, or use the sqlite memory driver (-M)." .
" Skipping $facade."
);
} catch (\Exception $e) {
$this->error("Exception: " . $e->getMessage() . "\nSkipping $facade.");
}
}
|
php
|
protected function detectRoot()
{
$facade = $this->facade;
try {
//If possible, get the facade root
if (method_exists($facade, 'getFacadeRoot')) {
$root = get_class($facade::getFacadeRoot());
} else {
$root = $facade;
}
//If it doesn't exist, skip it
if (!class_exists($root) && !interface_exists($root)) {
return;
}
$this->root = $root;
//When the database connection is not set, some classes will be skipped
} catch (\PDOException $e) {
$this->error(
"PDOException: " . $e->getMessage() .
"\nPlease configure your database connection correctly, or use the sqlite memory driver (-M)." .
" Skipping $facade."
);
} catch (\Exception $e) {
$this->error("Exception: " . $e->getMessage() . "\nSkipping $facade.");
}
}
|
[
"protected",
"function",
"detectRoot",
"(",
")",
"{",
"$",
"facade",
"=",
"$",
"this",
"->",
"facade",
";",
"try",
"{",
"//If possible, get the facade root",
"if",
"(",
"method_exists",
"(",
"$",
"facade",
",",
"'getFacadeRoot'",
")",
")",
"{",
"$",
"root",
"=",
"get_class",
"(",
"$",
"facade",
"::",
"getFacadeRoot",
"(",
")",
")",
";",
"}",
"else",
"{",
"$",
"root",
"=",
"$",
"facade",
";",
"}",
"//If it doesn't exist, skip it",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"root",
")",
"&&",
"!",
"interface_exists",
"(",
"$",
"root",
")",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"root",
"=",
"$",
"root",
";",
"//When the database connection is not set, some classes will be skipped",
"}",
"catch",
"(",
"\\",
"PDOException",
"$",
"e",
")",
"{",
"$",
"this",
"->",
"error",
"(",
"\"PDOException: \"",
".",
"$",
"e",
"->",
"getMessage",
"(",
")",
".",
"\"\\nPlease configure your database connection correctly, or use the sqlite memory driver (-M).\"",
".",
"\" Skipping $facade.\"",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"$",
"this",
"->",
"error",
"(",
"\"Exception: \"",
".",
"$",
"e",
"->",
"getMessage",
"(",
")",
".",
"\"\\nSkipping $facade.\"",
")",
";",
"}",
"}"
] |
Get the real root of a facade
@return bool|string
|
[
"Get",
"the",
"real",
"root",
"of",
"a",
"facade"
] |
87ebe458e9b5787e6b65b9c4b62df9c2b13be7fe
|
https://github.com/barryvdh/laravel-ide-helper/blob/87ebe458e9b5787e6b65b9c4b62df9c2b13be7fe/src/Alias.php#L267-L296
|
220,978
|
barryvdh/laravel-ide-helper
|
src/Alias.php
|
Alias.addMagicMethods
|
protected function addMagicMethods()
{
foreach ($this->magicMethods as $magic => $real) {
list($className, $name) = explode('::', $real);
if (!class_exists($className) && !interface_exists($className)) {
continue;
}
$method = new \ReflectionMethod($className, $name);
$class = new \ReflectionClass($className);
if (!in_array($magic, $this->usedMethods)) {
if ($class !== $this->root) {
$this->methods[] = new Method($method, $this->alias, $class, $magic, $this->interfaces);
}
$this->usedMethods[] = $magic;
}
}
}
|
php
|
protected function addMagicMethods()
{
foreach ($this->magicMethods as $magic => $real) {
list($className, $name) = explode('::', $real);
if (!class_exists($className) && !interface_exists($className)) {
continue;
}
$method = new \ReflectionMethod($className, $name);
$class = new \ReflectionClass($className);
if (!in_array($magic, $this->usedMethods)) {
if ($class !== $this->root) {
$this->methods[] = new Method($method, $this->alias, $class, $magic, $this->interfaces);
}
$this->usedMethods[] = $magic;
}
}
}
|
[
"protected",
"function",
"addMagicMethods",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"magicMethods",
"as",
"$",
"magic",
"=>",
"$",
"real",
")",
"{",
"list",
"(",
"$",
"className",
",",
"$",
"name",
")",
"=",
"explode",
"(",
"'::'",
",",
"$",
"real",
")",
";",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"className",
")",
"&&",
"!",
"interface_exists",
"(",
"$",
"className",
")",
")",
"{",
"continue",
";",
"}",
"$",
"method",
"=",
"new",
"\\",
"ReflectionMethod",
"(",
"$",
"className",
",",
"$",
"name",
")",
";",
"$",
"class",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"className",
")",
";",
"if",
"(",
"!",
"in_array",
"(",
"$",
"magic",
",",
"$",
"this",
"->",
"usedMethods",
")",
")",
"{",
"if",
"(",
"$",
"class",
"!==",
"$",
"this",
"->",
"root",
")",
"{",
"$",
"this",
"->",
"methods",
"[",
"]",
"=",
"new",
"Method",
"(",
"$",
"method",
",",
"$",
"this",
"->",
"alias",
",",
"$",
"class",
",",
"$",
"magic",
",",
"$",
"this",
"->",
"interfaces",
")",
";",
"}",
"$",
"this",
"->",
"usedMethods",
"[",
"]",
"=",
"$",
"magic",
";",
"}",
"}",
"}"
] |
Add magic methods, as defined in the configuration files
|
[
"Add",
"magic",
"methods",
"as",
"defined",
"in",
"the",
"configuration",
"files"
] |
87ebe458e9b5787e6b65b9c4b62df9c2b13be7fe
|
https://github.com/barryvdh/laravel-ide-helper/blob/87ebe458e9b5787e6b65b9c4b62df9c2b13be7fe/src/Alias.php#L315-L332
|
220,979
|
barryvdh/laravel-ide-helper
|
src/Alias.php
|
Alias.detectMethods
|
protected function detectMethods()
{
foreach ($this->classes as $class) {
$reflection = new \ReflectionClass($class);
$methods = $reflection->getMethods(\ReflectionMethod::IS_PUBLIC);
if ($methods) {
foreach ($methods as $method) {
if (!in_array($method->name, $this->usedMethods)) {
// Only add the methods to the output when the root is not the same as the class.
// And don't add the __*() methods
if ($this->extends !== $class && substr($method->name, 0, 2) !== '__') {
$this->methods[] = new Method(
$method,
$this->alias,
$reflection,
$method->name,
$this->interfaces
);
}
$this->usedMethods[] = $method->name;
}
}
}
// Check if the class is macroable
$traits = collect($reflection->getTraitNames());
if ($traits->contains('Illuminate\Support\Traits\Macroable')) {
$properties = $reflection->getStaticProperties();
$macros = isset($properties['macros']) ? $properties['macros'] : [];
foreach ($macros as $macro_name => $macro_func) {
if (!in_array($macro_name, $this->usedMethods)) {
// Add macros
$this->methods[] = new Macro(
$this->getMacroFunction($macro_func),
$this->alias,
$reflection,
$macro_name,
$this->interfaces
);
$this->usedMethods[] = $macro_name;
}
}
}
}
}
|
php
|
protected function detectMethods()
{
foreach ($this->classes as $class) {
$reflection = new \ReflectionClass($class);
$methods = $reflection->getMethods(\ReflectionMethod::IS_PUBLIC);
if ($methods) {
foreach ($methods as $method) {
if (!in_array($method->name, $this->usedMethods)) {
// Only add the methods to the output when the root is not the same as the class.
// And don't add the __*() methods
if ($this->extends !== $class && substr($method->name, 0, 2) !== '__') {
$this->methods[] = new Method(
$method,
$this->alias,
$reflection,
$method->name,
$this->interfaces
);
}
$this->usedMethods[] = $method->name;
}
}
}
// Check if the class is macroable
$traits = collect($reflection->getTraitNames());
if ($traits->contains('Illuminate\Support\Traits\Macroable')) {
$properties = $reflection->getStaticProperties();
$macros = isset($properties['macros']) ? $properties['macros'] : [];
foreach ($macros as $macro_name => $macro_func) {
if (!in_array($macro_name, $this->usedMethods)) {
// Add macros
$this->methods[] = new Macro(
$this->getMacroFunction($macro_func),
$this->alias,
$reflection,
$macro_name,
$this->interfaces
);
$this->usedMethods[] = $macro_name;
}
}
}
}
}
|
[
"protected",
"function",
"detectMethods",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"classes",
"as",
"$",
"class",
")",
"{",
"$",
"reflection",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"class",
")",
";",
"$",
"methods",
"=",
"$",
"reflection",
"->",
"getMethods",
"(",
"\\",
"ReflectionMethod",
"::",
"IS_PUBLIC",
")",
";",
"if",
"(",
"$",
"methods",
")",
"{",
"foreach",
"(",
"$",
"methods",
"as",
"$",
"method",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"method",
"->",
"name",
",",
"$",
"this",
"->",
"usedMethods",
")",
")",
"{",
"// Only add the methods to the output when the root is not the same as the class.",
"// And don't add the __*() methods",
"if",
"(",
"$",
"this",
"->",
"extends",
"!==",
"$",
"class",
"&&",
"substr",
"(",
"$",
"method",
"->",
"name",
",",
"0",
",",
"2",
")",
"!==",
"'__'",
")",
"{",
"$",
"this",
"->",
"methods",
"[",
"]",
"=",
"new",
"Method",
"(",
"$",
"method",
",",
"$",
"this",
"->",
"alias",
",",
"$",
"reflection",
",",
"$",
"method",
"->",
"name",
",",
"$",
"this",
"->",
"interfaces",
")",
";",
"}",
"$",
"this",
"->",
"usedMethods",
"[",
"]",
"=",
"$",
"method",
"->",
"name",
";",
"}",
"}",
"}",
"// Check if the class is macroable",
"$",
"traits",
"=",
"collect",
"(",
"$",
"reflection",
"->",
"getTraitNames",
"(",
")",
")",
";",
"if",
"(",
"$",
"traits",
"->",
"contains",
"(",
"'Illuminate\\Support\\Traits\\Macroable'",
")",
")",
"{",
"$",
"properties",
"=",
"$",
"reflection",
"->",
"getStaticProperties",
"(",
")",
";",
"$",
"macros",
"=",
"isset",
"(",
"$",
"properties",
"[",
"'macros'",
"]",
")",
"?",
"$",
"properties",
"[",
"'macros'",
"]",
":",
"[",
"]",
";",
"foreach",
"(",
"$",
"macros",
"as",
"$",
"macro_name",
"=>",
"$",
"macro_func",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"macro_name",
",",
"$",
"this",
"->",
"usedMethods",
")",
")",
"{",
"// Add macros",
"$",
"this",
"->",
"methods",
"[",
"]",
"=",
"new",
"Macro",
"(",
"$",
"this",
"->",
"getMacroFunction",
"(",
"$",
"macro_func",
")",
",",
"$",
"this",
"->",
"alias",
",",
"$",
"reflection",
",",
"$",
"macro_name",
",",
"$",
"this",
"->",
"interfaces",
")",
";",
"$",
"this",
"->",
"usedMethods",
"[",
"]",
"=",
"$",
"macro_name",
";",
"}",
"}",
"}",
"}",
"}"
] |
Get the methods for one or multiple classes.
@return string
|
[
"Get",
"the",
"methods",
"for",
"one",
"or",
"multiple",
"classes",
"."
] |
87ebe458e9b5787e6b65b9c4b62df9c2b13be7fe
|
https://github.com/barryvdh/laravel-ide-helper/blob/87ebe458e9b5787e6b65b9c4b62df9c2b13be7fe/src/Alias.php#L339-L385
|
220,980
|
barryvdh/laravel-ide-helper
|
src/Alias.php
|
Alias.removeDuplicateMethodsFromPhpDoc
|
protected function removeDuplicateMethodsFromPhpDoc()
{
$methodNames = array_map(function (Method $method) {
return $method->getName();
}, $this->getMethods());
foreach ($this->phpdoc->getTags() as $tag) {
if ($tag instanceof MethodTag && in_array($tag->getMethodName(), $methodNames)) {
$this->phpdoc->deleteTag($tag);
}
}
}
|
php
|
protected function removeDuplicateMethodsFromPhpDoc()
{
$methodNames = array_map(function (Method $method) {
return $method->getName();
}, $this->getMethods());
foreach ($this->phpdoc->getTags() as $tag) {
if ($tag instanceof MethodTag && in_array($tag->getMethodName(), $methodNames)) {
$this->phpdoc->deleteTag($tag);
}
}
}
|
[
"protected",
"function",
"removeDuplicateMethodsFromPhpDoc",
"(",
")",
"{",
"$",
"methodNames",
"=",
"array_map",
"(",
"function",
"(",
"Method",
"$",
"method",
")",
"{",
"return",
"$",
"method",
"->",
"getName",
"(",
")",
";",
"}",
",",
"$",
"this",
"->",
"getMethods",
"(",
")",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"phpdoc",
"->",
"getTags",
"(",
")",
"as",
"$",
"tag",
")",
"{",
"if",
"(",
"$",
"tag",
"instanceof",
"MethodTag",
"&&",
"in_array",
"(",
"$",
"tag",
"->",
"getMethodName",
"(",
")",
",",
"$",
"methodNames",
")",
")",
"{",
"$",
"this",
"->",
"phpdoc",
"->",
"deleteTag",
"(",
"$",
"tag",
")",
";",
"}",
"}",
"}"
] |
Removes method tags from the doc comment that already appear as functions inside the class.
This prevents duplicate function errors in the IDE.
@return void
|
[
"Removes",
"method",
"tags",
"from",
"the",
"doc",
"comment",
"that",
"already",
"appear",
"as",
"functions",
"inside",
"the",
"class",
".",
"This",
"prevents",
"duplicate",
"function",
"errors",
"in",
"the",
"IDE",
"."
] |
87ebe458e9b5787e6b65b9c4b62df9c2b13be7fe
|
https://github.com/barryvdh/laravel-ide-helper/blob/87ebe458e9b5787e6b65b9c4b62df9c2b13be7fe/src/Alias.php#L440-L451
|
220,981
|
barryvdh/laravel-ide-helper
|
src/Method.php
|
Method.normalizeDescription
|
protected function normalizeDescription(DocBlock $phpdoc)
{
//Get the short + long description from the DocBlock
$description = $phpdoc->getText();
//Loop through parents/interfaces, to fill in {@inheritdoc}
if (strpos($description, '{@inheritdoc}') !== false) {
$inheritdoc = $this->getInheritDoc($this->method);
$inheritDescription = $inheritdoc->getText();
$description = str_replace('{@inheritdoc}', $inheritDescription, $description);
$phpdoc->setText($description);
$this->normalizeParams($inheritdoc);
$this->normalizeReturn($inheritdoc);
//Add the tags that are inherited
$inheritTags = $inheritdoc->getTags();
if ($inheritTags) {
/** @var Tag $tag */
foreach ($inheritTags as $tag) {
$tag->setDocBlock();
$phpdoc->appendTag($tag);
}
}
}
}
|
php
|
protected function normalizeDescription(DocBlock $phpdoc)
{
//Get the short + long description from the DocBlock
$description = $phpdoc->getText();
//Loop through parents/interfaces, to fill in {@inheritdoc}
if (strpos($description, '{@inheritdoc}') !== false) {
$inheritdoc = $this->getInheritDoc($this->method);
$inheritDescription = $inheritdoc->getText();
$description = str_replace('{@inheritdoc}', $inheritDescription, $description);
$phpdoc->setText($description);
$this->normalizeParams($inheritdoc);
$this->normalizeReturn($inheritdoc);
//Add the tags that are inherited
$inheritTags = $inheritdoc->getTags();
if ($inheritTags) {
/** @var Tag $tag */
foreach ($inheritTags as $tag) {
$tag->setDocBlock();
$phpdoc->appendTag($tag);
}
}
}
}
|
[
"protected",
"function",
"normalizeDescription",
"(",
"DocBlock",
"$",
"phpdoc",
")",
"{",
"//Get the short + long description from the DocBlock",
"$",
"description",
"=",
"$",
"phpdoc",
"->",
"getText",
"(",
")",
";",
"//Loop through parents/interfaces, to fill in {@inheritdoc}",
"if",
"(",
"strpos",
"(",
"$",
"description",
",",
"'{@inheritdoc}'",
")",
"!==",
"false",
")",
"{",
"$",
"inheritdoc",
"=",
"$",
"this",
"->",
"getInheritDoc",
"(",
"$",
"this",
"->",
"method",
")",
";",
"$",
"inheritDescription",
"=",
"$",
"inheritdoc",
"->",
"getText",
"(",
")",
";",
"$",
"description",
"=",
"str_replace",
"(",
"'{@inheritdoc}'",
",",
"$",
"inheritDescription",
",",
"$",
"description",
")",
";",
"$",
"phpdoc",
"->",
"setText",
"(",
"$",
"description",
")",
";",
"$",
"this",
"->",
"normalizeParams",
"(",
"$",
"inheritdoc",
")",
";",
"$",
"this",
"->",
"normalizeReturn",
"(",
"$",
"inheritdoc",
")",
";",
"//Add the tags that are inherited",
"$",
"inheritTags",
"=",
"$",
"inheritdoc",
"->",
"getTags",
"(",
")",
";",
"if",
"(",
"$",
"inheritTags",
")",
"{",
"/** @var Tag $tag */",
"foreach",
"(",
"$",
"inheritTags",
"as",
"$",
"tag",
")",
"{",
"$",
"tag",
"->",
"setDocBlock",
"(",
")",
";",
"$",
"phpdoc",
"->",
"appendTag",
"(",
"$",
"tag",
")",
";",
"}",
"}",
"}",
"}"
] |
Get the description and get the inherited docs.
@param DocBlock $phpdoc
|
[
"Get",
"the",
"description",
"and",
"get",
"the",
"inherited",
"docs",
"."
] |
87ebe458e9b5787e6b65b9c4b62df9c2b13be7fe
|
https://github.com/barryvdh/laravel-ide-helper/blob/87ebe458e9b5787e6b65b9c4b62df9c2b13be7fe/src/Method.php#L193-L219
|
220,982
|
barryvdh/laravel-ide-helper
|
src/Method.php
|
Method.normalizeParams
|
protected function normalizeParams(DocBlock $phpdoc)
{
//Get the return type and adjust them for beter autocomplete
$paramTags = $phpdoc->getTagsByName('param');
if ($paramTags) {
/** @var ParamTag $tag */
foreach ($paramTags as $tag) {
// Convert the keywords
$content = $this->convertKeywords($tag->getContent());
$tag->setContent($content);
// Get the expanded type and re-set the content
$content = $tag->getType() . ' ' . $tag->getVariableName() . ' ' . $tag->getDescription();
$tag->setContent(trim($content));
}
}
}
|
php
|
protected function normalizeParams(DocBlock $phpdoc)
{
//Get the return type and adjust them for beter autocomplete
$paramTags = $phpdoc->getTagsByName('param');
if ($paramTags) {
/** @var ParamTag $tag */
foreach ($paramTags as $tag) {
// Convert the keywords
$content = $this->convertKeywords($tag->getContent());
$tag->setContent($content);
// Get the expanded type and re-set the content
$content = $tag->getType() . ' ' . $tag->getVariableName() . ' ' . $tag->getDescription();
$tag->setContent(trim($content));
}
}
}
|
[
"protected",
"function",
"normalizeParams",
"(",
"DocBlock",
"$",
"phpdoc",
")",
"{",
"//Get the return type and adjust them for beter autocomplete",
"$",
"paramTags",
"=",
"$",
"phpdoc",
"->",
"getTagsByName",
"(",
"'param'",
")",
";",
"if",
"(",
"$",
"paramTags",
")",
"{",
"/** @var ParamTag $tag */",
"foreach",
"(",
"$",
"paramTags",
"as",
"$",
"tag",
")",
"{",
"// Convert the keywords",
"$",
"content",
"=",
"$",
"this",
"->",
"convertKeywords",
"(",
"$",
"tag",
"->",
"getContent",
"(",
")",
")",
";",
"$",
"tag",
"->",
"setContent",
"(",
"$",
"content",
")",
";",
"// Get the expanded type and re-set the content",
"$",
"content",
"=",
"$",
"tag",
"->",
"getType",
"(",
")",
".",
"' '",
".",
"$",
"tag",
"->",
"getVariableName",
"(",
")",
".",
"' '",
".",
"$",
"tag",
"->",
"getDescription",
"(",
")",
";",
"$",
"tag",
"->",
"setContent",
"(",
"trim",
"(",
"$",
"content",
")",
")",
";",
"}",
"}",
"}"
] |
Normalize the parameters
@param DocBlock $phpdoc
|
[
"Normalize",
"the",
"parameters"
] |
87ebe458e9b5787e6b65b9c4b62df9c2b13be7fe
|
https://github.com/barryvdh/laravel-ide-helper/blob/87ebe458e9b5787e6b65b9c4b62df9c2b13be7fe/src/Method.php#L226-L242
|
220,983
|
barryvdh/laravel-ide-helper
|
src/Method.php
|
Method.convertKeywords
|
protected function convertKeywords($string)
{
$string = str_replace('\Closure', 'Closure', $string);
$string = str_replace('Closure', '\Closure', $string);
$string = str_replace('dynamic', 'mixed', $string);
return $string;
}
|
php
|
protected function convertKeywords($string)
{
$string = str_replace('\Closure', 'Closure', $string);
$string = str_replace('Closure', '\Closure', $string);
$string = str_replace('dynamic', 'mixed', $string);
return $string;
}
|
[
"protected",
"function",
"convertKeywords",
"(",
"$",
"string",
")",
"{",
"$",
"string",
"=",
"str_replace",
"(",
"'\\Closure'",
",",
"'Closure'",
",",
"$",
"string",
")",
";",
"$",
"string",
"=",
"str_replace",
"(",
"'Closure'",
",",
"'\\Closure'",
",",
"$",
"string",
")",
";",
"$",
"string",
"=",
"str_replace",
"(",
"'dynamic'",
",",
"'mixed'",
",",
"$",
"string",
")",
";",
"return",
"$",
"string",
";",
"}"
] |
Convert keywwords that are incorrect.
@param string $string
@return string
|
[
"Convert",
"keywwords",
"that",
"are",
"incorrect",
"."
] |
87ebe458e9b5787e6b65b9c4b62df9c2b13be7fe
|
https://github.com/barryvdh/laravel-ide-helper/blob/87ebe458e9b5787e6b65b9c4b62df9c2b13be7fe/src/Method.php#L282-L289
|
220,984
|
barryvdh/laravel-ide-helper
|
src/Method.php
|
Method.getParameters
|
public function getParameters($method)
{
//Loop through the default values for paremeters, and make the correct output string
$params = array();
$paramsWithDefault = array();
foreach ($method->getParameters() as $param) {
$paramStr = '$' . $param->getName();
$params[] = $paramStr;
if ($param->isOptional()) {
$default = $param->isDefaultValueAvailable() ? $param->getDefaultValue() : null;
if (is_bool($default)) {
$default = $default ? 'true' : 'false';
} elseif (is_array($default)) {
$default = 'array()';
} elseif (is_null($default)) {
$default = 'null';
} elseif (is_int($default)) {
//$default = $default;
} elseif (is_resource($default)) {
//skip to not fail
} else {
$default = "'" . trim($default) . "'";
}
$paramStr .= " = $default";
}
$paramsWithDefault[] = $paramStr;
}
$this->params = $params;
$this->params_with_default = $paramsWithDefault;
}
|
php
|
public function getParameters($method)
{
//Loop through the default values for paremeters, and make the correct output string
$params = array();
$paramsWithDefault = array();
foreach ($method->getParameters() as $param) {
$paramStr = '$' . $param->getName();
$params[] = $paramStr;
if ($param->isOptional()) {
$default = $param->isDefaultValueAvailable() ? $param->getDefaultValue() : null;
if (is_bool($default)) {
$default = $default ? 'true' : 'false';
} elseif (is_array($default)) {
$default = 'array()';
} elseif (is_null($default)) {
$default = 'null';
} elseif (is_int($default)) {
//$default = $default;
} elseif (is_resource($default)) {
//skip to not fail
} else {
$default = "'" . trim($default) . "'";
}
$paramStr .= " = $default";
}
$paramsWithDefault[] = $paramStr;
}
$this->params = $params;
$this->params_with_default = $paramsWithDefault;
}
|
[
"public",
"function",
"getParameters",
"(",
"$",
"method",
")",
"{",
"//Loop through the default values for paremeters, and make the correct output string",
"$",
"params",
"=",
"array",
"(",
")",
";",
"$",
"paramsWithDefault",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"method",
"->",
"getParameters",
"(",
")",
"as",
"$",
"param",
")",
"{",
"$",
"paramStr",
"=",
"'$'",
".",
"$",
"param",
"->",
"getName",
"(",
")",
";",
"$",
"params",
"[",
"]",
"=",
"$",
"paramStr",
";",
"if",
"(",
"$",
"param",
"->",
"isOptional",
"(",
")",
")",
"{",
"$",
"default",
"=",
"$",
"param",
"->",
"isDefaultValueAvailable",
"(",
")",
"?",
"$",
"param",
"->",
"getDefaultValue",
"(",
")",
":",
"null",
";",
"if",
"(",
"is_bool",
"(",
"$",
"default",
")",
")",
"{",
"$",
"default",
"=",
"$",
"default",
"?",
"'true'",
":",
"'false'",
";",
"}",
"elseif",
"(",
"is_array",
"(",
"$",
"default",
")",
")",
"{",
"$",
"default",
"=",
"'array()'",
";",
"}",
"elseif",
"(",
"is_null",
"(",
"$",
"default",
")",
")",
"{",
"$",
"default",
"=",
"'null'",
";",
"}",
"elseif",
"(",
"is_int",
"(",
"$",
"default",
")",
")",
"{",
"//$default = $default;",
"}",
"elseif",
"(",
"is_resource",
"(",
"$",
"default",
")",
")",
"{",
"//skip to not fail",
"}",
"else",
"{",
"$",
"default",
"=",
"\"'\"",
".",
"trim",
"(",
"$",
"default",
")",
".",
"\"'\"",
";",
"}",
"$",
"paramStr",
".=",
"\" = $default\"",
";",
"}",
"$",
"paramsWithDefault",
"[",
"]",
"=",
"$",
"paramStr",
";",
"}",
"$",
"this",
"->",
"params",
"=",
"$",
"params",
";",
"$",
"this",
"->",
"params_with_default",
"=",
"$",
"paramsWithDefault",
";",
"}"
] |
Get the parameters and format them correctly
@param \ReflectionMethod $method
@return array
|
[
"Get",
"the",
"parameters",
"and",
"format",
"them",
"correctly"
] |
87ebe458e9b5787e6b65b9c4b62df9c2b13be7fe
|
https://github.com/barryvdh/laravel-ide-helper/blob/87ebe458e9b5787e6b65b9c4b62df9c2b13be7fe/src/Method.php#L311-L341
|
220,985
|
barryvdh/laravel-ide-helper
|
src/Console/MetaCommand.php
|
MetaCommand.getAbstracts
|
protected function getAbstracts()
{
$abstracts = $this->laravel->getBindings();
// Return the abstract names only
$keys = array_keys($abstracts);
sort($keys);
return $keys;
}
|
php
|
protected function getAbstracts()
{
$abstracts = $this->laravel->getBindings();
// Return the abstract names only
$keys = array_keys($abstracts);
sort($keys);
return $keys;
}
|
[
"protected",
"function",
"getAbstracts",
"(",
")",
"{",
"$",
"abstracts",
"=",
"$",
"this",
"->",
"laravel",
"->",
"getBindings",
"(",
")",
";",
"// Return the abstract names only",
"$",
"keys",
"=",
"array_keys",
"(",
"$",
"abstracts",
")",
";",
"sort",
"(",
"$",
"keys",
")",
";",
"return",
"$",
"keys",
";",
"}"
] |
Get a list of abstracts from the Laravel Application.
@return array
|
[
"Get",
"a",
"list",
"of",
"abstracts",
"from",
"the",
"Laravel",
"Application",
"."
] |
87ebe458e9b5787e6b65b9c4b62df9c2b13be7fe
|
https://github.com/barryvdh/laravel-ide-helper/blob/87ebe458e9b5787e6b65b9c4b62df9c2b13be7fe/src/Console/MetaCommand.php#L120-L130
|
220,986
|
barryvdh/laravel-ide-helper
|
src/Console/ModelsCommand.php
|
ModelsCommand.getTypeOverride
|
protected function getTypeOverride($type)
{
$typeOverrides = $this->laravel['config']->get('ide-helper.type_overrides', array());
return isset($typeOverrides[$type]) ? $typeOverrides[$type] : $type;
}
|
php
|
protected function getTypeOverride($type)
{
$typeOverrides = $this->laravel['config']->get('ide-helper.type_overrides', array());
return isset($typeOverrides[$type]) ? $typeOverrides[$type] : $type;
}
|
[
"protected",
"function",
"getTypeOverride",
"(",
"$",
"type",
")",
"{",
"$",
"typeOverrides",
"=",
"$",
"this",
"->",
"laravel",
"[",
"'config'",
"]",
"->",
"get",
"(",
"'ide-helper.type_overrides'",
",",
"array",
"(",
")",
")",
";",
"return",
"isset",
"(",
"$",
"typeOverrides",
"[",
"$",
"type",
"]",
")",
"?",
"$",
"typeOverrides",
"[",
"$",
"type",
"]",
":",
"$",
"type",
";",
"}"
] |
Returns the overide type for the give type.
@param string $type
@return string
|
[
"Returns",
"the",
"overide",
"type",
"for",
"the",
"give",
"type",
"."
] |
87ebe458e9b5787e6b65b9c4b62df9c2b13be7fe
|
https://github.com/barryvdh/laravel-ide-helper/blob/87ebe458e9b5787e6b65b9c4b62df9c2b13be7fe/src/Console/ModelsCommand.php#L315-L320
|
220,987
|
barryvdh/laravel-ide-helper
|
src/Console/ModelsCommand.php
|
ModelsCommand.getPropertiesFromTable
|
protected function getPropertiesFromTable($model)
{
$table = $model->getConnection()->getTablePrefix() . $model->getTable();
$schema = $model->getConnection()->getDoctrineSchemaManager($table);
$databasePlatform = $schema->getDatabasePlatform();
$databasePlatform->registerDoctrineTypeMapping('enum', 'string');
$platformName = $databasePlatform->getName();
$customTypes = $this->laravel['config']->get("ide-helper.custom_db_types.{$platformName}", array());
foreach ($customTypes as $yourTypeName => $doctrineTypeName) {
$databasePlatform->registerDoctrineTypeMapping($yourTypeName, $doctrineTypeName);
}
$database = null;
if (strpos($table, '.')) {
list($database, $table) = explode('.', $table);
}
$columns = $schema->listTableColumns($table, $database);
if ($columns) {
foreach ($columns as $column) {
$name = $column->getName();
if (in_array($name, $model->getDates())) {
$type = '\Illuminate\Support\Carbon';
} else {
$type = $column->getType()->getName();
switch ($type) {
case 'string':
case 'text':
case 'date':
case 'time':
case 'guid':
case 'datetimetz':
case 'datetime':
$type = 'string';
break;
case 'integer':
case 'bigint':
case 'smallint':
$type = 'integer';
break;
case 'boolean':
switch (config('database.default')) {
case 'sqlite':
case 'mysql':
$type = 'integer';
break;
default:
$type = 'boolean';
break;
}
break;
case 'decimal':
case 'float':
$type = 'float';
break;
default:
$type = 'mixed';
break;
}
}
$comment = $column->getComment();
if (!$column->getNotnull()) {
$this->nullableColumns[$name] = true;
}
$this->setProperty($name, $type, true, true, $comment, !$column->getNotnull());
if ($this->write_model_magic_where) {
$this->setMethod(
Str::camel("where_" . $name),
'\Illuminate\Database\Eloquent\Builder|\\' . get_class($model),
array('$value')
);
}
}
}
}
|
php
|
protected function getPropertiesFromTable($model)
{
$table = $model->getConnection()->getTablePrefix() . $model->getTable();
$schema = $model->getConnection()->getDoctrineSchemaManager($table);
$databasePlatform = $schema->getDatabasePlatform();
$databasePlatform->registerDoctrineTypeMapping('enum', 'string');
$platformName = $databasePlatform->getName();
$customTypes = $this->laravel['config']->get("ide-helper.custom_db_types.{$platformName}", array());
foreach ($customTypes as $yourTypeName => $doctrineTypeName) {
$databasePlatform->registerDoctrineTypeMapping($yourTypeName, $doctrineTypeName);
}
$database = null;
if (strpos($table, '.')) {
list($database, $table) = explode('.', $table);
}
$columns = $schema->listTableColumns($table, $database);
if ($columns) {
foreach ($columns as $column) {
$name = $column->getName();
if (in_array($name, $model->getDates())) {
$type = '\Illuminate\Support\Carbon';
} else {
$type = $column->getType()->getName();
switch ($type) {
case 'string':
case 'text':
case 'date':
case 'time':
case 'guid':
case 'datetimetz':
case 'datetime':
$type = 'string';
break;
case 'integer':
case 'bigint':
case 'smallint':
$type = 'integer';
break;
case 'boolean':
switch (config('database.default')) {
case 'sqlite':
case 'mysql':
$type = 'integer';
break;
default:
$type = 'boolean';
break;
}
break;
case 'decimal':
case 'float':
$type = 'float';
break;
default:
$type = 'mixed';
break;
}
}
$comment = $column->getComment();
if (!$column->getNotnull()) {
$this->nullableColumns[$name] = true;
}
$this->setProperty($name, $type, true, true, $comment, !$column->getNotnull());
if ($this->write_model_magic_where) {
$this->setMethod(
Str::camel("where_" . $name),
'\Illuminate\Database\Eloquent\Builder|\\' . get_class($model),
array('$value')
);
}
}
}
}
|
[
"protected",
"function",
"getPropertiesFromTable",
"(",
"$",
"model",
")",
"{",
"$",
"table",
"=",
"$",
"model",
"->",
"getConnection",
"(",
")",
"->",
"getTablePrefix",
"(",
")",
".",
"$",
"model",
"->",
"getTable",
"(",
")",
";",
"$",
"schema",
"=",
"$",
"model",
"->",
"getConnection",
"(",
")",
"->",
"getDoctrineSchemaManager",
"(",
"$",
"table",
")",
";",
"$",
"databasePlatform",
"=",
"$",
"schema",
"->",
"getDatabasePlatform",
"(",
")",
";",
"$",
"databasePlatform",
"->",
"registerDoctrineTypeMapping",
"(",
"'enum'",
",",
"'string'",
")",
";",
"$",
"platformName",
"=",
"$",
"databasePlatform",
"->",
"getName",
"(",
")",
";",
"$",
"customTypes",
"=",
"$",
"this",
"->",
"laravel",
"[",
"'config'",
"]",
"->",
"get",
"(",
"\"ide-helper.custom_db_types.{$platformName}\"",
",",
"array",
"(",
")",
")",
";",
"foreach",
"(",
"$",
"customTypes",
"as",
"$",
"yourTypeName",
"=>",
"$",
"doctrineTypeName",
")",
"{",
"$",
"databasePlatform",
"->",
"registerDoctrineTypeMapping",
"(",
"$",
"yourTypeName",
",",
"$",
"doctrineTypeName",
")",
";",
"}",
"$",
"database",
"=",
"null",
";",
"if",
"(",
"strpos",
"(",
"$",
"table",
",",
"'.'",
")",
")",
"{",
"list",
"(",
"$",
"database",
",",
"$",
"table",
")",
"=",
"explode",
"(",
"'.'",
",",
"$",
"table",
")",
";",
"}",
"$",
"columns",
"=",
"$",
"schema",
"->",
"listTableColumns",
"(",
"$",
"table",
",",
"$",
"database",
")",
";",
"if",
"(",
"$",
"columns",
")",
"{",
"foreach",
"(",
"$",
"columns",
"as",
"$",
"column",
")",
"{",
"$",
"name",
"=",
"$",
"column",
"->",
"getName",
"(",
")",
";",
"if",
"(",
"in_array",
"(",
"$",
"name",
",",
"$",
"model",
"->",
"getDates",
"(",
")",
")",
")",
"{",
"$",
"type",
"=",
"'\\Illuminate\\Support\\Carbon'",
";",
"}",
"else",
"{",
"$",
"type",
"=",
"$",
"column",
"->",
"getType",
"(",
")",
"->",
"getName",
"(",
")",
";",
"switch",
"(",
"$",
"type",
")",
"{",
"case",
"'string'",
":",
"case",
"'text'",
":",
"case",
"'date'",
":",
"case",
"'time'",
":",
"case",
"'guid'",
":",
"case",
"'datetimetz'",
":",
"case",
"'datetime'",
":",
"$",
"type",
"=",
"'string'",
";",
"break",
";",
"case",
"'integer'",
":",
"case",
"'bigint'",
":",
"case",
"'smallint'",
":",
"$",
"type",
"=",
"'integer'",
";",
"break",
";",
"case",
"'boolean'",
":",
"switch",
"(",
"config",
"(",
"'database.default'",
")",
")",
"{",
"case",
"'sqlite'",
":",
"case",
"'mysql'",
":",
"$",
"type",
"=",
"'integer'",
";",
"break",
";",
"default",
":",
"$",
"type",
"=",
"'boolean'",
";",
"break",
";",
"}",
"break",
";",
"case",
"'decimal'",
":",
"case",
"'float'",
":",
"$",
"type",
"=",
"'float'",
";",
"break",
";",
"default",
":",
"$",
"type",
"=",
"'mixed'",
";",
"break",
";",
"}",
"}",
"$",
"comment",
"=",
"$",
"column",
"->",
"getComment",
"(",
")",
";",
"if",
"(",
"!",
"$",
"column",
"->",
"getNotnull",
"(",
")",
")",
"{",
"$",
"this",
"->",
"nullableColumns",
"[",
"$",
"name",
"]",
"=",
"true",
";",
"}",
"$",
"this",
"->",
"setProperty",
"(",
"$",
"name",
",",
"$",
"type",
",",
"true",
",",
"true",
",",
"$",
"comment",
",",
"!",
"$",
"column",
"->",
"getNotnull",
"(",
")",
")",
";",
"if",
"(",
"$",
"this",
"->",
"write_model_magic_where",
")",
"{",
"$",
"this",
"->",
"setMethod",
"(",
"Str",
"::",
"camel",
"(",
"\"where_\"",
".",
"$",
"name",
")",
",",
"'\\Illuminate\\Database\\Eloquent\\Builder|\\\\'",
".",
"get_class",
"(",
"$",
"model",
")",
",",
"array",
"(",
"'$value'",
")",
")",
";",
"}",
"}",
"}",
"}"
] |
Load the properties from the database table.
@param \Illuminate\Database\Eloquent\Model $model
|
[
"Load",
"the",
"properties",
"from",
"the",
"database",
"table",
"."
] |
87ebe458e9b5787e6b65b9c4b62df9c2b13be7fe
|
https://github.com/barryvdh/laravel-ide-helper/blob/87ebe458e9b5787e6b65b9c4b62df9c2b13be7fe/src/Console/ModelsCommand.php#L327-L404
|
220,988
|
barryvdh/laravel-ide-helper
|
src/Console/ModelsCommand.php
|
ModelsCommand.isRelationForeignKeyNullable
|
private function isRelationForeignKeyNullable(Relation $relation)
{
$reflectionObj = new \ReflectionObject($relation);
if (!$reflectionObj->hasProperty('foreignKey')) {
return false;
}
$fkProp = $reflectionObj->getProperty('foreignKey');
$fkProp->setAccessible(true);
return isset($this->nullableColumns[$fkProp->getValue($relation)]);
}
|
php
|
private function isRelationForeignKeyNullable(Relation $relation)
{
$reflectionObj = new \ReflectionObject($relation);
if (!$reflectionObj->hasProperty('foreignKey')) {
return false;
}
$fkProp = $reflectionObj->getProperty('foreignKey');
$fkProp->setAccessible(true);
return isset($this->nullableColumns[$fkProp->getValue($relation)]);
}
|
[
"private",
"function",
"isRelationForeignKeyNullable",
"(",
"Relation",
"$",
"relation",
")",
"{",
"$",
"reflectionObj",
"=",
"new",
"\\",
"ReflectionObject",
"(",
"$",
"relation",
")",
";",
"if",
"(",
"!",
"$",
"reflectionObj",
"->",
"hasProperty",
"(",
"'foreignKey'",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"fkProp",
"=",
"$",
"reflectionObj",
"->",
"getProperty",
"(",
"'foreignKey'",
")",
";",
"$",
"fkProp",
"->",
"setAccessible",
"(",
"true",
")",
";",
"return",
"isset",
"(",
"$",
"this",
"->",
"nullableColumns",
"[",
"$",
"fkProp",
"->",
"getValue",
"(",
"$",
"relation",
")",
"]",
")",
";",
"}"
] |
Check if the foreign key of the relation is nullable
@param Relation $relation
@return bool
|
[
"Check",
"if",
"the",
"foreign",
"key",
"of",
"the",
"relation",
"is",
"nullable"
] |
87ebe458e9b5787e6b65b9c4b62df9c2b13be7fe
|
https://github.com/barryvdh/laravel-ide-helper/blob/87ebe458e9b5787e6b65b9c4b62df9c2b13be7fe/src/Console/ModelsCommand.php#L548-L558
|
220,989
|
barryvdh/laravel-ide-helper
|
src/Console/ModelsCommand.php
|
ModelsCommand.getReturnTypeFromDocBlock
|
protected function getReturnTypeFromDocBlock(\ReflectionMethod $reflection)
{
$type = null;
$phpdoc = new DocBlock($reflection);
if ($phpdoc->hasTag('return')) {
$type = $phpdoc->getTagsByName('return')[0]->getType();
}
return $type;
}
|
php
|
protected function getReturnTypeFromDocBlock(\ReflectionMethod $reflection)
{
$type = null;
$phpdoc = new DocBlock($reflection);
if ($phpdoc->hasTag('return')) {
$type = $phpdoc->getTagsByName('return')[0]->getType();
}
return $type;
}
|
[
"protected",
"function",
"getReturnTypeFromDocBlock",
"(",
"\\",
"ReflectionMethod",
"$",
"reflection",
")",
"{",
"$",
"type",
"=",
"null",
";",
"$",
"phpdoc",
"=",
"new",
"DocBlock",
"(",
"$",
"reflection",
")",
";",
"if",
"(",
"$",
"phpdoc",
"->",
"hasTag",
"(",
"'return'",
")",
")",
"{",
"$",
"type",
"=",
"$",
"phpdoc",
"->",
"getTagsByName",
"(",
"'return'",
")",
"[",
"0",
"]",
"->",
"getType",
"(",
")",
";",
"}",
"return",
"$",
"type",
";",
"}"
] |
Get method return type based on it DocBlock comment
@param \ReflectionMethod $reflection
@return null|string
|
[
"Get",
"method",
"return",
"type",
"based",
"on",
"it",
"DocBlock",
"comment"
] |
87ebe458e9b5787e6b65b9c4b62df9c2b13be7fe
|
https://github.com/barryvdh/laravel-ide-helper/blob/87ebe458e9b5787e6b65b9c4b62df9c2b13be7fe/src/Console/ModelsCommand.php#L777-L787
|
220,990
|
barryvdh/laravel-ide-helper
|
src/Console/ModelsCommand.php
|
ModelsCommand.getSoftDeleteMethods
|
protected function getSoftDeleteMethods($model)
{
$traits = class_uses(get_class($model), true);
if (in_array('Illuminate\\Database\\Eloquent\\SoftDeletes', $traits)) {
$this->setMethod('forceDelete', 'bool|null', []);
$this->setMethod('restore', 'bool|null', []);
$this->setMethod('withTrashed', '\Illuminate\Database\Query\Builder|\\' . get_class($model), []);
$this->setMethod('withoutTrashed', '\Illuminate\Database\Query\Builder|\\' . get_class($model), []);
$this->setMethod('onlyTrashed', '\Illuminate\Database\Query\Builder|\\' . get_class($model), []);
}
}
|
php
|
protected function getSoftDeleteMethods($model)
{
$traits = class_uses(get_class($model), true);
if (in_array('Illuminate\\Database\\Eloquent\\SoftDeletes', $traits)) {
$this->setMethod('forceDelete', 'bool|null', []);
$this->setMethod('restore', 'bool|null', []);
$this->setMethod('withTrashed', '\Illuminate\Database\Query\Builder|\\' . get_class($model), []);
$this->setMethod('withoutTrashed', '\Illuminate\Database\Query\Builder|\\' . get_class($model), []);
$this->setMethod('onlyTrashed', '\Illuminate\Database\Query\Builder|\\' . get_class($model), []);
}
}
|
[
"protected",
"function",
"getSoftDeleteMethods",
"(",
"$",
"model",
")",
"{",
"$",
"traits",
"=",
"class_uses",
"(",
"get_class",
"(",
"$",
"model",
")",
",",
"true",
")",
";",
"if",
"(",
"in_array",
"(",
"'Illuminate\\\\Database\\\\Eloquent\\\\SoftDeletes'",
",",
"$",
"traits",
")",
")",
"{",
"$",
"this",
"->",
"setMethod",
"(",
"'forceDelete'",
",",
"'bool|null'",
",",
"[",
"]",
")",
";",
"$",
"this",
"->",
"setMethod",
"(",
"'restore'",
",",
"'bool|null'",
",",
"[",
"]",
")",
";",
"$",
"this",
"->",
"setMethod",
"(",
"'withTrashed'",
",",
"'\\Illuminate\\Database\\Query\\Builder|\\\\'",
".",
"get_class",
"(",
"$",
"model",
")",
",",
"[",
"]",
")",
";",
"$",
"this",
"->",
"setMethod",
"(",
"'withoutTrashed'",
",",
"'\\Illuminate\\Database\\Query\\Builder|\\\\'",
".",
"get_class",
"(",
"$",
"model",
")",
",",
"[",
"]",
")",
";",
"$",
"this",
"->",
"setMethod",
"(",
"'onlyTrashed'",
",",
"'\\Illuminate\\Database\\Query\\Builder|\\\\'",
".",
"get_class",
"(",
"$",
"model",
")",
",",
"[",
"]",
")",
";",
"}",
"}"
] |
Generates methods provided by the SoftDeletes trait
@param \Illuminate\Database\Eloquent\Model $model
|
[
"Generates",
"methods",
"provided",
"by",
"the",
"SoftDeletes",
"trait"
] |
87ebe458e9b5787e6b65b9c4b62df9c2b13be7fe
|
https://github.com/barryvdh/laravel-ide-helper/blob/87ebe458e9b5787e6b65b9c4b62df9c2b13be7fe/src/Console/ModelsCommand.php#L793-L804
|
220,991
|
aimeos/aimeos-laravel
|
src/Aimeos/Shop/Base/View.php
|
View.addNumber
|
protected function addNumber( \Aimeos\MW\View\Iface $view, \Aimeos\MW\Config\Iface $config, $locale )
{
$pattern = $config->get( 'client/html/common/format/pattern' );
$helper = new \Aimeos\MW\View\Helper\Number\Locale( $view, $locale, $pattern );
$view->addHelper( 'number', $helper );
return $view;
}
|
php
|
protected function addNumber( \Aimeos\MW\View\Iface $view, \Aimeos\MW\Config\Iface $config, $locale )
{
$pattern = $config->get( 'client/html/common/format/pattern' );
$helper = new \Aimeos\MW\View\Helper\Number\Locale( $view, $locale, $pattern );
$view->addHelper( 'number', $helper );
return $view;
}
|
[
"protected",
"function",
"addNumber",
"(",
"\\",
"Aimeos",
"\\",
"MW",
"\\",
"View",
"\\",
"Iface",
"$",
"view",
",",
"\\",
"Aimeos",
"\\",
"MW",
"\\",
"Config",
"\\",
"Iface",
"$",
"config",
",",
"$",
"locale",
")",
"{",
"$",
"pattern",
"=",
"$",
"config",
"->",
"get",
"(",
"'client/html/common/format/pattern'",
")",
";",
"$",
"helper",
"=",
"new",
"\\",
"Aimeos",
"\\",
"MW",
"\\",
"View",
"\\",
"Helper",
"\\",
"Number",
"\\",
"Locale",
"(",
"$",
"view",
",",
"$",
"locale",
",",
"$",
"pattern",
")",
";",
"$",
"view",
"->",
"addHelper",
"(",
"'number'",
",",
"$",
"helper",
")",
";",
"return",
"$",
"view",
";",
"}"
] |
Adds the "number" helper to the view object
@param \Aimeos\MW\View\Iface $view View object
@param \Aimeos\MW\Config\Iface $config Configuration object
@param string|null $locale Code of the current language or null for no translation
@return \Aimeos\MW\View\Iface Modified view object
|
[
"Adds",
"the",
"number",
"helper",
"to",
"the",
"view",
"object"
] |
d407e5ca95433fa3e900df8dbc9ab1ea74df1afe
|
https://github.com/aimeos/aimeos-laravel/blob/d407e5ca95433fa3e900df8dbc9ab1ea74df1afe/src/Aimeos/Shop/Base/View.php#L161-L169
|
220,992
|
aimeos/aimeos-laravel
|
src/Aimeos/Shop/Controller/JqadmController.php
|
JqadmController.exportAction
|
public function exportAction()
{
if( config( 'shop.authorize', true ) ) {
$this->authorize( 'admin', [JqadmController::class, ['admin', 'editor']] );
}
$cntl = $this->createAdmin();
if( ( $html = $cntl->export() ) == '' ) {
return $cntl->getView()->response();
}
return $this->getHtml( $html );
}
|
php
|
public function exportAction()
{
if( config( 'shop.authorize', true ) ) {
$this->authorize( 'admin', [JqadmController::class, ['admin', 'editor']] );
}
$cntl = $this->createAdmin();
if( ( $html = $cntl->export() ) == '' ) {
return $cntl->getView()->response();
}
return $this->getHtml( $html );
}
|
[
"public",
"function",
"exportAction",
"(",
")",
"{",
"if",
"(",
"config",
"(",
"'shop.authorize'",
",",
"true",
")",
")",
"{",
"$",
"this",
"->",
"authorize",
"(",
"'admin'",
",",
"[",
"JqadmController",
"::",
"class",
",",
"[",
"'admin'",
",",
"'editor'",
"]",
"]",
")",
";",
"}",
"$",
"cntl",
"=",
"$",
"this",
"->",
"createAdmin",
"(",
")",
";",
"if",
"(",
"(",
"$",
"html",
"=",
"$",
"cntl",
"->",
"export",
"(",
")",
")",
"==",
"''",
")",
"{",
"return",
"$",
"cntl",
"->",
"getView",
"(",
")",
"->",
"response",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"getHtml",
"(",
"$",
"html",
")",
";",
"}"
] |
Exports the data for a resource object
@return string Generated output
|
[
"Exports",
"the",
"data",
"for",
"a",
"resource",
"object"
] |
d407e5ca95433fa3e900df8dbc9ab1ea74df1afe
|
https://github.com/aimeos/aimeos-laravel/blob/d407e5ca95433fa3e900df8dbc9ab1ea74df1afe/src/Aimeos/Shop/Controller/JqadmController.php#L143-L156
|
220,993
|
aimeos/aimeos-laravel
|
src/Aimeos/Shop/Controller/JqadmController.php
|
JqadmController.getHtml
|
protected function getHtml( $content )
{
$site = Route::input( 'site', Input::get( 'site', 'default' ) );
return View::make( 'shop::jqadm.index', array( 'content' => $content, 'site' => $site ) );
}
|
php
|
protected function getHtml( $content )
{
$site = Route::input( 'site', Input::get( 'site', 'default' ) );
return View::make( 'shop::jqadm.index', array( 'content' => $content, 'site' => $site ) );
}
|
[
"protected",
"function",
"getHtml",
"(",
"$",
"content",
")",
"{",
"$",
"site",
"=",
"Route",
"::",
"input",
"(",
"'site'",
",",
"Input",
"::",
"get",
"(",
"'site'",
",",
"'default'",
")",
")",
";",
"return",
"View",
"::",
"make",
"(",
"'shop::jqadm.index'",
",",
"array",
"(",
"'content'",
"=>",
"$",
"content",
",",
"'site'",
"=>",
"$",
"site",
")",
")",
";",
"}"
] |
Returns the generated HTML code
@param string $content Content from admin client
@return \Illuminate\Contracts\View\View View for rendering the output
|
[
"Returns",
"the",
"generated",
"HTML",
"code"
] |
d407e5ca95433fa3e900df8dbc9ab1ea74df1afe
|
https://github.com/aimeos/aimeos-laravel/blob/d407e5ca95433fa3e900df8dbc9ab1ea74df1afe/src/Aimeos/Shop/Controller/JqadmController.php#L258-L262
|
220,994
|
aimeos/aimeos-laravel
|
src/Aimeos/Shop/Base/Shop.php
|
Shop.get
|
public function get( $name )
{
if( !isset( $this->objects[$name] ) )
{
$client = \Aimeos\Client\Html::create( $this->context, $name );
$client->setView( clone $this->view );
$client->process();
$this->objects[$name] = $client;
}
return $this->objects[$name];
}
|
php
|
public function get( $name )
{
if( !isset( $this->objects[$name] ) )
{
$client = \Aimeos\Client\Html::create( $this->context, $name );
$client->setView( clone $this->view );
$client->process();
$this->objects[$name] = $client;
}
return $this->objects[$name];
}
|
[
"public",
"function",
"get",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"objects",
"[",
"$",
"name",
"]",
")",
")",
"{",
"$",
"client",
"=",
"\\",
"Aimeos",
"\\",
"Client",
"\\",
"Html",
"::",
"create",
"(",
"$",
"this",
"->",
"context",
",",
"$",
"name",
")",
";",
"$",
"client",
"->",
"setView",
"(",
"clone",
"$",
"this",
"->",
"view",
")",
";",
"$",
"client",
"->",
"process",
"(",
")",
";",
"$",
"this",
"->",
"objects",
"[",
"$",
"name",
"]",
"=",
"$",
"client",
";",
"}",
"return",
"$",
"this",
"->",
"objects",
"[",
"$",
"name",
"]",
";",
"}"
] |
Returns the HTML client for the given name
@param string $name Name of the shop component
@return \Aimeos\Client\Html\Iface HTML client
|
[
"Returns",
"the",
"HTML",
"client",
"for",
"the",
"given",
"name"
] |
d407e5ca95433fa3e900df8dbc9ab1ea74df1afe
|
https://github.com/aimeos/aimeos-laravel/blob/d407e5ca95433fa3e900df8dbc9ab1ea74df1afe/src/Aimeos/Shop/Base/Shop.php#L63-L75
|
220,995
|
aimeos/aimeos-laravel
|
src/Aimeos/Shop/Command/AccountCommand.php
|
AccountCommand.addListItem
|
protected function addListItem( \Aimeos\MShop\Context\Item\Iface $context, $userid, $groupid )
{
$manager = \Aimeos\MShop::create( $context, 'customer/lists' );
$search = $manager->createSearch();
$expr = array(
$search->compare( '==', 'customer.lists.parentid', $userid ),
$search->compare( '==', 'customer.lists.refid', $groupid ),
$search->compare( '==', 'customer.lists.type', 'default' ),
$search->compare( '==', 'customer.lists.domain', 'customer/group' ),
);
$search->setConditions( $search->combine( '&&', $expr ) );
$search->setSlice( 0, 1 );
if( count( $manager->searchItems( $search ) ) === 0 )
{
$item = $manager->createItem();
$item->setDomain( 'customer/group' );
$item->setParentId( $userid );
$item->setRefId( $groupid );
$item->setType( 'default' );
$item->setStatus( 1 );
$manager->saveItem( $item, false );
}
}
|
php
|
protected function addListItem( \Aimeos\MShop\Context\Item\Iface $context, $userid, $groupid )
{
$manager = \Aimeos\MShop::create( $context, 'customer/lists' );
$search = $manager->createSearch();
$expr = array(
$search->compare( '==', 'customer.lists.parentid', $userid ),
$search->compare( '==', 'customer.lists.refid', $groupid ),
$search->compare( '==', 'customer.lists.type', 'default' ),
$search->compare( '==', 'customer.lists.domain', 'customer/group' ),
);
$search->setConditions( $search->combine( '&&', $expr ) );
$search->setSlice( 0, 1 );
if( count( $manager->searchItems( $search ) ) === 0 )
{
$item = $manager->createItem();
$item->setDomain( 'customer/group' );
$item->setParentId( $userid );
$item->setRefId( $groupid );
$item->setType( 'default' );
$item->setStatus( 1 );
$manager->saveItem( $item, false );
}
}
|
[
"protected",
"function",
"addListItem",
"(",
"\\",
"Aimeos",
"\\",
"MShop",
"\\",
"Context",
"\\",
"Item",
"\\",
"Iface",
"$",
"context",
",",
"$",
"userid",
",",
"$",
"groupid",
")",
"{",
"$",
"manager",
"=",
"\\",
"Aimeos",
"\\",
"MShop",
"::",
"create",
"(",
"$",
"context",
",",
"'customer/lists'",
")",
";",
"$",
"search",
"=",
"$",
"manager",
"->",
"createSearch",
"(",
")",
";",
"$",
"expr",
"=",
"array",
"(",
"$",
"search",
"->",
"compare",
"(",
"'=='",
",",
"'customer.lists.parentid'",
",",
"$",
"userid",
")",
",",
"$",
"search",
"->",
"compare",
"(",
"'=='",
",",
"'customer.lists.refid'",
",",
"$",
"groupid",
")",
",",
"$",
"search",
"->",
"compare",
"(",
"'=='",
",",
"'customer.lists.type'",
",",
"'default'",
")",
",",
"$",
"search",
"->",
"compare",
"(",
"'=='",
",",
"'customer.lists.domain'",
",",
"'customer/group'",
")",
",",
")",
";",
"$",
"search",
"->",
"setConditions",
"(",
"$",
"search",
"->",
"combine",
"(",
"'&&'",
",",
"$",
"expr",
")",
")",
";",
"$",
"search",
"->",
"setSlice",
"(",
"0",
",",
"1",
")",
";",
"if",
"(",
"count",
"(",
"$",
"manager",
"->",
"searchItems",
"(",
"$",
"search",
")",
")",
"===",
"0",
")",
"{",
"$",
"item",
"=",
"$",
"manager",
"->",
"createItem",
"(",
")",
";",
"$",
"item",
"->",
"setDomain",
"(",
"'customer/group'",
")",
";",
"$",
"item",
"->",
"setParentId",
"(",
"$",
"userid",
")",
";",
"$",
"item",
"->",
"setRefId",
"(",
"$",
"groupid",
")",
";",
"$",
"item",
"->",
"setType",
"(",
"'default'",
")",
";",
"$",
"item",
"->",
"setStatus",
"(",
"1",
")",
";",
"$",
"manager",
"->",
"saveItem",
"(",
"$",
"item",
",",
"false",
")",
";",
"}",
"}"
] |
Associates the user to the group by their given IDs
@param \Aimeos\MShop\Context\Item\Iface $context Aimeos context object
@param string $userid Unique user ID
@param string $groupid Unique group ID
|
[
"Associates",
"the",
"user",
"to",
"the",
"group",
"by",
"their",
"given",
"IDs"
] |
d407e5ca95433fa3e900df8dbc9ab1ea74df1afe
|
https://github.com/aimeos/aimeos-laravel/blob/d407e5ca95433fa3e900df8dbc9ab1ea74df1afe/src/Aimeos/Shop/Command/AccountCommand.php#L80-L105
|
220,996
|
aimeos/aimeos-laravel
|
src/Aimeos/Shop/Command/AccountCommand.php
|
AccountCommand.createCustomerItem
|
protected function createCustomerItem( \Aimeos\MShop\Context\Item\Iface $context, $email, $password )
{
$manager = \Aimeos\MShop::create( $context, 'customer' );
try {
$item = $manager->findItem( $email );
} catch( \Aimeos\MShop\Exception $e ) {
$item = $manager->createItem();
}
$item->setCode( $email );
$item->setLabel( $email );
$item->getPaymentAddress()->setEmail( $email );
$item->setPassword( $password );
$item->setStatus( 1 );
$manager->saveItem( $item );
return $item;
}
|
php
|
protected function createCustomerItem( \Aimeos\MShop\Context\Item\Iface $context, $email, $password )
{
$manager = \Aimeos\MShop::create( $context, 'customer' );
try {
$item = $manager->findItem( $email );
} catch( \Aimeos\MShop\Exception $e ) {
$item = $manager->createItem();
}
$item->setCode( $email );
$item->setLabel( $email );
$item->getPaymentAddress()->setEmail( $email );
$item->setPassword( $password );
$item->setStatus( 1 );
$manager->saveItem( $item );
return $item;
}
|
[
"protected",
"function",
"createCustomerItem",
"(",
"\\",
"Aimeos",
"\\",
"MShop",
"\\",
"Context",
"\\",
"Item",
"\\",
"Iface",
"$",
"context",
",",
"$",
"email",
",",
"$",
"password",
")",
"{",
"$",
"manager",
"=",
"\\",
"Aimeos",
"\\",
"MShop",
"::",
"create",
"(",
"$",
"context",
",",
"'customer'",
")",
";",
"try",
"{",
"$",
"item",
"=",
"$",
"manager",
"->",
"findItem",
"(",
"$",
"email",
")",
";",
"}",
"catch",
"(",
"\\",
"Aimeos",
"\\",
"MShop",
"\\",
"Exception",
"$",
"e",
")",
"{",
"$",
"item",
"=",
"$",
"manager",
"->",
"createItem",
"(",
")",
";",
"}",
"$",
"item",
"->",
"setCode",
"(",
"$",
"email",
")",
";",
"$",
"item",
"->",
"setLabel",
"(",
"$",
"email",
")",
";",
"$",
"item",
"->",
"getPaymentAddress",
"(",
")",
"->",
"setEmail",
"(",
"$",
"email",
")",
";",
"$",
"item",
"->",
"setPassword",
"(",
"$",
"password",
")",
";",
"$",
"item",
"->",
"setStatus",
"(",
"1",
")",
";",
"$",
"manager",
"->",
"saveItem",
"(",
"$",
"item",
")",
";",
"return",
"$",
"item",
";",
"}"
] |
Returns the customer item for the given e-mail and set its password
If the customer doesn't exist yet, it will be created.
@param \Aimeos\MShop\Context\Item\Iface $context Aimeos context object
@param string $email Unique e-mail address
@param string $password New user password
@return \Aimeos\MShop\Customer\Item\Iface Aimeos customer item object
|
[
"Returns",
"the",
"customer",
"item",
"for",
"the",
"given",
"e",
"-",
"mail",
"and",
"set",
"its",
"password"
] |
d407e5ca95433fa3e900df8dbc9ab1ea74df1afe
|
https://github.com/aimeos/aimeos-laravel/blob/d407e5ca95433fa3e900df8dbc9ab1ea74df1afe/src/Aimeos/Shop/Command/AccountCommand.php#L161-L180
|
220,997
|
aimeos/aimeos-laravel
|
src/Aimeos/Shop/Command/AccountCommand.php
|
AccountCommand.getGroupItem
|
protected function getGroupItem( \Aimeos\MShop\Context\Item\Iface $context, $code )
{
$manager = \Aimeos\MShop::create( $context, 'customer/group' );
try
{
$item = $manager->findItem( $code );
}
catch( \Aimeos\MShop\Exception $e )
{
$item = $manager->createItem();
$item->setLabel( $code );
$item->setCode( $code );
$manager->saveItem( $item );
}
return $item;
}
|
php
|
protected function getGroupItem( \Aimeos\MShop\Context\Item\Iface $context, $code )
{
$manager = \Aimeos\MShop::create( $context, 'customer/group' );
try
{
$item = $manager->findItem( $code );
}
catch( \Aimeos\MShop\Exception $e )
{
$item = $manager->createItem();
$item->setLabel( $code );
$item->setCode( $code );
$manager->saveItem( $item );
}
return $item;
}
|
[
"protected",
"function",
"getGroupItem",
"(",
"\\",
"Aimeos",
"\\",
"MShop",
"\\",
"Context",
"\\",
"Item",
"\\",
"Iface",
"$",
"context",
",",
"$",
"code",
")",
"{",
"$",
"manager",
"=",
"\\",
"Aimeos",
"\\",
"MShop",
"::",
"create",
"(",
"$",
"context",
",",
"'customer/group'",
")",
";",
"try",
"{",
"$",
"item",
"=",
"$",
"manager",
"->",
"findItem",
"(",
"$",
"code",
")",
";",
"}",
"catch",
"(",
"\\",
"Aimeos",
"\\",
"MShop",
"\\",
"Exception",
"$",
"e",
")",
"{",
"$",
"item",
"=",
"$",
"manager",
"->",
"createItem",
"(",
")",
";",
"$",
"item",
"->",
"setLabel",
"(",
"$",
"code",
")",
";",
"$",
"item",
"->",
"setCode",
"(",
"$",
"code",
")",
";",
"$",
"manager",
"->",
"saveItem",
"(",
"$",
"item",
")",
";",
"}",
"return",
"$",
"item",
";",
"}"
] |
Returns the customer group item for the given code
@param \Aimeos\MShop\Context\Item\Iface $context Aimeos context object
@param string $code Unique customer group code
@return \Aimeos\MShop\Customer\Item\Group\Iface Aimeos customer group item object
|
[
"Returns",
"the",
"customer",
"group",
"item",
"for",
"the",
"given",
"code"
] |
d407e5ca95433fa3e900df8dbc9ab1ea74df1afe
|
https://github.com/aimeos/aimeos-laravel/blob/d407e5ca95433fa3e900df8dbc9ab1ea74df1afe/src/Aimeos/Shop/Command/AccountCommand.php#L204-L222
|
220,998
|
aimeos/aimeos-laravel
|
src/Aimeos/Shop/Command/SetupCommand.php
|
SetupCommand.getDbConfig
|
protected function getDbConfig( \Aimeos\MW\Config\Iface $conf )
{
$dbconfig = $conf->get( 'resource', array() );
foreach( $dbconfig as $rname => $dbconf )
{
if( strncmp( $rname, 'db', 2 ) !== 0 ) {
unset( $dbconfig[$rname] );
}
}
return $dbconfig;
}
|
php
|
protected function getDbConfig( \Aimeos\MW\Config\Iface $conf )
{
$dbconfig = $conf->get( 'resource', array() );
foreach( $dbconfig as $rname => $dbconf )
{
if( strncmp( $rname, 'db', 2 ) !== 0 ) {
unset( $dbconfig[$rname] );
}
}
return $dbconfig;
}
|
[
"protected",
"function",
"getDbConfig",
"(",
"\\",
"Aimeos",
"\\",
"MW",
"\\",
"Config",
"\\",
"Iface",
"$",
"conf",
")",
"{",
"$",
"dbconfig",
"=",
"$",
"conf",
"->",
"get",
"(",
"'resource'",
",",
"array",
"(",
")",
")",
";",
"foreach",
"(",
"$",
"dbconfig",
"as",
"$",
"rname",
"=>",
"$",
"dbconf",
")",
"{",
"if",
"(",
"strncmp",
"(",
"$",
"rname",
",",
"'db'",
",",
"2",
")",
"!==",
"0",
")",
"{",
"unset",
"(",
"$",
"dbconfig",
"[",
"$",
"rname",
"]",
")",
";",
"}",
"}",
"return",
"$",
"dbconfig",
";",
"}"
] |
Returns the database configuration from the config object.
@param \Aimeos\MW\Config\Iface $conf Config object
@return array Multi-dimensional associative list of database configuration parameters
|
[
"Returns",
"the",
"database",
"configuration",
"from",
"the",
"config",
"object",
"."
] |
d407e5ca95433fa3e900df8dbc9ab1ea74df1afe
|
https://github.com/aimeos/aimeos-laravel/blob/d407e5ca95433fa3e900df8dbc9ab1ea74df1afe/src/Aimeos/Shop/Command/SetupCommand.php#L98-L110
|
220,999
|
aimeos/aimeos-laravel
|
src/Aimeos/Shop/Base/Context.php
|
Context.addGroups
|
protected function addGroups( \Aimeos\MShop\Context\Item\Iface $context )
{
if( ( $userid = Auth::id() ) !== null )
{
$context->setGroupIds( function() use ( $context, $userid )
{
$manager = \Aimeos\MShop::create( $context, 'customer' );
return $manager->getItem( $userid, array( 'customer/group' ) )->getGroups();
} );
}
return $context;
}
|
php
|
protected function addGroups( \Aimeos\MShop\Context\Item\Iface $context )
{
if( ( $userid = Auth::id() ) !== null )
{
$context->setGroupIds( function() use ( $context, $userid )
{
$manager = \Aimeos\MShop::create( $context, 'customer' );
return $manager->getItem( $userid, array( 'customer/group' ) )->getGroups();
} );
}
return $context;
}
|
[
"protected",
"function",
"addGroups",
"(",
"\\",
"Aimeos",
"\\",
"MShop",
"\\",
"Context",
"\\",
"Item",
"\\",
"Iface",
"$",
"context",
")",
"{",
"if",
"(",
"(",
"$",
"userid",
"=",
"Auth",
"::",
"id",
"(",
")",
")",
"!==",
"null",
")",
"{",
"$",
"context",
"->",
"setGroupIds",
"(",
"function",
"(",
")",
"use",
"(",
"$",
"context",
",",
"$",
"userid",
")",
"{",
"$",
"manager",
"=",
"\\",
"Aimeos",
"\\",
"MShop",
"::",
"create",
"(",
"$",
"context",
",",
"'customer'",
")",
";",
"return",
"$",
"manager",
"->",
"getItem",
"(",
"$",
"userid",
",",
"array",
"(",
"'customer/group'",
")",
")",
"->",
"getGroups",
"(",
")",
";",
"}",
")",
";",
"}",
"return",
"$",
"context",
";",
"}"
] |
Adds the group IDs if available
@param \Aimeos\MShop\Context\Item\Iface $context Context object
@return \Aimeos\MShop\Context\Item\Iface Modified context object
|
[
"Adds",
"the",
"group",
"IDs",
"if",
"available"
] |
d407e5ca95433fa3e900df8dbc9ab1ea74df1afe
|
https://github.com/aimeos/aimeos-laravel/blob/d407e5ca95433fa3e900df8dbc9ab1ea74df1afe/src/Aimeos/Shop/Base/Context.php#L259-L271
|
Subsets and Splits
Yii Code Samples
Gathers all records from test, train, and validation sets that contain the word 'yii', providing a basic filtered view of the dataset relevant to Yii-related content.