repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6 values | func_code_string stringlengths 52 3.87M | func_code_tokens listlengths 15 672k | func_documentation_string stringlengths 1 47.2k | func_documentation_tokens listlengths 1 3.92k | split_name stringclasses 1 value | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|---|---|---|
eveseat/web | src/Http/Controllers/Corporation/SummaryController.php | SummaryController.getSummary | public function getSummary(int $corporation_id)
{
$sheet = $this->getCorporationSheet($corporation_id);
// Check if we managed to get any records for
// this character. If not, redirect back with
// an error.
if (empty($sheet))
return redirect()->back()
->with('error', trans('web::seat.unknown_corporation'));
$divisions = $this->getCorporationDivisions($corporation_id);
$wallet_divisions = $this->getCorporationWalletDivisions($corporation_id);
return view('web::corporation.summary',
compact('divisions', 'sheet', 'wallet_divisions'));
} | php | public function getSummary(int $corporation_id)
{
$sheet = $this->getCorporationSheet($corporation_id);
// Check if we managed to get any records for
// this character. If not, redirect back with
// an error.
if (empty($sheet))
return redirect()->back()
->with('error', trans('web::seat.unknown_corporation'));
$divisions = $this->getCorporationDivisions($corporation_id);
$wallet_divisions = $this->getCorporationWalletDivisions($corporation_id);
return view('web::corporation.summary',
compact('divisions', 'sheet', 'wallet_divisions'));
} | [
"public",
"function",
"getSummary",
"(",
"int",
"$",
"corporation_id",
")",
"{",
"$",
"sheet",
"=",
"$",
"this",
"->",
"getCorporationSheet",
"(",
"$",
"corporation_id",
")",
";",
"// Check if we managed to get any records for",
"// this character. If not, redirect back w... | @param $corporation_id
@return \Illuminate\Contracts\View\Factory|\Illuminate\View\View | [
"@param",
"$corporation_id"
] | train | https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Http/Controllers/Corporation/SummaryController.php#L41-L59 |
eveseat/web | src/Http/Validation/RoleAffilliation.php | RoleAffilliation.rules | public function rules()
{
// Instead of using the 'exists' validation rule, we opt to use
// the 'in' rule. We do this because we want to add '0' as a valid
// value, which will signal a wild card for either all characters
// or all corporations.
$character_ids = implode(',',
array_prepend(CharacterInfo::pluck('character_id')->toArray(), 0));
$corporation_ids = implode(',',
array_prepend(CorporationInfo::pluck('corporation_id')->toArray(), 0));
$rules = [
'role_id' => 'required|exists:roles,id',
'inverse' => 'nullable|in:on',
'characters' => 'required_without_all:corporations',
'corporations' => 'required_without_all:characters',
'characters.*' => 'in:' . $character_ids,
'corporations.*' => 'in:' . $corporation_ids,
];
return $rules;
} | php | public function rules()
{
// Instead of using the 'exists' validation rule, we opt to use
// the 'in' rule. We do this because we want to add '0' as a valid
// value, which will signal a wild card for either all characters
// or all corporations.
$character_ids = implode(',',
array_prepend(CharacterInfo::pluck('character_id')->toArray(), 0));
$corporation_ids = implode(',',
array_prepend(CorporationInfo::pluck('corporation_id')->toArray(), 0));
$rules = [
'role_id' => 'required|exists:roles,id',
'inverse' => 'nullable|in:on',
'characters' => 'required_without_all:corporations',
'corporations' => 'required_without_all:characters',
'characters.*' => 'in:' . $character_ids,
'corporations.*' => 'in:' . $corporation_ids,
];
return $rules;
} | [
"public",
"function",
"rules",
"(",
")",
"{",
"// Instead of using the 'exists' validation rule, we opt to use",
"// the 'in' rule. We do this because we want to add '0' as a valid",
"// value, which will signal a wild card for either all characters",
"// or all corporations.",
"$",
"character... | Get the validation rules that apply to the request.
@return array | [
"Get",
"the",
"validation",
"rules",
"that",
"apply",
"to",
"the",
"request",
"."
] | train | https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Http/Validation/RoleAffilliation.php#L51-L73 |
eveseat/web | src/Notifications/EmailVerification.php | EmailVerification.toMail | public function toMail($notifiable): MailMessage
{
return (new MailMessage)
->success()
->subject('SeAT Account Activation')
->line(
'This email address has been used to register a SeAT account ' .
'at ' . route('home') . '. Before enabling your account, we would ' .
'like to make sure that you really own this address.'
)
->line(
'If you did not register this request, then you can safely ignore ' .
'this email.'
)
->action(
'Activate Your Account', route('auth.email.confirm', [
'token' => $notifiable->activation_token,
]));
} | php | public function toMail($notifiable): MailMessage
{
return (new MailMessage)
->success()
->subject('SeAT Account Activation')
->line(
'This email address has been used to register a SeAT account ' .
'at ' . route('home') . '. Before enabling your account, we would ' .
'like to make sure that you really own this address.'
)
->line(
'If you did not register this request, then you can safely ignore ' .
'this email.'
)
->action(
'Activate Your Account', route('auth.email.confirm', [
'token' => $notifiable->activation_token,
]));
} | [
"public",
"function",
"toMail",
"(",
"$",
"notifiable",
")",
":",
"MailMessage",
"{",
"return",
"(",
"new",
"MailMessage",
")",
"->",
"success",
"(",
")",
"->",
"subject",
"(",
"'SeAT Account Activation'",
")",
"->",
"line",
"(",
"'This email address has been us... | Get the mail representation of the notification.
@param mixed $notifiable
@return \Illuminate\Notifications\Messages\MailMessage | [
"Get",
"the",
"mail",
"representation",
"of",
"the",
"notification",
"."
] | train | https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Notifications/EmailVerification.php#L65-L84 |
eveseat/web | src/Http/Composers/CorporationSummary.php | CorporationSummary.compose | public function compose(View $view)
{
$sheet = $this->getCorporationSheet(
$this->request->corporation_id);
$view->with('sheet', $sheet);
} | php | public function compose(View $view)
{
$sheet = $this->getCorporationSheet(
$this->request->corporation_id);
$view->with('sheet', $sheet);
} | [
"public",
"function",
"compose",
"(",
"View",
"$",
"view",
")",
"{",
"$",
"sheet",
"=",
"$",
"this",
"->",
"getCorporationSheet",
"(",
"$",
"this",
"->",
"request",
"->",
"corporation_id",
")",
";",
"$",
"view",
"->",
"with",
"(",
"'sheet'",
",",
"$",
... | Bind data to the view.
@param View $view
@return void | [
"Bind",
"data",
"to",
"the",
"view",
"."
] | train | https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Http/Composers/CorporationSummary.php#L56-L64 |
eveseat/web | src/database/migrations/2014_10_12_000000_create_users_table.php | CreateUsersTable.up | public function up()
{
Schema::create('users', function (Blueprint $table) {
$table->bigInteger('id')->primary();
$table->integer('group_id');
$table->string('name')->unique();
$table->string('email')->unique()->nullable();
$table->boolean('active')->default(true);
$table->string('character_owner_hash');
$table->dateTime('last_login')->nullable();
$table->string('last_login_source')->nullable();
$table->rememberToken();
$table->index('group_id');
$table->timestamps();
});
} | php | public function up()
{
Schema::create('users', function (Blueprint $table) {
$table->bigInteger('id')->primary();
$table->integer('group_id');
$table->string('name')->unique();
$table->string('email')->unique()->nullable();
$table->boolean('active')->default(true);
$table->string('character_owner_hash');
$table->dateTime('last_login')->nullable();
$table->string('last_login_source')->nullable();
$table->rememberToken();
$table->index('group_id');
$table->timestamps();
});
} | [
"public",
"function",
"up",
"(",
")",
"{",
"Schema",
"::",
"create",
"(",
"'users'",
",",
"function",
"(",
"Blueprint",
"$",
"table",
")",
"{",
"$",
"table",
"->",
"bigInteger",
"(",
"'id'",
")",
"->",
"primary",
"(",
")",
";",
"$",
"table",
"->",
... | Run the migrations.
@return void | [
"Run",
"the",
"migrations",
"."
] | train | https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/database/migrations/2014_10_12_000000_create_users_table.php#L33-L52 |
eveseat/web | src/Http/Controllers/Character/ContactsController.php | ContactsController.getContacts | public function getContacts(int $character_id)
{
if(! request()->ajax())
return view('web::character.contacts');
if(! request()->has('all_linked_characters'))
return response('required url parameter is missing!', 400);
if(request('all_linked_characters') === 'false')
$character_ids = collect($character_id);
$user_group = User::find($character_id)->group->users
->filter(function ($user) {
if(! $user->name === 'admin' || $user->id === 1)
return false;
return true;
})
->pluck('id');
if(request('all_linked_characters') === 'true')
$character_ids = $user_group;
$standings = array_map('intval', explode(',', request('selected_standings')));
$contacts = $this->getCharacterContacts($character_ids, $standings);
return DataTables::of($contacts)
->editColumn('name', function ($row) {
$character_id = $row->character_id;
if($row->contact_type === 'character'){
$character = CharacterInfo::find($row->contact_id) ?: $row->contact_id;
return view('web::partials.character', compact('character', 'character_id'));
}
if($row->contact_type === 'corporation'){
$corporation = CorporationInfo::find($row->contact_id) ?: $row->contact_id;
return view('web::partials.corporation', compact('corporation', 'character_id'));
}
return view('web::partials.unknown', [
'unknown_id' => $row->contact_id,
'character_id' => $character_id,
]);
})
->editColumn('label_ids', function ($row) {
if(isset($row->label_ids)) {
$labels = $this->getCharacterContactLabels($row->character_id);
return $labels->whereIn('label_id', $row->label_ids)->implode('label_name', ', ');
}
return '';
})
->addColumn('standing_view', function ($row) {
if($row->standing > 0)
return "<b class='text-success'>" . $row->standing . '</b>';
if($row->standing < 0)
return "<b class='text-danger'>" . $row->standing . '</b>';
return '<b>' . $row->standing . '</b>';
})
->addColumn('links', function ($row) {
return view('web::partials.links', ['id' => $row->contact_id, 'type' => $row->contact_type]);
})
->addColumn('is_in_group', function ($row) use ($user_group) {
return $user_group->intersect(collect($row->contact_id))->isNotEmpty();
})
->filterColumn('name', function ($query, $keyword) {
$resolved_ids = UniverseName::where('name', 'like', '%' . $keyword . '%')->get()->map(function ($resolved_id) { return $resolved_id->entity_id; });
$character_info_ids = CharacterInfo::where('name', 'like', '%' . $keyword . '%')->get()->map(function ($character_info) { return $character_info->character_id; });
$corporation_info_ids = CorporationInfo::where('name', 'like', '%' . $keyword . '%')->get()->map(function ($corporation_info) { return $corporation_info->corproation_id; });
$query->whereIn('contact_id', array_merge($resolved_ids->toArray(), $character_info_ids->toArray(), $corporation_info_ids->toArray()));
})
->filterColumn('label_ids', function ($query, $keyword) use ($character_ids) {
$labels = CharacterContactLabel::where('label_name', 'like', '%' . $keyword . '%')
->whereIn('character_id', $character_ids)
->get();
foreach ($labels as $label)
$query->whereRaw(DB::raw('JSON_CONTAINS(label_ids, ' . $label->label_id . ')'));
})
->rawColumns(['name', 'standing_view', 'links'])
->make(true);
} | php | public function getContacts(int $character_id)
{
if(! request()->ajax())
return view('web::character.contacts');
if(! request()->has('all_linked_characters'))
return response('required url parameter is missing!', 400);
if(request('all_linked_characters') === 'false')
$character_ids = collect($character_id);
$user_group = User::find($character_id)->group->users
->filter(function ($user) {
if(! $user->name === 'admin' || $user->id === 1)
return false;
return true;
})
->pluck('id');
if(request('all_linked_characters') === 'true')
$character_ids = $user_group;
$standings = array_map('intval', explode(',', request('selected_standings')));
$contacts = $this->getCharacterContacts($character_ids, $standings);
return DataTables::of($contacts)
->editColumn('name', function ($row) {
$character_id = $row->character_id;
if($row->contact_type === 'character'){
$character = CharacterInfo::find($row->contact_id) ?: $row->contact_id;
return view('web::partials.character', compact('character', 'character_id'));
}
if($row->contact_type === 'corporation'){
$corporation = CorporationInfo::find($row->contact_id) ?: $row->contact_id;
return view('web::partials.corporation', compact('corporation', 'character_id'));
}
return view('web::partials.unknown', [
'unknown_id' => $row->contact_id,
'character_id' => $character_id,
]);
})
->editColumn('label_ids', function ($row) {
if(isset($row->label_ids)) {
$labels = $this->getCharacterContactLabels($row->character_id);
return $labels->whereIn('label_id', $row->label_ids)->implode('label_name', ', ');
}
return '';
})
->addColumn('standing_view', function ($row) {
if($row->standing > 0)
return "<b class='text-success'>" . $row->standing . '</b>';
if($row->standing < 0)
return "<b class='text-danger'>" . $row->standing . '</b>';
return '<b>' . $row->standing . '</b>';
})
->addColumn('links', function ($row) {
return view('web::partials.links', ['id' => $row->contact_id, 'type' => $row->contact_type]);
})
->addColumn('is_in_group', function ($row) use ($user_group) {
return $user_group->intersect(collect($row->contact_id))->isNotEmpty();
})
->filterColumn('name', function ($query, $keyword) {
$resolved_ids = UniverseName::where('name', 'like', '%' . $keyword . '%')->get()->map(function ($resolved_id) { return $resolved_id->entity_id; });
$character_info_ids = CharacterInfo::where('name', 'like', '%' . $keyword . '%')->get()->map(function ($character_info) { return $character_info->character_id; });
$corporation_info_ids = CorporationInfo::where('name', 'like', '%' . $keyword . '%')->get()->map(function ($corporation_info) { return $corporation_info->corproation_id; });
$query->whereIn('contact_id', array_merge($resolved_ids->toArray(), $character_info_ids->toArray(), $corporation_info_ids->toArray()));
})
->filterColumn('label_ids', function ($query, $keyword) use ($character_ids) {
$labels = CharacterContactLabel::where('label_name', 'like', '%' . $keyword . '%')
->whereIn('character_id', $character_ids)
->get();
foreach ($labels as $label)
$query->whereRaw(DB::raw('JSON_CONTAINS(label_ids, ' . $label->label_id . ')'));
})
->rawColumns(['name', 'standing_view', 'links'])
->make(true);
} | [
"public",
"function",
"getContacts",
"(",
"int",
"$",
"character_id",
")",
"{",
"if",
"(",
"!",
"request",
"(",
")",
"->",
"ajax",
"(",
")",
")",
"return",
"view",
"(",
"'web::character.contacts'",
")",
";",
"if",
"(",
"!",
"request",
"(",
")",
"->",
... | @param int $character_id
@return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
@throws \Exception | [
"@param",
"int",
"$character_id"
] | train | https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Http/Controllers/Character/ContactsController.php#L45-L143 |
eveseat/web | src/Http/Controllers/Tools/JobController.php | JobController.getDispatchUpdateJob | public function getDispatchUpdateJob(int $character_id, string $job_name)
{
$job_classes = collect(config('web.jobnames.' . $job_name));
// If we could not find the jon to dispatch, log this as a
// security event as someone might be trying something funny.
if ($job_classes->isEmpty()) {
$message = 'Failed to find the jobclass for job_name ' . $job_name .
' Someone might be trying something strange.';
event('security.log', [$message, 'jobdispatching']);
return redirect()->back()->with('warning', trans('web::seat.update_failed'));
}
// Find the refresh token for the jobs.
$refresh_token = RefreshToken::findOrFail($character_id);
// Dispatch jobs for each jobclass
$job_classes->each(function ($job) use ($refresh_token, $character_id) {
(new $job($refresh_token))->dispatch($refresh_token)->onQueue('high');
logger()->info('Manually dispatched job \'' . $job . '\' for character ' .
$character_id);
});
// Redirect back!
return redirect()->back()->with('success', trans('web::seat.update_dispatched'));
} | php | public function getDispatchUpdateJob(int $character_id, string $job_name)
{
$job_classes = collect(config('web.jobnames.' . $job_name));
// If we could not find the jon to dispatch, log this as a
// security event as someone might be trying something funny.
if ($job_classes->isEmpty()) {
$message = 'Failed to find the jobclass for job_name ' . $job_name .
' Someone might be trying something strange.';
event('security.log', [$message, 'jobdispatching']);
return redirect()->back()->with('warning', trans('web::seat.update_failed'));
}
// Find the refresh token for the jobs.
$refresh_token = RefreshToken::findOrFail($character_id);
// Dispatch jobs for each jobclass
$job_classes->each(function ($job) use ($refresh_token, $character_id) {
(new $job($refresh_token))->dispatch($refresh_token)->onQueue('high');
logger()->info('Manually dispatched job \'' . $job . '\' for character ' .
$character_id);
});
// Redirect back!
return redirect()->back()->with('success', trans('web::seat.update_dispatched'));
} | [
"public",
"function",
"getDispatchUpdateJob",
"(",
"int",
"$",
"character_id",
",",
"string",
"$",
"job_name",
")",
"{",
"$",
"job_classes",
"=",
"collect",
"(",
"config",
"(",
"'web.jobnames.'",
".",
"$",
"job_name",
")",
")",
";",
"// If we could not find the ... | @param int $character_id
@param string $job_name
@return \Illuminate\Http\RedirectResponse | [
"@param",
"int",
"$character_id",
"@param",
"string",
"$job_name"
] | train | https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Http/Controllers/Tools/JobController.php#L40-L71 |
eveseat/web | src/Events/Logout.php | Logout.handle | public static function handle(LogoutEvent $event)
{
// If there is no user, do nothing.
if (! $event->user)
return;
$event->user->login_history()->save(new UserLoginHistory([
'source' => Request::getClientIp(),
'user_agent' => Request::header('User-Agent'),
'action' => 'logout',
]));
$message = 'User logged out from ' . Request::getClientIp();
event('security.log', [$message, 'authentication']);
} | php | public static function handle(LogoutEvent $event)
{
// If there is no user, do nothing.
if (! $event->user)
return;
$event->user->login_history()->save(new UserLoginHistory([
'source' => Request::getClientIp(),
'user_agent' => Request::header('User-Agent'),
'action' => 'logout',
]));
$message = 'User logged out from ' . Request::getClientIp();
event('security.log', [$message, 'authentication']);
} | [
"public",
"static",
"function",
"handle",
"(",
"LogoutEvent",
"$",
"event",
")",
"{",
"// If there is no user, do nothing.",
"if",
"(",
"!",
"$",
"event",
"->",
"user",
")",
"return",
";",
"$",
"event",
"->",
"user",
"->",
"login_history",
"(",
")",
"->",
... | Write a logout history item for this user.
@param \Illuminate\Auth\Events\Logout $event | [
"Write",
"a",
"logout",
"history",
"item",
"for",
"this",
"user",
"."
] | train | https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Events/Logout.php#L40-L55 |
eveseat/web | src/Http/Controllers/Auth/AdminLoginController.php | AdminLoginController.checkLoginToken | public function checkLoginToken(string $token)
{
if ($token != cache('admin_login_token'))
abort(404);
$user = User::whereName('admin')->first();
if (is_null($user))
return redirect()->route('auth.login')
->withErrors('The Admin user does not exist. Re-run the seat:admin:login command.');
// Login and clear the token we just used.
auth()->login($user);
cache()->delete('admin_login_token');
return redirect()->intended('home');
} | php | public function checkLoginToken(string $token)
{
if ($token != cache('admin_login_token'))
abort(404);
$user = User::whereName('admin')->first();
if (is_null($user))
return redirect()->route('auth.login')
->withErrors('The Admin user does not exist. Re-run the seat:admin:login command.');
// Login and clear the token we just used.
auth()->login($user);
cache()->delete('admin_login_token');
return redirect()->intended('home');
} | [
"public",
"function",
"checkLoginToken",
"(",
"string",
"$",
"token",
")",
"{",
"if",
"(",
"$",
"token",
"!=",
"cache",
"(",
"'admin_login_token'",
")",
")",
"abort",
"(",
"404",
")",
";",
"$",
"user",
"=",
"User",
"::",
"whereName",
"(",
"'admin'",
")... | Login using the cached admin user token.
@param string $token
@return \Illuminate\Http\RedirectResponse
@throws \Exception
@throws \Psr\SimpleCache\InvalidArgumentException | [
"Login",
"using",
"the",
"cached",
"admin",
"user",
"token",
"."
] | train | https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Http/Controllers/Auth/AdminLoginController.php#L43-L61 |
eveseat/web | src/Models/User.php | User.delete | public function delete()
{
// Cleanup the user
$this->login_history()->delete();
$this->affiliations()->detach();
$this->refresh_token()->forceDelete();
$this->settings()->delete();
return parent::delete();
} | php | public function delete()
{
// Cleanup the user
$this->login_history()->delete();
$this->affiliations()->detach();
$this->refresh_token()->forceDelete();
$this->settings()->delete();
return parent::delete();
} | [
"public",
"function",
"delete",
"(",
")",
"{",
"// Cleanup the user",
"$",
"this",
"->",
"login_history",
"(",
")",
"->",
"delete",
"(",
")",
";",
"$",
"this",
"->",
"affiliations",
"(",
")",
"->",
"detach",
"(",
")",
";",
"$",
"this",
"->",
"refresh_t... | Make sure we cleanup on delete.
@return bool|null
@throws \Exception | [
"Make",
"sure",
"we",
"cleanup",
"on",
"delete",
"."
] | train | https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Models/User.php#L160-L171 |
eveseat/web | src/database/migrations/2016_11_02_164414_add_permission_inversion_flags.php | AddPermissionInversionFlags.up | public function up()
{
Schema::table('group_role', function (Blueprint $table) {
$table->boolean('not')->after('group_id')->default(false);
});
Schema::table('permission_role', function (Blueprint $table) {
$table->boolean('not')->after('role_id')->default(false);
});
Schema::table('affiliation_user', function (Blueprint $table) {
$table->boolean('not')->after('affiliation_id')->default(false);
});
Schema::table('affiliation_role', function (Blueprint $table) {
$table->boolean('not')->after('affiliation_id')->default(false);
});
} | php | public function up()
{
Schema::table('group_role', function (Blueprint $table) {
$table->boolean('not')->after('group_id')->default(false);
});
Schema::table('permission_role', function (Blueprint $table) {
$table->boolean('not')->after('role_id')->default(false);
});
Schema::table('affiliation_user', function (Blueprint $table) {
$table->boolean('not')->after('affiliation_id')->default(false);
});
Schema::table('affiliation_role', function (Blueprint $table) {
$table->boolean('not')->after('affiliation_id')->default(false);
});
} | [
"public",
"function",
"up",
"(",
")",
"{",
"Schema",
"::",
"table",
"(",
"'group_role'",
",",
"function",
"(",
"Blueprint",
"$",
"table",
")",
"{",
"$",
"table",
"->",
"boolean",
"(",
"'not'",
")",
"->",
"after",
"(",
"'group_id'",
")",
"->",
"default"... | Run the migrations.
@return void | [
"Run",
"the",
"migrations",
"."
] | train | https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/database/migrations/2016_11_02_164414_add_permission_inversion_flags.php#L34-L56 |
eveseat/web | src/database/migrations/2016_11_02_164414_add_permission_inversion_flags.php | AddPermissionInversionFlags.down | public function down()
{
Schema::table('group_role', function (Blueprint $table) {
$table->dropColumn('not');
});
Schema::table('permission_role', function (Blueprint $table) {
$table->dropColumn('not');
});
Schema::table('affiliation_user', function (Blueprint $table) {
$table->dropColumn('not');
});
Schema::table('affiliation_role', function (Blueprint $table) {
$table->dropColumn('not');
});
} | php | public function down()
{
Schema::table('group_role', function (Blueprint $table) {
$table->dropColumn('not');
});
Schema::table('permission_role', function (Blueprint $table) {
$table->dropColumn('not');
});
Schema::table('affiliation_user', function (Blueprint $table) {
$table->dropColumn('not');
});
Schema::table('affiliation_role', function (Blueprint $table) {
$table->dropColumn('not');
});
} | [
"public",
"function",
"down",
"(",
")",
"{",
"Schema",
"::",
"table",
"(",
"'group_role'",
",",
"function",
"(",
"Blueprint",
"$",
"table",
")",
"{",
"$",
"table",
"->",
"dropColumn",
"(",
"'not'",
")",
";",
"}",
")",
";",
"Schema",
"::",
"table",
"(... | Reverse the migrations.
@return void | [
"Reverse",
"the",
"migrations",
"."
] | train | https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/database/migrations/2016_11_02_164414_add_permission_inversion_flags.php#L63-L85 |
eveseat/web | src/Http/Controllers/Corporation/ContactsController.php | ContactsController.getContacts | public function getContacts(int $corporation_id)
{
$contacts = $this->getCorporationContacts($corporation_id);
$labels = $this->getCorporationContactLabels($corporation_id);
return view('web::corporation.contacts', compact('contacts', 'labels'));
} | php | public function getContacts(int $corporation_id)
{
$contacts = $this->getCorporationContacts($corporation_id);
$labels = $this->getCorporationContactLabels($corporation_id);
return view('web::corporation.contacts', compact('contacts', 'labels'));
} | [
"public",
"function",
"getContacts",
"(",
"int",
"$",
"corporation_id",
")",
"{",
"$",
"contacts",
"=",
"$",
"this",
"->",
"getCorporationContacts",
"(",
"$",
"corporation_id",
")",
";",
"$",
"labels",
"=",
"$",
"this",
"->",
"getCorporationContactLabels",
"("... | @param $corporation_id
@return \Illuminate\Contracts\View\Factory|\Illuminate\View\View | [
"@param",
"$corporation_id"
] | train | https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Http/Controllers/Corporation/ContactsController.php#L37-L44 |
eveseat/web | src/Http/Controllers/Support/ResolveController.php | ResolveController.resolveIdsToNames | public function resolveIdsToNames(Request $request)
{
// Resolve the Esi client library from the IoC
$eseye = app('esi-client')->get();
// Grab the ids from the request for processing
collect(explode(',', $request->ids))
->map(function ($id) {
// Convert them all to integers
return (int) $id;
})
->unique()
->filter(function ($id) {
// Filter out ids that are System items
// see: https://gist.github.com/a-tal/5ff5199fdbeb745b77cb633b7f4400bb
if ($id <= 10000)
return false;
// Next, filter the ids we have in the cache, setting
// the appropriate response values as we go along.
if ($cached_entry = cache($this->prefix . $id)) {
$this->response[$id] = $cached_entry;
// Remove this as a valid id, we already have the value we want.
return false;
}
// We don't have this id in the cache. Return it
// so that we can update it later.
return true;
})
->pipe(function ($collection) {
return $collection->when($collection->isNotEmpty(), function ($ids) {
return $this->resolveFactionIDs($ids);
});
})
->pipe(function ($collection) {
return $collection->when($collection->isNotEmpty(), function ($ids) {
return $this->resolveInternalUniverseIDs($ids);
});
})
->pipe(function ($collection) {
return $collection->when($collection->isNotEmpty(), function ($ids) {
return $this->resolveInternalCharacterIDs($ids);
});
})
->pipe(function ($collection) {
return $collection->when($collection->isNotEmpty(), function ($ids) {
return $this->resolveInternalCorporationIDs($ids);
});
})
->chunk(1000)
->each(function ($chunk) use ($eseye) {
// quick break if no more IDs must be resolve by ESI
if ($chunk->isEmpty())
return;
$this->resolveIDsfromESI($chunk, $eseye);
});
return response()->json($this->response);
} | php | public function resolveIdsToNames(Request $request)
{
// Resolve the Esi client library from the IoC
$eseye = app('esi-client')->get();
// Grab the ids from the request for processing
collect(explode(',', $request->ids))
->map(function ($id) {
// Convert them all to integers
return (int) $id;
})
->unique()
->filter(function ($id) {
// Filter out ids that are System items
// see: https://gist.github.com/a-tal/5ff5199fdbeb745b77cb633b7f4400bb
if ($id <= 10000)
return false;
// Next, filter the ids we have in the cache, setting
// the appropriate response values as we go along.
if ($cached_entry = cache($this->prefix . $id)) {
$this->response[$id] = $cached_entry;
// Remove this as a valid id, we already have the value we want.
return false;
}
// We don't have this id in the cache. Return it
// so that we can update it later.
return true;
})
->pipe(function ($collection) {
return $collection->when($collection->isNotEmpty(), function ($ids) {
return $this->resolveFactionIDs($ids);
});
})
->pipe(function ($collection) {
return $collection->when($collection->isNotEmpty(), function ($ids) {
return $this->resolveInternalUniverseIDs($ids);
});
})
->pipe(function ($collection) {
return $collection->when($collection->isNotEmpty(), function ($ids) {
return $this->resolveInternalCharacterIDs($ids);
});
})
->pipe(function ($collection) {
return $collection->when($collection->isNotEmpty(), function ($ids) {
return $this->resolveInternalCorporationIDs($ids);
});
})
->chunk(1000)
->each(function ($chunk) use ($eseye) {
// quick break if no more IDs must be resolve by ESI
if ($chunk->isEmpty())
return;
$this->resolveIDsfromESI($chunk, $eseye);
});
return response()->json($this->response);
} | [
"public",
"function",
"resolveIdsToNames",
"(",
"Request",
"$",
"request",
")",
"{",
"// Resolve the Esi client library from the IoC",
"$",
"eseye",
"=",
"app",
"(",
"'esi-client'",
")",
"->",
"get",
"(",
")",
";",
"// Grab the ids from the request for processing",
"col... | @param \Illuminate\Http\Request $request
@return \Illuminate\Http\JsonResponse
@throws \Exception | [
"@param",
"\\",
"Illuminate",
"\\",
"Http",
"\\",
"Request",
"$request"
] | train | https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Http/Controllers/Support/ResolveController.php#L67-L134 |
eveseat/web | src/Http/Controllers/Support/ResolveController.php | ResolveController.resolveFactionIDs | private function resolveFactionIDs(Collection $ids)
{
// universe resolver is not working on factions at this time
// retrieve them from SDE and remove them from collection
$names = UniverseName::whereIn('entity_id', $ids->flatten()->toArray())
->get()
->map(function ($entity) {
return collect([
'id' => $entity->entity_id,
'name' => $entity->name,
'category' => $entity->category,
]);
});
return $this->cacheIDsAndReturnUnresolvedIDs($names, $ids);
} | php | private function resolveFactionIDs(Collection $ids)
{
// universe resolver is not working on factions at this time
// retrieve them from SDE and remove them from collection
$names = UniverseName::whereIn('entity_id', $ids->flatten()->toArray())
->get()
->map(function ($entity) {
return collect([
'id' => $entity->entity_id,
'name' => $entity->name,
'category' => $entity->category,
]);
});
return $this->cacheIDsAndReturnUnresolvedIDs($names, $ids);
} | [
"private",
"function",
"resolveFactionIDs",
"(",
"Collection",
"$",
"ids",
")",
"{",
"// universe resolver is not working on factions at this time",
"// retrieve them from SDE and remove them from collection",
"$",
"names",
"=",
"UniverseName",
"::",
"whereIn",
"(",
"'entity_id'"... | Resolve received sets of ids with the help of chrFactions table
map the resolved names, cache the results and return unresolved ids.
@param \Illuminate\Support\Collection $ids
@return \Illuminate\Support\Collection collection of ids that were unable to be resolved within this function | [
"Resolve",
"received",
"sets",
"of",
"ids",
"with",
"the",
"help",
"of",
"chrFactions",
"table",
"map",
"the",
"resolved",
"names",
"cache",
"the",
"results",
"and",
"return",
"unresolved",
"ids",
"."
] | train | https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Http/Controllers/Support/ResolveController.php#L143-L159 |
eveseat/web | src/Http/Controllers/Support/ResolveController.php | ResolveController.resolveInternalCharacterIDs | private function resolveInternalCharacterIDs(Collection $ids)
{
// resolve names that are already in SeAT
// no unnecessary api calls the request can be resolved internally.
$names = CharacterInfo::whereIn('character_id', $ids->flatten()->toArray())
->get()
->map(function ($character) {
return collect([
'id' => $character->character_id,
'name' => $character->name,
'category' => 'character',
]);
});
return $this->cacheIDsAndReturnUnresolvedIDs($names, $ids);
} | php | private function resolveInternalCharacterIDs(Collection $ids)
{
// resolve names that are already in SeAT
// no unnecessary api calls the request can be resolved internally.
$names = CharacterInfo::whereIn('character_id', $ids->flatten()->toArray())
->get()
->map(function ($character) {
return collect([
'id' => $character->character_id,
'name' => $character->name,
'category' => 'character',
]);
});
return $this->cacheIDsAndReturnUnresolvedIDs($names, $ids);
} | [
"private",
"function",
"resolveInternalCharacterIDs",
"(",
"Collection",
"$",
"ids",
")",
"{",
"// resolve names that are already in SeAT",
"// no unnecessary api calls the request can be resolved internally.",
"$",
"names",
"=",
"CharacterInfo",
"::",
"whereIn",
"(",
"'character... | Resolve received sets of ids with the help of character_infos table
map the resolved names, cache the results and return unresolved ids.
@param \Illuminate\Support\Collection $ids
@return \Illuminate\Support\Collection collection of ids that were unable to be resolved within this function | [
"Resolve",
"received",
"sets",
"of",
"ids",
"with",
"the",
"help",
"of",
"character_infos",
"table",
"map",
"the",
"resolved",
"names",
"cache",
"the",
"results",
"and",
"return",
"unresolved",
"ids",
"."
] | train | https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Http/Controllers/Support/ResolveController.php#L192-L208 |
eveseat/web | src/Http/Controllers/Support/ResolveController.php | ResolveController.resolveInternalCorporationIDs | private function resolveInternalCorporationIDs(Collection $ids)
{
// resolve names that are already in SeAT
// no unnecessary api calls the request can be resolved internally.
$names = CorporationInfo::whereIn('corporation_id', $ids->flatten()->toArray())
->get()
->map(function ($corporation) {
return collect([
'id' => $corporation->corporation_id,
'name' => $corporation->name,
'category' => 'corporation',
]);
});
return $this->cacheIDsAndReturnUnresolvedIDs($names, $ids);
} | php | private function resolveInternalCorporationIDs(Collection $ids)
{
// resolve names that are already in SeAT
// no unnecessary api calls the request can be resolved internally.
$names = CorporationInfo::whereIn('corporation_id', $ids->flatten()->toArray())
->get()
->map(function ($corporation) {
return collect([
'id' => $corporation->corporation_id,
'name' => $corporation->name,
'category' => 'corporation',
]);
});
return $this->cacheIDsAndReturnUnresolvedIDs($names, $ids);
} | [
"private",
"function",
"resolveInternalCorporationIDs",
"(",
"Collection",
"$",
"ids",
")",
"{",
"// resolve names that are already in SeAT",
"// no unnecessary api calls the request can be resolved internally.",
"$",
"names",
"=",
"CorporationInfo",
"::",
"whereIn",
"(",
"'corpo... | Resolve received sets of ids with the help of corporation_infos table
map the resolved names, cache the results and return unresolved ids.
@param \Illuminate\Support\Collection $ids
@return \Illuminate\Support\Collection collection of ids that were unable to be resolved within this function | [
"Resolve",
"received",
"sets",
"of",
"ids",
"with",
"the",
"help",
"of",
"corporation_infos",
"table",
"map",
"the",
"resolved",
"names",
"cache",
"the",
"results",
"and",
"return",
"unresolved",
"ids",
"."
] | train | https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Http/Controllers/Support/ResolveController.php#L217-L233 |
eveseat/web | src/Http/Controllers/Support/ResolveController.php | ResolveController.resolveIDsfromESI | private function resolveIDsfromESI(Collection $ids, $eseye)
{
// Finally, grab outstanding ids and resolve their names
// using Esi.
try {
$eseye->setVersion('v3');
$eseye->setBody($ids->flatten()->toArray());
$names = $eseye->invoke('post', '/universe/names/');
collect($names)->each(function ($name) {
// Cache the name resolution for this id for a long time.
cache([$this->prefix . $name->id => $name->name], carbon()->addCentury());
$this->response[$name->id] = $name->name;
UniverseName::firstOrCreate([
'entity_id' => $name->id,
], [
'name' => $name->name,
'category' => $name->category,
]);
});
} catch (\Exception $e) {
// If this fails split the ids in half and try to self referential resolve the half_chunks
// until all possible resolvable ids has processed.
if ($ids->count() === 1) {
// return a singleton unresolvable id as 'unknown'
$this->response[$ids->first()] = trans('web::seat.unknown');
} else {
//split the chunk in two
$half = ceil($ids->count() / 2);
//keep on processing the halfs independently,
//ideally one of the halfs will process just perfect
$ids->chunk($half)->each(function ($half_chunk) use ($eseye) {
//this is a selfrefrencial call.
$this->resolveIDsfromESI($half_chunk, $eseye);
});
}
}
} | php | private function resolveIDsfromESI(Collection $ids, $eseye)
{
// Finally, grab outstanding ids and resolve their names
// using Esi.
try {
$eseye->setVersion('v3');
$eseye->setBody($ids->flatten()->toArray());
$names = $eseye->invoke('post', '/universe/names/');
collect($names)->each(function ($name) {
// Cache the name resolution for this id for a long time.
cache([$this->prefix . $name->id => $name->name], carbon()->addCentury());
$this->response[$name->id] = $name->name;
UniverseName::firstOrCreate([
'entity_id' => $name->id,
], [
'name' => $name->name,
'category' => $name->category,
]);
});
} catch (\Exception $e) {
// If this fails split the ids in half and try to self referential resolve the half_chunks
// until all possible resolvable ids has processed.
if ($ids->count() === 1) {
// return a singleton unresolvable id as 'unknown'
$this->response[$ids->first()] = trans('web::seat.unknown');
} else {
//split the chunk in two
$half = ceil($ids->count() / 2);
//keep on processing the halfs independently,
//ideally one of the halfs will process just perfect
$ids->chunk($half)->each(function ($half_chunk) use ($eseye) {
//this is a selfrefrencial call.
$this->resolveIDsfromESI($half_chunk, $eseye);
});
}
}
} | [
"private",
"function",
"resolveIDsfromESI",
"(",
"Collection",
"$",
"ids",
",",
"$",
"eseye",
")",
"{",
"// Finally, grab outstanding ids and resolve their names",
"// using Esi.",
"try",
"{",
"$",
"eseye",
"->",
"setVersion",
"(",
"'v3'",
")",
";",
"$",
"eseye",
... | Resolve given set of ids with the help of eseye client and ESI
using a boolean algorithm if one of the ids in the collection of ids
is invalid.
If name could be resolved, save the name to universe_names table.
@param \Illuminate\Support\Collection $ids
@param $eseye | [
"Resolve",
"given",
"set",
"of",
"ids",
"with",
"the",
"help",
"of",
"eseye",
"client",
"and",
"ESI",
"using",
"a",
"boolean",
"algorithm",
"if",
"one",
"of",
"the",
"ids",
"in",
"the",
"collection",
"of",
"ids",
"is",
"invalid",
".",
"If",
"name",
"co... | train | https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Http/Controllers/Support/ResolveController.php#L244-L290 |
eveseat/web | src/Http/Controllers/Support/ResolveController.php | ResolveController.cacheIDsAndReturnUnresolvedIDs | private function cacheIDsAndReturnUnresolvedIDs(Collection $names, Collection $ids) : Collection
{
$names->each(function ($name) {
cache([$this->prefix . $name['id'] => $name['name']], carbon()->addCentury());
$this->response[$name['id']] = $name['name'];
UniverseName::firstOrCreate([
'entity_id' => $name['id'],
], [
'name' => $name['name'],
'category' => $name['category'],
]);
});
$ids = $ids->filter(function ($id) use ($names) {
return ! $names->contains('id', $id);
});
return $ids;
} | php | private function cacheIDsAndReturnUnresolvedIDs(Collection $names, Collection $ids) : Collection
{
$names->each(function ($name) {
cache([$this->prefix . $name['id'] => $name['name']], carbon()->addCentury());
$this->response[$name['id']] = $name['name'];
UniverseName::firstOrCreate([
'entity_id' => $name['id'],
], [
'name' => $name['name'],
'category' => $name['category'],
]);
});
$ids = $ids->filter(function ($id) use ($names) {
return ! $names->contains('id', $id);
});
return $ids;
} | [
"private",
"function",
"cacheIDsAndReturnUnresolvedIDs",
"(",
"Collection",
"$",
"names",
",",
"Collection",
"$",
"ids",
")",
":",
"Collection",
"{",
"$",
"names",
"->",
"each",
"(",
"function",
"(",
"$",
"name",
")",
"{",
"cache",
"(",
"[",
"$",
"this",
... | Cache and save resolved IDs. Return unresolved collection of ids.
@param \Illuminate\Support\Collection $names resolved names
@param \Illuminate\Support\Collection $ids
@return \Illuminate\Support\Collection unresolved collection of ids | [
"Cache",
"and",
"save",
"resolved",
"IDs",
".",
"Return",
"unresolved",
"collection",
"of",
"ids",
"."
] | train | https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Http/Controllers/Support/ResolveController.php#L300-L322 |
eveseat/web | src/Http/Validation/SeatSettings.php | SeatSettings.rules | public function rules()
{
$allowed_registration = implode(',', Seat::$options['registration']);
$allowed_cleanup = implode(',', Seat::$options['cleanup_data']);
$allowed_tracking = implode(',', Seat::$options['allow_tracking']);
return [
'registration' => 'required|in:' . $allowed_registration,
'cleanup_data' => 'required|in:' . $allowed_cleanup,
'admin_contact' => 'required|email',
'allow_tracking' => 'required|in:' . $allowed_tracking,
];
} | php | public function rules()
{
$allowed_registration = implode(',', Seat::$options['registration']);
$allowed_cleanup = implode(',', Seat::$options['cleanup_data']);
$allowed_tracking = implode(',', Seat::$options['allow_tracking']);
return [
'registration' => 'required|in:' . $allowed_registration,
'cleanup_data' => 'required|in:' . $allowed_cleanup,
'admin_contact' => 'required|email',
'allow_tracking' => 'required|in:' . $allowed_tracking,
];
} | [
"public",
"function",
"rules",
"(",
")",
"{",
"$",
"allowed_registration",
"=",
"implode",
"(",
"','",
",",
"Seat",
"::",
"$",
"options",
"[",
"'registration'",
"]",
")",
";",
"$",
"allowed_cleanup",
"=",
"implode",
"(",
"','",
",",
"Seat",
"::",
"$",
... | Get the validation rules that apply to the request.
@return array | [
"Get",
"the",
"validation",
"rules",
"that",
"apply",
"to",
"the",
"request",
"."
] | train | https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Http/Validation/SeatSettings.php#L50-L63 |
eveseat/web | src/Http/Validation/NewSchedule.php | NewSchedule.rules | public function rules()
{
$available_commands = implode(',', array_keys(Artisan::all()));
return [
'command' => 'required|in:' . $available_commands,
'expression' => 'required|cron|unique:schedules,expression,NULL,NULL,command,' .
$this->request->get('command'),
];
} | php | public function rules()
{
$available_commands = implode(',', array_keys(Artisan::all()));
return [
'command' => 'required|in:' . $available_commands,
'expression' => 'required|cron|unique:schedules,expression,NULL,NULL,command,' .
$this->request->get('command'),
];
} | [
"public",
"function",
"rules",
"(",
")",
"{",
"$",
"available_commands",
"=",
"implode",
"(",
"','",
",",
"array_keys",
"(",
"Artisan",
"::",
"all",
"(",
")",
")",
")",
";",
"return",
"[",
"'command'",
"=>",
"'required|in:'",
".",
"$",
"available_commands"... | Get the validation rules that apply to the request.
I have to admit, the Laravel docs is super shit when it
comes to the unique condition with a where clause.
After reading a number of crap posts online, I think I
finally figured it out.
Lies! **I have no idea how it works**, but for sanity
sake, here is the query that gets generated for the
'expression' unique with where validation:
select count(*) as aggregate from `schedules` where
`expression` = "cron_expression" and `command`
= "command-name"
Lolwut...
@return array | [
"Get",
"the",
"validation",
"rules",
"that",
"apply",
"to",
"the",
"request",
"."
] | train | https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Http/Validation/NewSchedule.php#L78-L89 |
eveseat/web | src/Http/Validation/Custom/Cron.php | Cron.validate | public function validate($attribute, $value, $parameters, $validator)
{
// Try create a new CronExpression factory. If
// this fails, we can assume the expression
// itself is invalid/malformed.
try {
CronExpression::factory($value);
} catch (InvalidArgumentException $e) {
return false;
}
return true;
} | php | public function validate($attribute, $value, $parameters, $validator)
{
// Try create a new CronExpression factory. If
// this fails, we can assume the expression
// itself is invalid/malformed.
try {
CronExpression::factory($value);
} catch (InvalidArgumentException $e) {
return false;
}
return true;
} | [
"public",
"function",
"validate",
"(",
"$",
"attribute",
",",
"$",
"value",
",",
"$",
"parameters",
",",
"$",
"validator",
")",
"{",
"// Try create a new CronExpression factory. If",
"// this fails, we can assume the expression",
"// itself is invalid/malformed.",
"try",
"{... | Validate if the $value is a valid cron expression.
@param $attribute
@param $value
@param $parameters
@param $validator
@return bool | [
"Validate",
"if",
"the",
"$value",
"is",
"a",
"valid",
"cron",
"expression",
"."
] | train | https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Http/Validation/Custom/Cron.php#L44-L61 |
eveseat/web | src/Http/Composers/Esi.php | Esi.compose | public function compose(View $view)
{
$view->with('esi_status', EsiStatus::latest()->first());
$view->with('is_rate_limited', $this->isEsiRateLimited());
$view->with('rate_limit_ttl', $this->getRateLimitKeyTtl());
} | php | public function compose(View $view)
{
$view->with('esi_status', EsiStatus::latest()->first());
$view->with('is_rate_limited', $this->isEsiRateLimited());
$view->with('rate_limit_ttl', $this->getRateLimitKeyTtl());
} | [
"public",
"function",
"compose",
"(",
"View",
"$",
"view",
")",
"{",
"$",
"view",
"->",
"with",
"(",
"'esi_status'",
",",
"EsiStatus",
"::",
"latest",
"(",
")",
"->",
"first",
"(",
")",
")",
";",
"$",
"view",
"->",
"with",
"(",
"'is_rate_limited'",
"... | Bind data to the view.
@param View $view
@return void
@throws \Exception | [
"Bind",
"data",
"to",
"the",
"view",
"."
] | train | https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Http/Composers/Esi.php#L46-L52 |
eveseat/web | src/Http/Controllers/Corporation/IndustryController.php | IndustryController.getIndustryData | public function getIndustryData(int $corporation_id)
{
$jobs = $this->getCorporationIndustry($corporation_id, false);
return Datatables::of($jobs)
->editColumn('installer_id', function ($row) {
return view('web::partials.industryinstaller', compact('row'))
->render();
})
->editColumn('facilityName', function ($row) {
return view('web::partials.industrysystem', compact('row'))
->render();
})
->editColumn('blueprintTypeName', function ($row) {
return view('web::partials.industryblueprint', compact('row'))
->render();
})
->editColumn('productTypeName', function ($row) {
return view('web::partials.industryproduct', compact('row'))
->render();
})
->rawColumns(['installer_id', 'facilityName', 'blueprintTypeName', 'productTypeName'])
->make(true);
} | php | public function getIndustryData(int $corporation_id)
{
$jobs = $this->getCorporationIndustry($corporation_id, false);
return Datatables::of($jobs)
->editColumn('installer_id', function ($row) {
return view('web::partials.industryinstaller', compact('row'))
->render();
})
->editColumn('facilityName', function ($row) {
return view('web::partials.industrysystem', compact('row'))
->render();
})
->editColumn('blueprintTypeName', function ($row) {
return view('web::partials.industryblueprint', compact('row'))
->render();
})
->editColumn('productTypeName', function ($row) {
return view('web::partials.industryproduct', compact('row'))
->render();
})
->rawColumns(['installer_id', 'facilityName', 'blueprintTypeName', 'productTypeName'])
->make(true);
} | [
"public",
"function",
"getIndustryData",
"(",
"int",
"$",
"corporation_id",
")",
"{",
"$",
"jobs",
"=",
"$",
"this",
"->",
"getCorporationIndustry",
"(",
"$",
"corporation_id",
",",
"false",
")",
";",
"return",
"Datatables",
"::",
"of",
"(",
"$",
"jobs",
"... | @param int $corporation_id
@return mixed
@throws \Exception | [
"@param",
"int",
"$corporation_id"
] | train | https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Http/Controllers/Corporation/IndustryController.php#L54-L83 |
eveseat/web | src/Http/Controllers/Profile/ProfileController.php | ProfileController.getUpdateUserSettings | public function getUpdateUserSettings(ProfileSettings $request)
{
// Update the rest of the settings
Profile::set('main_character_id', $request->main_character_id);
Profile::set('skin', $request->skin);
Profile::set('language', $request->language);
Profile::set('sidebar', $request->sidebar);
Profile::set('mail_threads', $request->mail_threads);
Profile::set('thousand_seperator', $request->thousand_seperator);
Profile::set('decimal_seperator', $request->decimal_seperator);
Profile::set('email_notifications', $request->email_notifications);
return redirect()->back()
->with('success', 'Profile settings updated!');
} | php | public function getUpdateUserSettings(ProfileSettings $request)
{
// Update the rest of the settings
Profile::set('main_character_id', $request->main_character_id);
Profile::set('skin', $request->skin);
Profile::set('language', $request->language);
Profile::set('sidebar', $request->sidebar);
Profile::set('mail_threads', $request->mail_threads);
Profile::set('thousand_seperator', $request->thousand_seperator);
Profile::set('decimal_seperator', $request->decimal_seperator);
Profile::set('email_notifications', $request->email_notifications);
return redirect()->back()
->with('success', 'Profile settings updated!');
} | [
"public",
"function",
"getUpdateUserSettings",
"(",
"ProfileSettings",
"$",
"request",
")",
"{",
"// Update the rest of the settings",
"Profile",
"::",
"set",
"(",
"'main_character_id'",
",",
"$",
"request",
"->",
"main_character_id",
")",
";",
"Profile",
"::",
"set",... | @param \Seat\Web\Http\Validation\ProfileSettings $request
@return \Illuminate\Http\RedirectResponse
@throws \Seat\Services\Exceptions\SettingException | [
"@param",
"\\",
"Seat",
"\\",
"Web",
"\\",
"Http",
"\\",
"Validation",
"\\",
"ProfileSettings",
"$request"
] | train | https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Http/Controllers/Profile/ProfileController.php#L72-L89 |
eveseat/web | src/Http/Controllers/Profile/ProfileController.php | ProfileController.postUpdateEmail | public function postUpdateEmail(EmailUpdate $request)
{
Profile::set('email_address', $request->new_email);
return redirect()->back()
->with('success', 'Email updated!');
} | php | public function postUpdateEmail(EmailUpdate $request)
{
Profile::set('email_address', $request->new_email);
return redirect()->back()
->with('success', 'Email updated!');
} | [
"public",
"function",
"postUpdateEmail",
"(",
"EmailUpdate",
"$",
"request",
")",
"{",
"Profile",
"::",
"set",
"(",
"'email_address'",
",",
"$",
"request",
"->",
"new_email",
")",
";",
"return",
"redirect",
"(",
")",
"->",
"back",
"(",
")",
"->",
"with",
... | @param \Seat\Web\Http\Validation\EmailUpdate $request
@return \Illuminate\Http\RedirectResponse
@throws \Seat\Services\Exceptions\SettingException | [
"@param",
"\\",
"Seat",
"\\",
"Web",
"\\",
"Http",
"\\",
"Validation",
"\\",
"EmailUpdate",
"$request"
] | train | https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Http/Controllers/Profile/ProfileController.php#L97-L104 |
eveseat/web | src/Http/Controllers/Profile/ProfileController.php | ProfileController.getChangeCharacter | public function getChangeCharacter(int $character_id)
{
$user_characters = $this->getUserGroupCharacters(
auth()->user()->group)->pluck('id');
// Prevent logins to arbitrary characters.
if (! $user_characters->contains($character_id)) {
// Log this attempt
event('security.log', ['Character change denied ', 'authentication']);
abort(404);
}
// Find the new user to login as.
$user = User::findOrFail($character_id);
// Log the character change login event.
event('security.log', [
'Character change to ' . $user->name . ' from ' . auth()->user()->name,
'authentication',
]);
auth()->login($user, true);
return redirect()->back();
} | php | public function getChangeCharacter(int $character_id)
{
$user_characters = $this->getUserGroupCharacters(
auth()->user()->group)->pluck('id');
// Prevent logins to arbitrary characters.
if (! $user_characters->contains($character_id)) {
// Log this attempt
event('security.log', ['Character change denied ', 'authentication']);
abort(404);
}
// Find the new user to login as.
$user = User::findOrFail($character_id);
// Log the character change login event.
event('security.log', [
'Character change to ' . $user->name . ' from ' . auth()->user()->name,
'authentication',
]);
auth()->login($user, true);
return redirect()->back();
} | [
"public",
"function",
"getChangeCharacter",
"(",
"int",
"$",
"character_id",
")",
"{",
"$",
"user_characters",
"=",
"$",
"this",
"->",
"getUserGroupCharacters",
"(",
"auth",
"(",
")",
"->",
"user",
"(",
")",
"->",
"group",
")",
"->",
"pluck",
"(",
"'id'",
... | @param int $character_id
@return \Illuminate\Http\RedirectResponse | [
"@param",
"int",
"$character_id"
] | train | https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Http/Controllers/Profile/ProfileController.php#L111-L137 |
eveseat/web | src/Http/Controllers/Auth/EmailController.php | EmailController.confirmEmail | public function confirmEmail($token)
{
$user = User::whereActivationToken($token)->firstOrFail();
$user->confirmEmail();
auth()->login($user);
return redirect()->intended()
->with('success', 'Email verified!');
} | php | public function confirmEmail($token)
{
$user = User::whereActivationToken($token)->firstOrFail();
$user->confirmEmail();
auth()->login($user);
return redirect()->intended()
->with('success', 'Email verified!');
} | [
"public",
"function",
"confirmEmail",
"(",
"$",
"token",
")",
"{",
"$",
"user",
"=",
"User",
"::",
"whereActivationToken",
"(",
"$",
"token",
")",
"->",
"firstOrFail",
"(",
")",
";",
"$",
"user",
"->",
"confirmEmail",
"(",
")",
";",
"auth",
"(",
")",
... | @param $token
@return \Illuminate\Http\RedirectResponse | [
"@param",
"$token"
] | train | https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Http/Controllers/Auth/EmailController.php#L39-L50 |
eveseat/web | src/Http/Controllers/Configuration/ScheduleController.php | ScheduleController.newSchedule | public function newSchedule(NewSchedule $request)
{
Schedule::create($request->all());
return redirect()->back()
->with('success', 'New Schedule has been added!');
} | php | public function newSchedule(NewSchedule $request)
{
Schedule::create($request->all());
return redirect()->back()
->with('success', 'New Schedule has been added!');
} | [
"public",
"function",
"newSchedule",
"(",
"NewSchedule",
"$",
"request",
")",
"{",
"Schedule",
"::",
"create",
"(",
"$",
"request",
"->",
"all",
"(",
")",
")",
";",
"return",
"redirect",
"(",
")",
"->",
"back",
"(",
")",
"->",
"with",
"(",
"'success'",... | @param \Seat\Web\Http\Validation\NewSchedule $request
@return \Illuminate\Http\RedirectResponse | [
"@param",
"\\",
"Seat",
"\\",
"Web",
"\\",
"Http",
"\\",
"Validation",
"\\",
"NewSchedule",
"$request"
] | train | https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Http/Controllers/Configuration/ScheduleController.php#L66-L74 |
eveseat/web | src/Http/Controllers/Character/PiController.php | PiController.getPi | public function getPi(int $character_id)
{
$colonies = $this->getCharacterPlanetaryColonies($character_id);
$extractors = $this->getCharacterPlanetaryExtractors($character_id);
// TODO: Complete the Links and stuff™
return view('web::character.pi', compact('colonies', 'extractors'));
} | php | public function getPi(int $character_id)
{
$colonies = $this->getCharacterPlanetaryColonies($character_id);
$extractors = $this->getCharacterPlanetaryExtractors($character_id);
// TODO: Complete the Links and stuff™
return view('web::character.pi', compact('colonies', 'extractors'));
} | [
"public",
"function",
"getPi",
"(",
"int",
"$",
"character_id",
")",
"{",
"$",
"colonies",
"=",
"$",
"this",
"->",
"getCharacterPlanetaryColonies",
"(",
"$",
"character_id",
")",
";",
"$",
"extractors",
"=",
"$",
"this",
"->",
"getCharacterPlanetaryExtractors",
... | @param $character_id
@return \Illuminate\Contracts\View\Factory|\Illuminate\View\View | [
"@param",
"$character_id"
] | train | https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Http/Controllers/Character/PiController.php#L37-L46 |
eveseat/web | src/Http/Controllers/Corporation/AssetsController.php | AssetsController.getAssets | public function getAssets(int $corporation_id)
{
$divisions = $this->getCorporationDivisions($corporation_id);
$assets = $this->getCorporationAssets($corporation_id);
return view('web::corporation.assets', compact('divisions', 'assets'));
} | php | public function getAssets(int $corporation_id)
{
$divisions = $this->getCorporationDivisions($corporation_id);
$assets = $this->getCorporationAssets($corporation_id);
return view('web::corporation.assets', compact('divisions', 'assets'));
} | [
"public",
"function",
"getAssets",
"(",
"int",
"$",
"corporation_id",
")",
"{",
"$",
"divisions",
"=",
"$",
"this",
"->",
"getCorporationDivisions",
"(",
"$",
"corporation_id",
")",
";",
"$",
"assets",
"=",
"$",
"this",
"->",
"getCorporationAssets",
"(",
"$"... | @param $corporation_id
@return \Illuminate\Contracts\View\Factory|\Illuminate\View\View | [
"@param",
"$corporation_id"
] | train | https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Http/Controllers/Corporation/AssetsController.php#L42-L49 |
eveseat/web | src/Http/Controllers/Corporation/AssetsController.php | AssetsController.getAssetsContents | public function getAssetsContents(int $corporation_id, int $item_id)
{
$contents = $this->getCorporationAssetContents($corporation_id, $item_id);
return view('web::partials.assetscontents', compact('contents'));
} | php | public function getAssetsContents(int $corporation_id, int $item_id)
{
$contents = $this->getCorporationAssetContents($corporation_id, $item_id);
return view('web::partials.assetscontents', compact('contents'));
} | [
"public",
"function",
"getAssetsContents",
"(",
"int",
"$",
"corporation_id",
",",
"int",
"$",
"item_id",
")",
"{",
"$",
"contents",
"=",
"$",
"this",
"->",
"getCorporationAssetContents",
"(",
"$",
"corporation_id",
",",
"$",
"item_id",
")",
";",
"return",
"... | @param int $corporation_id
@param int $item_id
@return \Illuminate\Contracts\View\Factory|\Illuminate\View\View | [
"@param",
"int",
"$corporation_id",
"@param",
"int",
"$item_id"
] | train | https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Http/Controllers/Corporation/AssetsController.php#L57-L63 |
eveseat/web | src/Http/Controllers/Tools/StandingsController.php | StandingsController.postNewStanding | public function postNewStanding(StandingsBuilder $request)
{
StandingsProfile::create([
'name' => $request->input('name'),
]);
return redirect()->back()
->with('success', 'Created!');
} | php | public function postNewStanding(StandingsBuilder $request)
{
StandingsProfile::create([
'name' => $request->input('name'),
]);
return redirect()->back()
->with('success', 'Created!');
} | [
"public",
"function",
"postNewStanding",
"(",
"StandingsBuilder",
"$",
"request",
")",
"{",
"StandingsProfile",
"::",
"create",
"(",
"[",
"'name'",
"=>",
"$",
"request",
"->",
"input",
"(",
"'name'",
")",
",",
"]",
")",
";",
"return",
"redirect",
"(",
")",... | @param \Seat\Web\Http\Validation\StandingsBuilder $request
@return \Illuminate\Http\RedirectResponse | [
"@param",
"\\",
"Seat",
"\\",
"Web",
"\\",
"Http",
"\\",
"Validation",
"\\",
"StandingsBuilder",
"$request"
] | train | https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Http/Controllers/Tools/StandingsController.php#L69-L79 |
eveseat/web | src/Http/Controllers/Tools/StandingsController.php | StandingsController.getDeleteStandingsProfile | public function getDeleteStandingsProfile(int $profile_id)
{
$standing = StandingsProfile::findOrFail($profile_id);
$standing->delete();
return redirect()->back()
->with('success', 'Standings profile deleted.');
} | php | public function getDeleteStandingsProfile(int $profile_id)
{
$standing = StandingsProfile::findOrFail($profile_id);
$standing->delete();
return redirect()->back()
->with('success', 'Standings profile deleted.');
} | [
"public",
"function",
"getDeleteStandingsProfile",
"(",
"int",
"$",
"profile_id",
")",
"{",
"$",
"standing",
"=",
"StandingsProfile",
"::",
"findOrFail",
"(",
"$",
"profile_id",
")",
";",
"$",
"standing",
"->",
"delete",
"(",
")",
";",
"return",
"redirect",
... | @param int $profile_id
@return \Illuminate\Http\RedirectResponse | [
"@param",
"int",
"$profile_id"
] | train | https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Http/Controllers/Tools/StandingsController.php#L86-L94 |
eveseat/web | src/Http/Controllers/Tools/StandingsController.php | StandingsController.getStandingEdit | public function getStandingEdit(int $id)
{
$standing = StandingsProfile::with('standings')
->where('id', $id)
->first();
$characters = $this->getAllCharactersWithAffiliations();
$corporations = $this->getAllCorporationsWithAffiliationsAndFilters();
return view('web::tools.standings.edit',
compact('standing', 'characters', 'corporations'));
} | php | public function getStandingEdit(int $id)
{
$standing = StandingsProfile::with('standings')
->where('id', $id)
->first();
$characters = $this->getAllCharactersWithAffiliations();
$corporations = $this->getAllCorporationsWithAffiliationsAndFilters();
return view('web::tools.standings.edit',
compact('standing', 'characters', 'corporations'));
} | [
"public",
"function",
"getStandingEdit",
"(",
"int",
"$",
"id",
")",
"{",
"$",
"standing",
"=",
"StandingsProfile",
"::",
"with",
"(",
"'standings'",
")",
"->",
"where",
"(",
"'id'",
",",
"$",
"id",
")",
"->",
"first",
"(",
")",
";",
"$",
"characters",... | @param int $id
@return \Illuminate\Contracts\View\Factory|\Illuminate\View\View | [
"@param",
"int",
"$id"
] | train | https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Http/Controllers/Tools/StandingsController.php#L101-L113 |
eveseat/web | src/Http/Controllers/Tools/StandingsController.php | StandingsController.getStandingsAjaxElementName | public function getStandingsAjaxElementName(Request $request)
{
$response = [
'results' => [],
];
if (strlen($request->input('search')) > 0) {
try {
// Resolve the Esi client library from the IoC
$eseye = app('esi-client')->get();
$eseye->setVersion('v2');
$eseye->setQueryString([
'categories' => $request->input('type'),
'search' => $request->input('search'),
]);
$entityIds = $eseye->invoke('get', '/search/');
if (! property_exists($entityIds, $request->input('type')))
return response()->json([]);
if (count($entityIds->{$request->input('type')}) < 1)
return response()->json();
collect($entityIds->{$request->input('type')})->unique()
->filter(function ($id) use (&$response) {
// Next, filter the ids we have in the cache, setting
// the appropriate response values as we go along.
if ($cached_entry = cache('name_id:' . $id)) {
$response['results'][] = [
'id' => $id,
'text' => $cached_entry,
];
// Remove this as a valid id, we already have the value we want.
return false;
}
// We don't have this id in the cache. Return it
// so that we can update it later.
return true;
})->chunk(1000)->each(function ($chunk) use (&$response, $eseye) {
$eseye->setVersion('v2');
$eseye->setBody($chunk->flatten()->toArray());
$names = $eseye->invoke('post', '/universe/names/');
collect($names)->each(function ($name) use (&$response) {
// Cache the name resolution for this id for a long time.
cache(['name_id:' . $name->id => $name->name], carbon()->addCentury());
$response['results'][] = [
'id' => $name->id,
'text' => $name->name,
];
});
});
} catch (Exception $e) {
}
}
return response()->json($response);
} | php | public function getStandingsAjaxElementName(Request $request)
{
$response = [
'results' => [],
];
if (strlen($request->input('search')) > 0) {
try {
// Resolve the Esi client library from the IoC
$eseye = app('esi-client')->get();
$eseye->setVersion('v2');
$eseye->setQueryString([
'categories' => $request->input('type'),
'search' => $request->input('search'),
]);
$entityIds = $eseye->invoke('get', '/search/');
if (! property_exists($entityIds, $request->input('type')))
return response()->json([]);
if (count($entityIds->{$request->input('type')}) < 1)
return response()->json();
collect($entityIds->{$request->input('type')})->unique()
->filter(function ($id) use (&$response) {
// Next, filter the ids we have in the cache, setting
// the appropriate response values as we go along.
if ($cached_entry = cache('name_id:' . $id)) {
$response['results'][] = [
'id' => $id,
'text' => $cached_entry,
];
// Remove this as a valid id, we already have the value we want.
return false;
}
// We don't have this id in the cache. Return it
// so that we can update it later.
return true;
})->chunk(1000)->each(function ($chunk) use (&$response, $eseye) {
$eseye->setVersion('v2');
$eseye->setBody($chunk->flatten()->toArray());
$names = $eseye->invoke('post', '/universe/names/');
collect($names)->each(function ($name) use (&$response) {
// Cache the name resolution for this id for a long time.
cache(['name_id:' . $name->id => $name->name], carbon()->addCentury());
$response['results'][] = [
'id' => $name->id,
'text' => $name->name,
];
});
});
} catch (Exception $e) {
}
}
return response()->json($response);
} | [
"public",
"function",
"getStandingsAjaxElementName",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"response",
"=",
"[",
"'results'",
"=>",
"[",
"]",
",",
"]",
";",
"if",
"(",
"strlen",
"(",
"$",
"request",
"->",
"input",
"(",
"'search'",
")",
")",
">... | @param \Illuminate\Http\Request $request
@return \Illuminate\Http\JsonResponse | [
"@param",
"\\",
"Illuminate",
"\\",
"Http",
"\\",
"Request",
"$request"
] | train | https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Http/Controllers/Tools/StandingsController.php#L120-L191 |
eveseat/web | src/Http/Controllers/Tools/StandingsController.php | StandingsController.postAddElementToStanding | public function postAddElementToStanding(StandingsElementAdd $request)
{
$element_id = $request->input('element_id');
$type = $request->input('type');
$standing = $request->input('standing');
// Ensure that the element we got is one what we managed
// to resolve earlier.
if (! cache($this->cache_prefix . $element_id))
return redirect()->back()
->with('error', 'Invalid Element ID');
$standings_profile = StandingsProfile::find($request->input('id'));
$standings_profile->standings()->save(new StandingsProfileStanding([
'type' => $type,
'elementID' => $element_id,
'standing' => $standing,
]));
return redirect()->back()
->with('success', 'Element Added to Profile!');
} | php | public function postAddElementToStanding(StandingsElementAdd $request)
{
$element_id = $request->input('element_id');
$type = $request->input('type');
$standing = $request->input('standing');
// Ensure that the element we got is one what we managed
// to resolve earlier.
if (! cache($this->cache_prefix . $element_id))
return redirect()->back()
->with('error', 'Invalid Element ID');
$standings_profile = StandingsProfile::find($request->input('id'));
$standings_profile->standings()->save(new StandingsProfileStanding([
'type' => $type,
'elementID' => $element_id,
'standing' => $standing,
]));
return redirect()->back()
->with('success', 'Element Added to Profile!');
} | [
"public",
"function",
"postAddElementToStanding",
"(",
"StandingsElementAdd",
"$",
"request",
")",
"{",
"$",
"element_id",
"=",
"$",
"request",
"->",
"input",
"(",
"'element_id'",
")",
";",
"$",
"type",
"=",
"$",
"request",
"->",
"input",
"(",
"'type'",
")",... | @param \Seat\Web\Http\Validation\StandingsElementAdd $request
@return \Illuminate\Http\RedirectResponse
@throws \Exception | [
"@param",
"\\",
"Seat",
"\\",
"Web",
"\\",
"Http",
"\\",
"Validation",
"\\",
"StandingsElementAdd",
"$request"
] | train | https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Http/Controllers/Tools/StandingsController.php#L199-L222 |
eveseat/web | src/Http/Controllers/Tools/StandingsController.php | StandingsController.postAddStandingsFromCorpOrChar | public function postAddStandingsFromCorpOrChar(StandingsExistingElementAdd $request)
{
// Get the standings profile that will be updated.
$standings_profile = StandingsProfile::find($request->input('id'));
// Character Contacts
if ($request->filled('character')) {
foreach ($this->getCharacterContacts($request->input('character')) as $contact) {
// Prepare the standings entry.
$standing = StandingsProfileStanding::firstOrNew([
'standings_profile_id' => $request->input('id'),
'elementID' => $contact->contact_id,
'type' => $contact->contact_type,
])->fill([
// Update the standing incase its different to an
// existing one.
'standing' => $contact->standing,
]);
// Save the standings entry to the profile.
$standings_profile->standings()->save($standing);
}
}
// Corporation Contacts
if ($request->filled('corporation')) {
foreach ($this->getCorporationContacts($request->input('corporation')) as $contact) {
// Prepare the standings entry.
$standing = StandingsProfileStanding::firstOrNew([
'standings_profile_id' => $request->input('id'),
'elementID' => $contact->contact_id,
'type' => $contact->contact_type,
])->fill([
// Update the standing incase its different to an
// existing one.
'standing' => $contact->standing,
]);
// Save the standings entry to the profile.
$standings_profile->standings()->save($standing);
}
}
return redirect()->back()
->with('success', 'Standings successfully imported from contact lists.');
} | php | public function postAddStandingsFromCorpOrChar(StandingsExistingElementAdd $request)
{
// Get the standings profile that will be updated.
$standings_profile = StandingsProfile::find($request->input('id'));
// Character Contacts
if ($request->filled('character')) {
foreach ($this->getCharacterContacts($request->input('character')) as $contact) {
// Prepare the standings entry.
$standing = StandingsProfileStanding::firstOrNew([
'standings_profile_id' => $request->input('id'),
'elementID' => $contact->contact_id,
'type' => $contact->contact_type,
])->fill([
// Update the standing incase its different to an
// existing one.
'standing' => $contact->standing,
]);
// Save the standings entry to the profile.
$standings_profile->standings()->save($standing);
}
}
// Corporation Contacts
if ($request->filled('corporation')) {
foreach ($this->getCorporationContacts($request->input('corporation')) as $contact) {
// Prepare the standings entry.
$standing = StandingsProfileStanding::firstOrNew([
'standings_profile_id' => $request->input('id'),
'elementID' => $contact->contact_id,
'type' => $contact->contact_type,
])->fill([
// Update the standing incase its different to an
// existing one.
'standing' => $contact->standing,
]);
// Save the standings entry to the profile.
$standings_profile->standings()->save($standing);
}
}
return redirect()->back()
->with('success', 'Standings successfully imported from contact lists.');
} | [
"public",
"function",
"postAddStandingsFromCorpOrChar",
"(",
"StandingsExistingElementAdd",
"$",
"request",
")",
"{",
"// Get the standings profile that will be updated.",
"$",
"standings_profile",
"=",
"StandingsProfile",
"::",
"find",
"(",
"$",
"request",
"->",
"input",
"... | @param \Seat\Web\Http\Validation\StandingsExistingElementAdd $request
@return \Illuminate\Http\RedirectResponse | [
"@param",
"\\",
"Seat",
"\\",
"Web",
"\\",
"Http",
"\\",
"Validation",
"\\",
"StandingsExistingElementAdd",
"$request"
] | train | https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Http/Controllers/Tools/StandingsController.php#L229-L280 |
eveseat/web | src/Http/Controllers/Tools/StandingsController.php | StandingsController.getRemoveElementFromProfile | public function getRemoveElementFromProfile(int $element_id, int $profile_id)
{
// Get the standings profile that will be updated.
$standings_profile = StandingsProfile::find($profile_id);
$standings_profile->standings()->find($element_id)->delete();
return redirect()->back()
->with('success', 'Standing removed!');
} | php | public function getRemoveElementFromProfile(int $element_id, int $profile_id)
{
// Get the standings profile that will be updated.
$standings_profile = StandingsProfile::find($profile_id);
$standings_profile->standings()->find($element_id)->delete();
return redirect()->back()
->with('success', 'Standing removed!');
} | [
"public",
"function",
"getRemoveElementFromProfile",
"(",
"int",
"$",
"element_id",
",",
"int",
"$",
"profile_id",
")",
"{",
"// Get the standings profile that will be updated.",
"$",
"standings_profile",
"=",
"StandingsProfile",
"::",
"find",
"(",
"$",
"profile_id",
")... | @param int $element_id
@param int $profile_id
@return \Illuminate\Http\RedirectResponse | [
"@param",
"int",
"$element_id",
"@param",
"int",
"$profile_id"
] | train | https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Http/Controllers/Tools/StandingsController.php#L288-L298 |
eveseat/web | src/Acl/AccessChecker.php | AccessChecker.hasAny | public function hasAny(array $permissions, bool $need_affiliation = true): bool
{
foreach ($permissions as $permission)
if ($this->has($permission, $need_affiliation))
return true;
return false;
} | php | public function hasAny(array $permissions, bool $need_affiliation = true): bool
{
foreach ($permissions as $permission)
if ($this->has($permission, $need_affiliation))
return true;
return false;
} | [
"public",
"function",
"hasAny",
"(",
"array",
"$",
"permissions",
",",
"bool",
"$",
"need_affiliation",
"=",
"true",
")",
":",
"bool",
"{",
"foreach",
"(",
"$",
"permissions",
"as",
"$",
"permission",
")",
"if",
"(",
"$",
"this",
"->",
"has",
"(",
"$",... | Checks if the user has any of the required
permissions.
@param array $permissions
@param bool|false $need_affiliation
@return bool
@throws \Seat\Web\Exceptions\BouncerException | [
"Checks",
"if",
"the",
"user",
"has",
"any",
"of",
"the",
"required",
"permissions",
"."
] | train | https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Acl/AccessChecker.php#L50-L58 |
eveseat/web | src/Acl/AccessChecker.php | AccessChecker.has | public function has($permission, $need_affiliation = true)
{
if ($this->hasSuperUser())
return true;
if (! $need_affiliation) {
if ($this->hasPermissions($permission))
return true;
} else {
if ($this->hasAffiliationAndPermission($permission))
return true;
}
return false;
} | php | public function has($permission, $need_affiliation = true)
{
if ($this->hasSuperUser())
return true;
if (! $need_affiliation) {
if ($this->hasPermissions($permission))
return true;
} else {
if ($this->hasAffiliationAndPermission($permission))
return true;
}
return false;
} | [
"public",
"function",
"has",
"(",
"$",
"permission",
",",
"$",
"need_affiliation",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"hasSuperUser",
"(",
")",
")",
"return",
"true",
";",
"if",
"(",
"!",
"$",
"need_affiliation",
")",
"{",
"if",
"("... | Has.
This is probably *the* most important function in
the ACL logic. It's sole purpose is to ensure that
a logged in user has a specific permission.
@param $permission
@param bool $need_affiliation
@return bool
@throws \Seat\Web\Exceptions\BouncerException | [
"Has",
"."
] | train | https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Acl/AccessChecker.php#L73-L93 |
eveseat/web | src/Acl/AccessChecker.php | AccessChecker.hasSuperUser | public function hasSuperUser()
{
$permissions = $this->getAllPermissions();
foreach ($permissions as $permission)
if ($permission === 'superuser') return true;
return false;
} | php | public function hasSuperUser()
{
$permissions = $this->getAllPermissions();
foreach ($permissions as $permission)
if ($permission === 'superuser') return true;
return false;
} | [
"public",
"function",
"hasSuperUser",
"(",
")",
"{",
"$",
"permissions",
"=",
"$",
"this",
"->",
"getAllPermissions",
"(",
")",
";",
"foreach",
"(",
"$",
"permissions",
"as",
"$",
"permission",
")",
"if",
"(",
"$",
"permission",
"===",
"'superuser'",
")",
... | Determine of the current user has the
superuser permission. | [
"Determine",
"of",
"the",
"current",
"user",
"has",
"the",
"superuser",
"permission",
"."
] | train | https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Acl/AccessChecker.php#L99-L108 |
eveseat/web | src/Acl/AccessChecker.php | AccessChecker.getAllPermissions | public function getAllPermissions()
{
$permissions = [];
$roles = $this->group->roles()->with('permissions')->get();
// Go through every role...
foreach ($roles as $role) {
// ... in every defined permission
foreach ($role->permissions as $permission) {
// only add permissions if it is not an inverse
if (! $permission->pivot->not)
array_push($permissions, $permission->title);
}
}
return $permissions;
} | php | public function getAllPermissions()
{
$permissions = [];
$roles = $this->group->roles()->with('permissions')->get();
// Go through every role...
foreach ($roles as $role) {
// ... in every defined permission
foreach ($role->permissions as $permission) {
// only add permissions if it is not an inverse
if (! $permission->pivot->not)
array_push($permissions, $permission->title);
}
}
return $permissions;
} | [
"public",
"function",
"getAllPermissions",
"(",
")",
"{",
"$",
"permissions",
"=",
"[",
"]",
";",
"$",
"roles",
"=",
"$",
"this",
"->",
"group",
"->",
"roles",
"(",
")",
"->",
"with",
"(",
"'permissions'",
")",
"->",
"get",
"(",
")",
";",
"// Go thro... | Return an array of all the of the permissions
that the user has.
@return array | [
"Return",
"an",
"array",
"of",
"all",
"the",
"of",
"the",
"permissions",
"that",
"the",
"user",
"has",
"."
] | train | https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Acl/AccessChecker.php#L116-L137 |
eveseat/web | src/Acl/AccessChecker.php | AccessChecker.hasAffiliationAndPermission | public function hasAffiliationAndPermission($permission)
{
// TODO: An annoying change in the 3x migration introduced
// and array based permission, which is stupid. Remove that
// or plan better for it in 3.1
$array_permission = $permission;
if (! is_array($permission))
$array_permission = (array) $permission;
// Process entries for character
if (array_filter($array_permission, [$this, 'permissionCharacterLookup']))
return $this->hasCharacterPermission($array_permission);
// Process entries for corporations
if (array_filter($array_permission, [$this, 'permissionCorporationLookup']))
return $this->hasCorporationPermission($array_permission);
return false;
} | php | public function hasAffiliationAndPermission($permission)
{
// TODO: An annoying change in the 3x migration introduced
// and array based permission, which is stupid. Remove that
// or plan better for it in 3.1
$array_permission = $permission;
if (! is_array($permission))
$array_permission = (array) $permission;
// Process entries for character
if (array_filter($array_permission, [$this, 'permissionCharacterLookup']))
return $this->hasCharacterPermission($array_permission);
// Process entries for corporations
if (array_filter($array_permission, [$this, 'permissionCorporationLookup']))
return $this->hasCorporationPermission($array_permission);
return false;
} | [
"public",
"function",
"hasAffiliationAndPermission",
"(",
"$",
"permission",
")",
"{",
"// TODO: An annoying change in the 3x migration introduced",
"// and array based permission, which is stupid. Remove that",
"// or plan better for it in 3.1",
"$",
"array_permission",
"=",
"$",
"per... | Check if the user is correctly affiliated
*and* has the requested permission on that
affiliation.
@param $permission
@return bool
@throws \Seat\Web\Exceptions\BouncerException | [
"Check",
"if",
"the",
"user",
"is",
"correctly",
"affiliated",
"*",
"and",
"*",
"has",
"the",
"requested",
"permission",
"on",
"that",
"affiliation",
"."
] | train | https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Acl/AccessChecker.php#L165-L186 |
eveseat/web | src/Acl/AccessChecker.php | AccessChecker.hasCharacterPermission | private function hasCharacterPermission(array $permission)
{
$map = $this->getAffiliationMap();
// Owning a character grants you '*' permissions to the owned object. In this
// context, '*' acts as a wildcard for *all* permissions
foreach ($map['char'] as $char => $permissions) {
// in case the permissions array is not related to the character for which we're requesting access
// skip
if ($char != $this->getCharacterId())
continue;
// in case a wildcard access has been assigned (user is owner), grant access
if (in_array('character.*', $permissions))
return true;
// yeah, this is dumb. So if we have an array permission, we need to
// loop and check each in there.
foreach ($permission as $sub_permission) {
// check only character wildcard and specific permission
if (in_array($sub_permission, $permissions))
return true;
}
}
return false;
} | php | private function hasCharacterPermission(array $permission)
{
$map = $this->getAffiliationMap();
// Owning a character grants you '*' permissions to the owned object. In this
// context, '*' acts as a wildcard for *all* permissions
foreach ($map['char'] as $char => $permissions) {
// in case the permissions array is not related to the character for which we're requesting access
// skip
if ($char != $this->getCharacterId())
continue;
// in case a wildcard access has been assigned (user is owner), grant access
if (in_array('character.*', $permissions))
return true;
// yeah, this is dumb. So if we have an array permission, we need to
// loop and check each in there.
foreach ($permission as $sub_permission) {
// check only character wildcard and specific permission
if (in_array($sub_permission, $permissions))
return true;
}
}
return false;
} | [
"private",
"function",
"hasCharacterPermission",
"(",
"array",
"$",
"permission",
")",
"{",
"$",
"map",
"=",
"$",
"this",
"->",
"getAffiliationMap",
"(",
")",
";",
"// Owning a character grants you '*' permissions to the owned object. In this",
"// context, '*' acts as a wild... | @param array $permission
@return bool
@throws \Seat\Web\Exceptions\BouncerException | [
"@param",
"array",
"$permission"
] | train | https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Acl/AccessChecker.php#L194-L223 |
eveseat/web | src/Acl/AccessChecker.php | AccessChecker.getAffiliationMap | public function getAffiliationMap()
{
// Prepare a skeleton of the final affiliation map that
// will be returned.
$map = [
'char' => [],
'corp' => [],
// These keys keep record of the affiliations and
// permissions that are marked for inversion.
'inverted_permissions' => [],
'inverted_affiliations' => [
'char' => [],
'corp' => [],
],
];
// User Accounts inherit the character and
// corporation ID's on the keys that they are
// the owner for. They also automatically
// inherit all permissions for these keys.
// TODO: Refactor this in 3.1.
// For now we get the character_ids this user has
// in the character_groups they belong to, then
// assign the wildcard permission for that character.
$user_character_ids = $this->associatedCharacterIds()->toArray();
foreach ($user_character_ids as $user_character_id) {
$map['char'][$user_character_id] = ['character.*'];
}
// Next we move through the roles the user has
// and populate the permissions that the affiliations
// offer us.
foreach ($this->group->roles as $role) {
// A blank array for the permissions granted to
// this role.
$role_permissions = [];
// Add the permissions, ignoring those that
// should be inverted.
foreach ($role->permissions as $permission) {
// If a specific permission should be be inverted,
// update the global array with the permission name.
//
// Also make sure the permission does not exist in
// any of the corp/char arrays.
if ($permission->pivot->not) {
array_push($map['inverted_permissions'], $permission->title);
continue;
}
// Add the permission to the existing array
array_push($role_permissions, $permission->title);
}
// Add the permissions to the affiliations
// map for each respective affiliation. We will also keep in
// mind here that affiliations can have inversions too.
foreach ($role->affiliations as $affiliation) {
if ($affiliation->pivot->not && ! in_array($affiliation->affiliation, $user_character_ids)) {
array_push(
$map['inverted_affiliations'][$affiliation->type],
$affiliation->affiliation);
continue;
}
// It is possible to 'wildcard' users and corporations. This
// is signified by the char / corp id of 0. If we encounter
// this id, then we need to all of the possible corp / char
// in the system to the affiliation map.
if ($affiliation->affiliation === 0) {
if ($affiliation->type == 'char') {
// Process all of the characters
foreach ($this->getAllCharacters()->pluck('character_id') as $characterID) {
if (isset($map['char'][$characterID]))
$map['char'][$characterID] += $role_permissions;
else
$map['char'][$characterID] = $role_permissions;
}
}
if ($affiliation->type == 'corp') {
// Process all of the corporations
foreach ($this->getAllCorporations()->pluck('corporation_id') as $corporationID) {
if (isset($map['corp'][$corporationID]))
$map['corp'][$corporationID] += $role_permissions;
else
$map['corp'][$corporationID] = $role_permissions;
}
}
} else {
// in case we have an affiliation of corp kind
// check if it's containing any character permission and append all character from this corporation
if ($affiliation->type == 'corp') {
$characters = CharacterInfo::where('corporation_id', $affiliation->affiliation)->get();
foreach ($role_permissions as $permission) {
if (strpos($permission, 'character.') !== false) {
$characters->each(function ($character) use (&$map, $permission) {
if (! isset($map['char'][$character->character_id]))
$map['char'][$character->character_id] = [];
array_push($map['char'][$character->character_id], $permission);
});
}
}
}
// Add the single affiliation to the map. As we will run this operation
// multiple times when multiple roles are involved, we need to check if
// affiliations already exist. Not using a ternary of coalesce operator
// here as it makes reading this really hard.
if (isset($map[$affiliation->type][$affiliation->affiliation]))
$map[$affiliation->type][$affiliation->affiliation] += $role_permissions;
else
$map[$affiliation->type][$affiliation->affiliation] = $role_permissions;
}
}
}
// Cleanup any inverted affiliations themselves for characters..
foreach ($map['inverted_affiliations']['char'] as $inverted_affiliation)
unset($map['char'][$inverted_affiliation]);
// And corporations
foreach ($map['inverted_affiliations']['corp'] as $inverted_affiliation)
unset($map['corp'][$inverted_affiliation]);
// Cleanup the inverted affiliations' permissions from
// each of the affiliations.
//
// We start by processing characters
foreach ($map['char'] as $char => $permissions)
$map['char'][$char] = array_diff($map['char'][$char], $map['inverted_permissions']);
// And corporations
foreach ($map['corp'] as $corp => $permissions)
$map['corp'][$corp] = array_diff($map['corp'][$corp], $map['inverted_permissions']);
// ESI Related corporation role <-> SeAT role mapping.
// This is to allow characters that have in game roles
// such as director or other wallet related roles to view
// corporation information.
// TODO: This is going to need a major revamp in 3.1!
$esi_role_map = [
'Accountant' => [
'corporation.summary',
'corporation.journal',
'corporation.transactions',
],
'Auditor' => [
'corporation.summary',
],
'Contract_Manager' => [
'corporation.summary',
'corporation.contracts',
],
'Diplomat' => [
'corporation.summary',
'corporation.tracking',
],
'Director' => ['corporation.*'], // All roles for you!
'Junior_Accountant' => [
'corporation.summary',
'corporation.journal',
'corporation.transactions',
],
'Security_Officer' => [
'corporation.summary',
'corporation.security',
],
'Trader' => [
'corporation.summary',
'corporation.market',
],
];
// Check if there are corporation roles we can add. If so, add 'em.
if ($current_corp_roles = optional($this->character)->corporation_roles) {
// Extract only the roles names and cast to an array for lookups.
$current_corp_roles = $current_corp_roles->pluck('role')->toArray();
foreach ($esi_role_map as $ingame_role => $seat_roles) {
if (in_array($ingame_role, $current_corp_roles)) {
if (! isset($map['corp'][$this->character->corporation_id]))
$map['corp'][$this->character->corporation_id] = [];
foreach ($seat_roles as $seat_role)
array_push($map['corp'][$this->character->corporation_id], $seat_role);
}
}
}
// Finally, return the calculated map!
return $map;
} | php | public function getAffiliationMap()
{
// Prepare a skeleton of the final affiliation map that
// will be returned.
$map = [
'char' => [],
'corp' => [],
// These keys keep record of the affiliations and
// permissions that are marked for inversion.
'inverted_permissions' => [],
'inverted_affiliations' => [
'char' => [],
'corp' => [],
],
];
// User Accounts inherit the character and
// corporation ID's on the keys that they are
// the owner for. They also automatically
// inherit all permissions for these keys.
// TODO: Refactor this in 3.1.
// For now we get the character_ids this user has
// in the character_groups they belong to, then
// assign the wildcard permission for that character.
$user_character_ids = $this->associatedCharacterIds()->toArray();
foreach ($user_character_ids as $user_character_id) {
$map['char'][$user_character_id] = ['character.*'];
}
// Next we move through the roles the user has
// and populate the permissions that the affiliations
// offer us.
foreach ($this->group->roles as $role) {
// A blank array for the permissions granted to
// this role.
$role_permissions = [];
// Add the permissions, ignoring those that
// should be inverted.
foreach ($role->permissions as $permission) {
// If a specific permission should be be inverted,
// update the global array with the permission name.
//
// Also make sure the permission does not exist in
// any of the corp/char arrays.
if ($permission->pivot->not) {
array_push($map['inverted_permissions'], $permission->title);
continue;
}
// Add the permission to the existing array
array_push($role_permissions, $permission->title);
}
// Add the permissions to the affiliations
// map for each respective affiliation. We will also keep in
// mind here that affiliations can have inversions too.
foreach ($role->affiliations as $affiliation) {
if ($affiliation->pivot->not && ! in_array($affiliation->affiliation, $user_character_ids)) {
array_push(
$map['inverted_affiliations'][$affiliation->type],
$affiliation->affiliation);
continue;
}
// It is possible to 'wildcard' users and corporations. This
// is signified by the char / corp id of 0. If we encounter
// this id, then we need to all of the possible corp / char
// in the system to the affiliation map.
if ($affiliation->affiliation === 0) {
if ($affiliation->type == 'char') {
// Process all of the characters
foreach ($this->getAllCharacters()->pluck('character_id') as $characterID) {
if (isset($map['char'][$characterID]))
$map['char'][$characterID] += $role_permissions;
else
$map['char'][$characterID] = $role_permissions;
}
}
if ($affiliation->type == 'corp') {
// Process all of the corporations
foreach ($this->getAllCorporations()->pluck('corporation_id') as $corporationID) {
if (isset($map['corp'][$corporationID]))
$map['corp'][$corporationID] += $role_permissions;
else
$map['corp'][$corporationID] = $role_permissions;
}
}
} else {
// in case we have an affiliation of corp kind
// check if it's containing any character permission and append all character from this corporation
if ($affiliation->type == 'corp') {
$characters = CharacterInfo::where('corporation_id', $affiliation->affiliation)->get();
foreach ($role_permissions as $permission) {
if (strpos($permission, 'character.') !== false) {
$characters->each(function ($character) use (&$map, $permission) {
if (! isset($map['char'][$character->character_id]))
$map['char'][$character->character_id] = [];
array_push($map['char'][$character->character_id], $permission);
});
}
}
}
// Add the single affiliation to the map. As we will run this operation
// multiple times when multiple roles are involved, we need to check if
// affiliations already exist. Not using a ternary of coalesce operator
// here as it makes reading this really hard.
if (isset($map[$affiliation->type][$affiliation->affiliation]))
$map[$affiliation->type][$affiliation->affiliation] += $role_permissions;
else
$map[$affiliation->type][$affiliation->affiliation] = $role_permissions;
}
}
}
// Cleanup any inverted affiliations themselves for characters..
foreach ($map['inverted_affiliations']['char'] as $inverted_affiliation)
unset($map['char'][$inverted_affiliation]);
// And corporations
foreach ($map['inverted_affiliations']['corp'] as $inverted_affiliation)
unset($map['corp'][$inverted_affiliation]);
// Cleanup the inverted affiliations' permissions from
// each of the affiliations.
//
// We start by processing characters
foreach ($map['char'] as $char => $permissions)
$map['char'][$char] = array_diff($map['char'][$char], $map['inverted_permissions']);
// And corporations
foreach ($map['corp'] as $corp => $permissions)
$map['corp'][$corp] = array_diff($map['corp'][$corp], $map['inverted_permissions']);
// ESI Related corporation role <-> SeAT role mapping.
// This is to allow characters that have in game roles
// such as director or other wallet related roles to view
// corporation information.
// TODO: This is going to need a major revamp in 3.1!
$esi_role_map = [
'Accountant' => [
'corporation.summary',
'corporation.journal',
'corporation.transactions',
],
'Auditor' => [
'corporation.summary',
],
'Contract_Manager' => [
'corporation.summary',
'corporation.contracts',
],
'Diplomat' => [
'corporation.summary',
'corporation.tracking',
],
'Director' => ['corporation.*'], // All roles for you!
'Junior_Accountant' => [
'corporation.summary',
'corporation.journal',
'corporation.transactions',
],
'Security_Officer' => [
'corporation.summary',
'corporation.security',
],
'Trader' => [
'corporation.summary',
'corporation.market',
],
];
// Check if there are corporation roles we can add. If so, add 'em.
if ($current_corp_roles = optional($this->character)->corporation_roles) {
// Extract only the roles names and cast to an array for lookups.
$current_corp_roles = $current_corp_roles->pluck('role')->toArray();
foreach ($esi_role_map as $ingame_role => $seat_roles) {
if (in_array($ingame_role, $current_corp_roles)) {
if (! isset($map['corp'][$this->character->corporation_id]))
$map['corp'][$this->character->corporation_id] = [];
foreach ($seat_roles as $seat_role)
array_push($map['corp'][$this->character->corporation_id], $seat_role);
}
}
}
// Finally, return the calculated map!
return $map;
} | [
"public",
"function",
"getAffiliationMap",
"(",
")",
"{",
"// Prepare a skeleton of the final affiliation map that",
"// will be returned.",
"$",
"map",
"=",
"[",
"'char'",
"=>",
"[",
"]",
",",
"'corp'",
"=>",
"[",
"]",
",",
"// These keys keep record of the affiliations ... | The affiliation map maps character / corporation
ID's to the permissions that they have. This allows
us to simply lookup the existence of a permission
in the context of an ID. All roles are considered
but strict adherence to *which* affiliation ID's are
applicable is kept.
Keys that a character own automatically grants them
all permissions to that corp/char keeping in mind
of course that the key type needs to match too.
@return array | [
"The",
"affiliation",
"map",
"maps",
"character",
"/",
"corporation",
"ID",
"s",
"to",
"the",
"permissions",
"that",
"they",
"have",
".",
"This",
"allows",
"us",
"to",
"simply",
"lookup",
"the",
"existence",
"of",
"a",
"permission",
"in",
"the",
"context",
... | train | https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Acl/AccessChecker.php#L239-L469 |
eveseat/web | src/Acl/AccessChecker.php | AccessChecker.hasCorporationPermission | private function hasCorporationPermission(array $permission)
{
$map = $this->getAffiliationMap();
foreach ($map['corp'] as $corp => $permissions) {
// in case the permissions array is not related to the corporation for which we're checking access
// skip
if ($corp != $this->getCorporationId())
continue;
// in case a wildcard access is in the permissions array, grant access
if (in_array('corporation.*', $permissions))
return true;
foreach ($permission as $sub_permission) {
if (in_array($sub_permission, $permissions))
return true;
}
}
return false;
} | php | private function hasCorporationPermission(array $permission)
{
$map = $this->getAffiliationMap();
foreach ($map['corp'] as $corp => $permissions) {
// in case the permissions array is not related to the corporation for which we're checking access
// skip
if ($corp != $this->getCorporationId())
continue;
// in case a wildcard access is in the permissions array, grant access
if (in_array('corporation.*', $permissions))
return true;
foreach ($permission as $sub_permission) {
if (in_array($sub_permission, $permissions))
return true;
}
}
return false;
} | [
"private",
"function",
"hasCorporationPermission",
"(",
"array",
"$",
"permission",
")",
"{",
"$",
"map",
"=",
"$",
"this",
"->",
"getAffiliationMap",
"(",
")",
";",
"foreach",
"(",
"$",
"map",
"[",
"'corp'",
"]",
"as",
"$",
"corp",
"=>",
"$",
"permissio... | @param array $permission
@return bool
@throws \Seat\Web\Exceptions\BouncerException | [
"@param",
"array",
"$permission"
] | train | https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Acl/AccessChecker.php#L493-L517 |
eveseat/web | src/Acl/AccessChecker.php | AccessChecker.hasRole | public function hasRole($role_name)
{
if ($this->hasSuperUser())
return true;
foreach ($this->group->roles as $role)
if ($role->title == $role_name)
return true;
return false;
} | php | public function hasRole($role_name)
{
if ($this->hasSuperUser())
return true;
foreach ($this->group->roles as $role)
if ($role->title == $role_name)
return true;
return false;
} | [
"public",
"function",
"hasRole",
"(",
"$",
"role_name",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"hasSuperUser",
"(",
")",
")",
"return",
"true",
";",
"foreach",
"(",
"$",
"this",
"->",
"group",
"->",
"roles",
"as",
"$",
"role",
")",
"if",
"(",
"$",... | Determine if the current user has a specific
role.
@param $role_name
@return bool | [
"Determine",
"if",
"the",
"current",
"user",
"has",
"a",
"specific",
"role",
"."
] | train | https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Acl/AccessChecker.php#L543-L555 |
eveseat/web | src/Http/Controllers/Configuration/AccessController.php | AccessController.newRole | public function newRole(Role $request)
{
$role = $this->addRole($request->input('title'));
return redirect()
->route('configuration.access.roles.edit', ['id' => $role->id])
->with('success', trans('web::seat.role_added'));
} | php | public function newRole(Role $request)
{
$role = $this->addRole($request->input('title'));
return redirect()
->route('configuration.access.roles.edit', ['id' => $role->id])
->with('success', trans('web::seat.role_added'));
} | [
"public",
"function",
"newRole",
"(",
"Role",
"$",
"request",
")",
"{",
"$",
"role",
"=",
"$",
"this",
"->",
"addRole",
"(",
"$",
"request",
"->",
"input",
"(",
"'title'",
")",
")",
";",
"return",
"redirect",
"(",
")",
"->",
"route",
"(",
"'configura... | @param \Seat\Web\Http\Validation\Role $request
@return mixed | [
"@param",
"\\",
"Seat",
"\\",
"Web",
"\\",
"Http",
"\\",
"Validation",
"\\",
"Role",
"$request"
] | train | https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Http/Controllers/Configuration/AccessController.php#L59-L67 |
eveseat/web | src/Http/Controllers/Configuration/AccessController.php | AccessController.editRole | public function editRole($role_id)
{
// Get the role. We don't get the full one
// as we need to mangle some of the data to
// arrays for easier processing in the view
$role = $this->getRole($role_id);
$role_permissions = $role->permissions()->get()->pluck('title')->toArray();
$role_affiliations = $role->affiliations();
$role_groups = $role->groups()->get()->pluck('id')->toArray();
$all_groups = $this->getAllGroups();
$all_characters = $this->getAllCharacters();
$all_corporations = $this->getAllCorporations();
return view(
'web::configuration.access.edit',
compact(
'role', 'role_permissions', 'role_groups', 'all_groups',
'role_affiliations', 'all_characters', 'all_corporations'
));
} | php | public function editRole($role_id)
{
// Get the role. We don't get the full one
// as we need to mangle some of the data to
// arrays for easier processing in the view
$role = $this->getRole($role_id);
$role_permissions = $role->permissions()->get()->pluck('title')->toArray();
$role_affiliations = $role->affiliations();
$role_groups = $role->groups()->get()->pluck('id')->toArray();
$all_groups = $this->getAllGroups();
$all_characters = $this->getAllCharacters();
$all_corporations = $this->getAllCorporations();
return view(
'web::configuration.access.edit',
compact(
'role', 'role_permissions', 'role_groups', 'all_groups',
'role_affiliations', 'all_characters', 'all_corporations'
));
} | [
"public",
"function",
"editRole",
"(",
"$",
"role_id",
")",
"{",
"// Get the role. We don't get the full one",
"// as we need to mangle some of the data to",
"// arrays for easier processing in the view",
"$",
"role",
"=",
"$",
"this",
"->",
"getRole",
"(",
"$",
"role_id",
... | @param $role_id
@return \Illuminate\View\View | [
"@param",
"$role_id"
] | train | https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Http/Controllers/Configuration/AccessController.php#L88-L109 |
eveseat/web | src/Http/Controllers/Configuration/AccessController.php | AccessController.grantPermissions | public function grantPermissions(RolePermission $request)
{
$this->giveRolePermissions(
$request->input('role_id'),
$request->input('permissions'),
$request->input('inverse') ? true : false);
return redirect()->back()
->with('success', trans('web::seat.permissions_granted'));
} | php | public function grantPermissions(RolePermission $request)
{
$this->giveRolePermissions(
$request->input('role_id'),
$request->input('permissions'),
$request->input('inverse') ? true : false);
return redirect()->back()
->with('success', trans('web::seat.permissions_granted'));
} | [
"public",
"function",
"grantPermissions",
"(",
"RolePermission",
"$",
"request",
")",
"{",
"$",
"this",
"->",
"giveRolePermissions",
"(",
"$",
"request",
"->",
"input",
"(",
"'role_id'",
")",
",",
"$",
"request",
"->",
"input",
"(",
"'permissions'",
")",
","... | @param \Seat\Web\Http\Validation\RolePermission $request
@return mixed | [
"@param",
"\\",
"Seat",
"\\",
"Web",
"\\",
"Http",
"\\",
"Validation",
"\\",
"RolePermission",
"$request"
] | train | https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Http/Controllers/Configuration/AccessController.php#L116-L126 |
eveseat/web | src/Http/Controllers/Configuration/AccessController.php | AccessController.removePermissions | public function removePermissions($role_id, $permission_id)
{
$this->removePermissionFromRole($permission_id, $role_id);
return redirect()->back()
->with('success', trans('web::seat.permission_revoked'));
} | php | public function removePermissions($role_id, $permission_id)
{
$this->removePermissionFromRole($permission_id, $role_id);
return redirect()->back()
->with('success', trans('web::seat.permission_revoked'));
} | [
"public",
"function",
"removePermissions",
"(",
"$",
"role_id",
",",
"$",
"permission_id",
")",
"{",
"$",
"this",
"->",
"removePermissionFromRole",
"(",
"$",
"permission_id",
",",
"$",
"role_id",
")",
";",
"return",
"redirect",
"(",
")",
"->",
"back",
"(",
... | @param $role_id
@param $permission_id
@return mixed | [
"@param",
"$role_id",
"@param",
"$permission_id"
] | train | https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Http/Controllers/Configuration/AccessController.php#L134-L141 |
eveseat/web | src/Http/Controllers/Configuration/AccessController.php | AccessController.addGroups | public function addGroups(RoleGroup $request)
{
$this->giveGroupsRole(
$request->input('groups'), $request->input('role_id'));
return redirect()->back()
->with('success', trans('web::seat.user_added'));
} | php | public function addGroups(RoleGroup $request)
{
$this->giveGroupsRole(
$request->input('groups'), $request->input('role_id'));
return redirect()->back()
->with('success', trans('web::seat.user_added'));
} | [
"public",
"function",
"addGroups",
"(",
"RoleGroup",
"$",
"request",
")",
"{",
"$",
"this",
"->",
"giveGroupsRole",
"(",
"$",
"request",
"->",
"input",
"(",
"'groups'",
")",
",",
"$",
"request",
"->",
"input",
"(",
"'role_id'",
")",
")",
";",
"return",
... | @param \Seat\Web\Http\Validation\RoleGroup $request
@return mixed | [
"@param",
"\\",
"Seat",
"\\",
"Web",
"\\",
"Http",
"\\",
"Validation",
"\\",
"RoleGroup",
"$request"
] | train | https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Http/Controllers/Configuration/AccessController.php#L148-L157 |
eveseat/web | src/Http/Controllers/Configuration/AccessController.php | AccessController.removeGroup | public function removeGroup($role_id, $group_id)
{
$this->removeGroupFromRole($group_id, $role_id);
return redirect()->back()
->with('success', trans('web::seat.user_removed'));
} | php | public function removeGroup($role_id, $group_id)
{
$this->removeGroupFromRole($group_id, $role_id);
return redirect()->back()
->with('success', trans('web::seat.user_removed'));
} | [
"public",
"function",
"removeGroup",
"(",
"$",
"role_id",
",",
"$",
"group_id",
")",
"{",
"$",
"this",
"->",
"removeGroupFromRole",
"(",
"$",
"group_id",
",",
"$",
"role_id",
")",
";",
"return",
"redirect",
"(",
")",
"->",
"back",
"(",
")",
"->",
"with... | @param $role_id
@param $group_id
@return mixed | [
"@param",
"$role_id",
"@param",
"$group_id"
] | train | https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Http/Controllers/Configuration/AccessController.php#L165-L172 |
eveseat/web | src/Http/Controllers/Configuration/AccessController.php | AccessController.addAffiliations | public function addAffiliations(RoleAffilliation $request)
{
if ($request->input('corporations'))
$this->giveRoleCorporationAffiliations(
$request->input('role_id'),
$request->input('corporations'),
$request->input('inverse') ? true : false);
if ($request->input('characters'))
$this->giveRoleCharacterAffiliations(
$request->input('role_id'),
$request->input('characters'),
$request->input('inverse') ? true : false);
return redirect()->back()
->with('success', 'Affiliations were added to this role');
} | php | public function addAffiliations(RoleAffilliation $request)
{
if ($request->input('corporations'))
$this->giveRoleCorporationAffiliations(
$request->input('role_id'),
$request->input('corporations'),
$request->input('inverse') ? true : false);
if ($request->input('characters'))
$this->giveRoleCharacterAffiliations(
$request->input('role_id'),
$request->input('characters'),
$request->input('inverse') ? true : false);
return redirect()->back()
->with('success', 'Affiliations were added to this role');
} | [
"public",
"function",
"addAffiliations",
"(",
"RoleAffilliation",
"$",
"request",
")",
"{",
"if",
"(",
"$",
"request",
"->",
"input",
"(",
"'corporations'",
")",
")",
"$",
"this",
"->",
"giveRoleCorporationAffiliations",
"(",
"$",
"request",
"->",
"input",
"("... | @param \Seat\Web\Http\Validation\RoleAffilliation $request
@return mixed | [
"@param",
"\\",
"Seat",
"\\",
"Web",
"\\",
"Http",
"\\",
"Validation",
"\\",
"RoleAffilliation",
"$request"
] | train | https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Http/Controllers/Configuration/AccessController.php#L179-L196 |
eveseat/web | src/Http/Controllers/Configuration/AccessController.php | AccessController.removeAffiliation | public function removeAffiliation($role_id, $affiliation_id)
{
$this->removeAffiliationFromRole($role_id, $affiliation_id);
return redirect()->back()
->with('success', trans('web::seat.affiliation_removed'));
} | php | public function removeAffiliation($role_id, $affiliation_id)
{
$this->removeAffiliationFromRole($role_id, $affiliation_id);
return redirect()->back()
->with('success', trans('web::seat.affiliation_removed'));
} | [
"public",
"function",
"removeAffiliation",
"(",
"$",
"role_id",
",",
"$",
"affiliation_id",
")",
"{",
"$",
"this",
"->",
"removeAffiliationFromRole",
"(",
"$",
"role_id",
",",
"$",
"affiliation_id",
")",
";",
"return",
"redirect",
"(",
")",
"->",
"back",
"("... | @param $role_id
@param $affiliation_id
@return mixed | [
"@param",
"$role_id",
"@param",
"$affiliation_id"
] | train | https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Http/Controllers/Configuration/AccessController.php#L204-L211 |
eveseat/web | src/Http/Controllers/Character/FittingController.php | FittingController.getFittingItems | public function getFittingItems(int $character_id, int $fitting_id)
{
$fitting = $this->getCharacterFitting($character_id, $fitting_id);
$items = $this->getCharacterFittingItems($fitting_id);
return view('web::character.fittingitems', compact('fitting', 'items'));
} | php | public function getFittingItems(int $character_id, int $fitting_id)
{
$fitting = $this->getCharacterFitting($character_id, $fitting_id);
$items = $this->getCharacterFittingItems($fitting_id);
return view('web::character.fittingitems', compact('fitting', 'items'));
} | [
"public",
"function",
"getFittingItems",
"(",
"int",
"$",
"character_id",
",",
"int",
"$",
"fitting_id",
")",
"{",
"$",
"fitting",
"=",
"$",
"this",
"->",
"getCharacterFitting",
"(",
"$",
"character_id",
",",
"$",
"fitting_id",
")",
";",
"$",
"items",
"=",... | @param int $character_id
@param int $fitting_id
@return \Illuminate\Contracts\View\Factory|\Illuminate\View\View | [
"@param",
"int",
"$character_id",
"@param",
"int",
"$fitting_id"
] | train | https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Http/Controllers/Character/FittingController.php#L56-L63 |
eveseat/web | src/Http/Composers/CorporationLayout.php | CorporationLayout.compose | public function compose(View $view)
{
$corporation_info = CorporationInfo::find($this->request->corporation_id);
if (! is_null($corporation_info))
$view->with('corporation_name', $corporation_info->name);
} | php | public function compose(View $view)
{
$corporation_info = CorporationInfo::find($this->request->corporation_id);
if (! is_null($corporation_info))
$view->with('corporation_name', $corporation_info->name);
} | [
"public",
"function",
"compose",
"(",
"View",
"$",
"view",
")",
"{",
"$",
"corporation_info",
"=",
"CorporationInfo",
"::",
"find",
"(",
"$",
"this",
"->",
"request",
"->",
"corporation_id",
")",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"corporation_info"... | Bind Character Name to the view.
@param View $view | [
"Bind",
"Character",
"Name",
"to",
"the",
"view",
"."
] | train | https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Http/Composers/CorporationLayout.php#L48-L54 |
eveseat/web | src/Http/Controllers/Corporation/MarketController.php | MarketController.getMarketData | public function getMarketData(int $corporation_id)
{
$orders = $this->getCorporationMarketOrders($corporation_id, false);
return DataTables::of($orders)
->addColumn('bs', function ($row) {
return view('web::partials.marketbuysell', compact('row'));
})
->addColumn('vol', function ($row) {
if ($row->is_buy_order)
return number($row->volume_total, 0);
return number($row->volume_remain, 0) . ' / ' . number($row->volume_total, 0);
})
->editColumn('price', function ($row) {
return number($row->price);
})
->addColumn('price_total', function ($row) {
return number($row->price_total);
})
->editColumn('typeName', function ($row) {
return view('web::partials.markettype', compact('row'));
})
->editColumn('issued_by', function ($row) {
$character = CharacterInfo::find($row->issued_by) ?: $row->issued_by;
return view('web::partials.character', compact('character', 'character_id'));
})
->filterColumn('issued_by', function ($query, $keyword) {
$resolved_ids = UniverseName::where('name', 'like', '%' . $keyword . '%')
->get()
->map(function ($resolved_id) {
return $resolved_id->entity_id;
});
$character_info_ids = CharacterInfo::where('name', 'like', '%' . $keyword . '%')
->get()
->map(function ($character_info) {
return $character_info->character_id;
});
$query->whereIn('a.issued_by', array_merge($resolved_ids->toArray(), $character_info_ids->toArray()));
})
->rawColumns(['bs', 'vol', 'typeName', 'issued_by'])
->make(true);
} | php | public function getMarketData(int $corporation_id)
{
$orders = $this->getCorporationMarketOrders($corporation_id, false);
return DataTables::of($orders)
->addColumn('bs', function ($row) {
return view('web::partials.marketbuysell', compact('row'));
})
->addColumn('vol', function ($row) {
if ($row->is_buy_order)
return number($row->volume_total, 0);
return number($row->volume_remain, 0) . ' / ' . number($row->volume_total, 0);
})
->editColumn('price', function ($row) {
return number($row->price);
})
->addColumn('price_total', function ($row) {
return number($row->price_total);
})
->editColumn('typeName', function ($row) {
return view('web::partials.markettype', compact('row'));
})
->editColumn('issued_by', function ($row) {
$character = CharacterInfo::find($row->issued_by) ?: $row->issued_by;
return view('web::partials.character', compact('character', 'character_id'));
})
->filterColumn('issued_by', function ($query, $keyword) {
$resolved_ids = UniverseName::where('name', 'like', '%' . $keyword . '%')
->get()
->map(function ($resolved_id) {
return $resolved_id->entity_id;
});
$character_info_ids = CharacterInfo::where('name', 'like', '%' . $keyword . '%')
->get()
->map(function ($character_info) {
return $character_info->character_id;
});
$query->whereIn('a.issued_by', array_merge($resolved_ids->toArray(), $character_info_ids->toArray()));
})
->rawColumns(['bs', 'vol', 'typeName', 'issued_by'])
->make(true);
} | [
"public",
"function",
"getMarketData",
"(",
"int",
"$",
"corporation_id",
")",
"{",
"$",
"orders",
"=",
"$",
"this",
"->",
"getCorporationMarketOrders",
"(",
"$",
"corporation_id",
",",
"false",
")",
";",
"return",
"DataTables",
"::",
"of",
"(",
"$",
"orders... | @param int $corporation_id
@return mixed
@throws \Exception | [
"@param",
"int",
"$corporation_id"
] | train | https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Http/Controllers/Corporation/MarketController.php#L58-L112 |
eveseat/web | src/Http/Middleware/Requirements.php | Requirements.handle | public function handle($request, Closure $next)
{
// Get the status of all of the extensions
$requirements = collect(array_map(function ($extension) {
return [
'name' => $extension,
'loaded' => extension_loaded($extension),
];
}, self::$extensions))->sortBy('name');
// If there is an extension not loaded (aka false), then
// render a view with the information in it.
if (! $requirements->filter(function ($item) {
return $item['loaded'] === false;
})->isEmpty()
)
return response()->view('web::requirements.extentions', compact('requirements'));
// Check the PHP Version.
if (! version_compare(phpversion(), '5.5.14', '>='))
return view('web::requirements.phpversion');
// Everything ok \o/
return $next($request);
} | php | public function handle($request, Closure $next)
{
// Get the status of all of the extensions
$requirements = collect(array_map(function ($extension) {
return [
'name' => $extension,
'loaded' => extension_loaded($extension),
];
}, self::$extensions))->sortBy('name');
// If there is an extension not loaded (aka false), then
// render a view with the information in it.
if (! $requirements->filter(function ($item) {
return $item['loaded'] === false;
})->isEmpty()
)
return response()->view('web::requirements.extentions', compact('requirements'));
// Check the PHP Version.
if (! version_compare(phpversion(), '5.5.14', '>='))
return view('web::requirements.phpversion');
// Everything ok \o/
return $next($request);
} | [
"public",
"function",
"handle",
"(",
"$",
"request",
",",
"Closure",
"$",
"next",
")",
"{",
"// Get the status of all of the extensions",
"$",
"requirements",
"=",
"collect",
"(",
"array_map",
"(",
"function",
"(",
"$",
"extension",
")",
"{",
"return",
"[",
"'... | Handle an incoming request.
@param \Illuminate\Http\Request $request
@param \Closure $next
@return mixed | [
"Handle",
"an",
"incoming",
"request",
"."
] | train | https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Http/Middleware/Requirements.php#L50-L79 |
eveseat/web | src/Http/Validation/ProfileSettings.php | ProfileSettings.rules | public function rules()
{
$allowed_main_character_ids = auth()->user()->associatedCharacterIds()->implode(',');
$allowed_skins = implode(',', Profile::$options['skins']);
$allowed_languages = implode(',', array_map(function ($entry) {
return $entry['short'];
}, config('web.locale.languages')));
$allowed_sidebar = implode(',', Profile::$options['sidebar']);
$mail_threads = implode(',', Profile::$options['mail_threads']);
// Workaround if the thousands seperator is null to convert it
// to a space. We dont receive a space from the request as a
// result of the TrimStrings middleware. Thats ok.
if (is_null($this->request->get('thousand_seperator')))
$this->request->set('thousand_seperator', ' ');
return [
'main_character_id' => auth()->user()->name == 'admin' ? 'optional' : 'required|in:' . $allowed_main_character_ids,
'skin' => 'required|in:' . $allowed_skins,
'language' => 'required|in:' . $allowed_languages,
'sidebar' => 'required|in:' . $allowed_sidebar,
'mail_threads' => 'required|in:' . $mail_threads,
'thousand_seperator' => 'nullable|in:" ",",","."|size:1',
'decimal_seperator' => 'required|in:",","."|size:1',
'email_notifications' => 'required|in:yes,no',
];
} | php | public function rules()
{
$allowed_main_character_ids = auth()->user()->associatedCharacterIds()->implode(',');
$allowed_skins = implode(',', Profile::$options['skins']);
$allowed_languages = implode(',', array_map(function ($entry) {
return $entry['short'];
}, config('web.locale.languages')));
$allowed_sidebar = implode(',', Profile::$options['sidebar']);
$mail_threads = implode(',', Profile::$options['mail_threads']);
// Workaround if the thousands seperator is null to convert it
// to a space. We dont receive a space from the request as a
// result of the TrimStrings middleware. Thats ok.
if (is_null($this->request->get('thousand_seperator')))
$this->request->set('thousand_seperator', ' ');
return [
'main_character_id' => auth()->user()->name == 'admin' ? 'optional' : 'required|in:' . $allowed_main_character_ids,
'skin' => 'required|in:' . $allowed_skins,
'language' => 'required|in:' . $allowed_languages,
'sidebar' => 'required|in:' . $allowed_sidebar,
'mail_threads' => 'required|in:' . $mail_threads,
'thousand_seperator' => 'nullable|in:" ",",","."|size:1',
'decimal_seperator' => 'required|in:",","."|size:1',
'email_notifications' => 'required|in:yes,no',
];
} | [
"public",
"function",
"rules",
"(",
")",
"{",
"$",
"allowed_main_character_ids",
"=",
"auth",
"(",
")",
"->",
"user",
"(",
")",
"->",
"associatedCharacterIds",
"(",
")",
"->",
"implode",
"(",
"','",
")",
";",
"$",
"allowed_skins",
"=",
"implode",
"(",
"'... | Get the validation rules that apply to the request.
@return array | [
"Get",
"the",
"validation",
"rules",
"that",
"apply",
"to",
"the",
"request",
"."
] | train | https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Http/Validation/ProfileSettings.php#L46-L74 |
eveseat/web | src/Http/Middleware/Bouncer/KeyBouncer.php | KeyBouncer.handle | public function handle(Request $request, Closure $next, string $permission = null)
{
// Get the currently logged in user
$user = auth()->user();
// Having the permission / superuser here means
// your access is fine.
if ($user->has('apikey.' . $permission, false))
return $next($request);
// If we don't have the required permission, check
// if the current user owns the key.
if (in_array($request->key_id, $user->keys->pluck('key_id')->all()))
return $next($request);
$message = 'Request to ' . $request->path() . ' was ' .
'denied by the keybouncer. The permission required is ' .
'key.' . $permission . '.';
event('security.log', [$message, 'authorization']);
// Redirect away from the original request
return redirect()->route('auth.unauthorized');
} | php | public function handle(Request $request, Closure $next, string $permission = null)
{
// Get the currently logged in user
$user = auth()->user();
// Having the permission / superuser here means
// your access is fine.
if ($user->has('apikey.' . $permission, false))
return $next($request);
// If we don't have the required permission, check
// if the current user owns the key.
if (in_array($request->key_id, $user->keys->pluck('key_id')->all()))
return $next($request);
$message = 'Request to ' . $request->path() . ' was ' .
'denied by the keybouncer. The permission required is ' .
'key.' . $permission . '.';
event('security.log', [$message, 'authorization']);
// Redirect away from the original request
return redirect()->route('auth.unauthorized');
} | [
"public",
"function",
"handle",
"(",
"Request",
"$",
"request",
",",
"Closure",
"$",
"next",
",",
"string",
"$",
"permission",
"=",
"null",
")",
"{",
"// Get the currently logged in user",
"$",
"user",
"=",
"auth",
"(",
")",
"->",
"user",
"(",
")",
";",
... | Handle an incoming request.
This filter checks the required permissions or
key ownership for a API key.
@param \Illuminate\Http\Request $request
@param \Closure $next
@param string $permission
@return \Illuminate\Http\RedirectResponse | [
"Handle",
"an",
"incoming",
"request",
"."
] | train | https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Http/Middleware/Bouncer/KeyBouncer.php#L46-L71 |
eveseat/web | src/Http/Controllers/Corporation/CorporationsController.php | CorporationsController.deleteCorporation | public function deleteCorporation(int $corporation_id)
{
CorporationInfo::find($corporation_id)->delete();
return redirect()->back()->with(
'success', 'Corporation deleted!'
);
} | php | public function deleteCorporation(int $corporation_id)
{
CorporationInfo::find($corporation_id)->delete();
return redirect()->back()->with(
'success', 'Corporation deleted!'
);
} | [
"public",
"function",
"deleteCorporation",
"(",
"int",
"$",
"corporation_id",
")",
"{",
"CorporationInfo",
"::",
"find",
"(",
"$",
"corporation_id",
")",
"->",
"delete",
"(",
")",
";",
"return",
"redirect",
"(",
")",
"->",
"back",
"(",
")",
"->",
"with",
... | @param int $corporation_id
@return \Illuminate\Http\RedirectResponse | [
"@param",
"int",
"$corporation_id"
] | train | https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Http/Controllers/Corporation/CorporationsController.php#L92-L100 |
eveseat/web | src/Http/Controllers/Character/AssetsController.php | AssetsController.getCharacterAssets | public function getCharacterAssets(int $character_id)
{
if (! request()->has('all_linked_characters'))
return abort(500);
if (request('all_linked_characters') === 'false')
$character_ids = collect($character_id);
if (request('all_linked_characters') === 'true')
$character_ids = User::find($character_id)->group->users
->filter(function ($user) {
if (! $user->name === 'admin' || $user->id === 1)
return false;
return true;
})
->pluck('id');
$assets = $this->getCharacterAssetsBuilder($character_ids);
return DataTables::of($assets)
->editColumn('quantity', function ($row) {
if ($row->content->count() < 1)
return number($row->quantity, 0);
})
->editColumn('item', function ($row) {
return view('web::character.partials.asset-type', compact('row'));
})
->editColumn('volume', function ($row) {
return number_metric($row->quantity * optional($row->type)->volume ?? 0) . 'm³';
})
->addColumn('group', function ($row) {
if ($row->type)
return $row->type->group->groupName;
return 'Unknown';
})
->editColumn('content', function ($row) {
return view('web::character.partials.content', compact('row'));
})
->rawColumns(['item', 'volume', 'content'])
->make(true);
} | php | public function getCharacterAssets(int $character_id)
{
if (! request()->has('all_linked_characters'))
return abort(500);
if (request('all_linked_characters') === 'false')
$character_ids = collect($character_id);
if (request('all_linked_characters') === 'true')
$character_ids = User::find($character_id)->group->users
->filter(function ($user) {
if (! $user->name === 'admin' || $user->id === 1)
return false;
return true;
})
->pluck('id');
$assets = $this->getCharacterAssetsBuilder($character_ids);
return DataTables::of($assets)
->editColumn('quantity', function ($row) {
if ($row->content->count() < 1)
return number($row->quantity, 0);
})
->editColumn('item', function ($row) {
return view('web::character.partials.asset-type', compact('row'));
})
->editColumn('volume', function ($row) {
return number_metric($row->quantity * optional($row->type)->volume ?? 0) . 'm³';
})
->addColumn('group', function ($row) {
if ($row->type)
return $row->type->group->groupName;
return 'Unknown';
})
->editColumn('content', function ($row) {
return view('web::character.partials.content', compact('row'));
})
->rawColumns(['item', 'volume', 'content'])
->make(true);
} | [
"public",
"function",
"getCharacterAssets",
"(",
"int",
"$",
"character_id",
")",
"{",
"if",
"(",
"!",
"request",
"(",
")",
"->",
"has",
"(",
"'all_linked_characters'",
")",
")",
"return",
"abort",
"(",
"500",
")",
";",
"if",
"(",
"request",
"(",
"'all_l... | @param int $character_id
@return mixed
@throws \Exception | [
"@param",
"int",
"$character_id"
] | train | https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Http/Controllers/Character/AssetsController.php#L55-L97 |
eveseat/web | src/Http/Validation/RolePermission.php | RolePermission.rules | public function rules()
{
// Start with a default rules array for the
// role_id check
$rules = [
'role_id' => 'required|exists:roles,id',
'inverse' => 'nullable|in:on',
];
// Ensure that the permissions is set, if not,
// complain that it is actually required
if (! $this->request->get('permissions')) {
$rules['permissions'] = 'required';
return $rules;
}
// Add each permission in the multi select dynamically
foreach ($this->request->get('permissions') as $key => $value)
// Permissions can be written in . notation. If this is
// the case, we need to build the filter so that the
// actual value we got from the form request exists in the
// 'in' constraint on the validation rules. We do this by
// running array map on the categorized permissions and
// appending the category to the rule to match the value
// the form request would have sent.
if (str_contains($value, '.')) {
$category = explode('.', $value)[0];
$rules['permissions.' . $key] = 'required|in:' .
implode(',', array_filter(
array_map(function ($web_perm) use ($category) {
return $category . '.' . $web_perm;
}, config('web.permissions.' . $category))));
} else {
// If the string does not have . notation,
// then we can assume its flat and no category needs
// appending to the permission name
$rules['permissions.' . $key] = 'required|in:' .
implode(',', array_filter(
array_map(function ($web_perm) {
// If the permission is an array, then
// we just return null
if (is_array($web_perm))
return null;
return $web_perm;
}, config('web.permissions'))));
}
return $rules;
} | php | public function rules()
{
// Start with a default rules array for the
// role_id check
$rules = [
'role_id' => 'required|exists:roles,id',
'inverse' => 'nullable|in:on',
];
// Ensure that the permissions is set, if not,
// complain that it is actually required
if (! $this->request->get('permissions')) {
$rules['permissions'] = 'required';
return $rules;
}
// Add each permission in the multi select dynamically
foreach ($this->request->get('permissions') as $key => $value)
// Permissions can be written in . notation. If this is
// the case, we need to build the filter so that the
// actual value we got from the form request exists in the
// 'in' constraint on the validation rules. We do this by
// running array map on the categorized permissions and
// appending the category to the rule to match the value
// the form request would have sent.
if (str_contains($value, '.')) {
$category = explode('.', $value)[0];
$rules['permissions.' . $key] = 'required|in:' .
implode(',', array_filter(
array_map(function ($web_perm) use ($category) {
return $category . '.' . $web_perm;
}, config('web.permissions.' . $category))));
} else {
// If the string does not have . notation,
// then we can assume its flat and no category needs
// appending to the permission name
$rules['permissions.' . $key] = 'required|in:' .
implode(',', array_filter(
array_map(function ($web_perm) {
// If the permission is an array, then
// we just return null
if (is_array($web_perm))
return null;
return $web_perm;
}, config('web.permissions'))));
}
return $rules;
} | [
"public",
"function",
"rules",
"(",
")",
"{",
"// Start with a default rules array for the",
"// role_id check",
"$",
"rules",
"=",
"[",
"'role_id'",
"=>",
"'required|exists:roles,id'",
",",
"'inverse'",
"=>",
"'nullable|in:on'",
",",
"]",
";",
"// Ensure that the permiss... | Get the validation rules that apply to the request.
@return array | [
"Get",
"the",
"validation",
"rules",
"that",
"apply",
"to",
"the",
"request",
"."
] | train | https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Http/Validation/RolePermission.php#L49-L111 |
eveseat/web | src/Acl/AccessManager.php | AccessManager.getCompleteRole | public function getCompleteRole(int $role_id = null)
{
$roles = RoleModel::with('permissions', 'groups', 'affiliations');
if (! is_null($role_id)) {
$roles = $roles->where('id', $role_id)->first();
if (! $roles) abort(404);
return $roles;
}
return $roles->get();
} | php | public function getCompleteRole(int $role_id = null)
{
$roles = RoleModel::with('permissions', 'groups', 'affiliations');
if (! is_null($role_id)) {
$roles = $roles->where('id', $role_id)->first();
if (! $roles) abort(404);
return $roles;
}
return $roles->get();
} | [
"public",
"function",
"getCompleteRole",
"(",
"int",
"$",
"role_id",
"=",
"null",
")",
"{",
"$",
"roles",
"=",
"RoleModel",
"::",
"with",
"(",
"'permissions'",
",",
"'groups'",
",",
"'affiliations'",
")",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"role_i... | Return everything related to the Role
with eager loading.
@param int $role_id
@return \Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Eloquent\Collection | [
"Return",
"everything",
"related",
"to",
"the",
"Role",
"with",
"eager",
"loading",
"."
] | train | https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Acl/AccessManager.php#L46-L61 |
eveseat/web | src/Acl/AccessManager.php | AccessManager.removeRoleByTitle | public function removeRoleByTitle(string $title)
{
$role = RoleModel::where('title', $title)->first();
$this->removeRole($role->id);
} | php | public function removeRoleByTitle(string $title)
{
$role = RoleModel::where('title', $title)->first();
$this->removeRole($role->id);
} | [
"public",
"function",
"removeRoleByTitle",
"(",
"string",
"$",
"title",
")",
"{",
"$",
"role",
"=",
"RoleModel",
"::",
"where",
"(",
"'title'",
",",
"$",
"title",
")",
"->",
"first",
"(",
")",
";",
"$",
"this",
"->",
"removeRole",
"(",
"$",
"role",
"... | Remove a role by title.
@param string $title | [
"Remove",
"a",
"role",
"by",
"title",
"."
] | train | https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Acl/AccessManager.php#L84-L89 |
eveseat/web | src/Acl/AccessManager.php | AccessManager.giveRolePermissions | public function giveRolePermissions($role_id, array $permissions, bool $inverse)
{
foreach ($permissions as $key => $permission_name)
$this->giveRolePermission($role_id, $permission_name, $inverse);
} | php | public function giveRolePermissions($role_id, array $permissions, bool $inverse)
{
foreach ($permissions as $key => $permission_name)
$this->giveRolePermission($role_id, $permission_name, $inverse);
} | [
"public",
"function",
"giveRolePermissions",
"(",
"$",
"role_id",
",",
"array",
"$",
"permissions",
",",
"bool",
"$",
"inverse",
")",
"{",
"foreach",
"(",
"$",
"permissions",
"as",
"$",
"key",
"=>",
"$",
"permission_name",
")",
"$",
"this",
"->",
"giveRole... | Give a role many permissions.
@param $role_id
@param array $permissions
@param bool $inverse | [
"Give",
"a",
"role",
"many",
"permissions",
"."
] | train | https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Acl/AccessManager.php#L111-L117 |
eveseat/web | src/Acl/AccessManager.php | AccessManager.giveRolePermission | public function giveRolePermission(int $role_id, string $permission_name, bool $inverse)
{
$role = $this->getRole($role_id);
$permission = PermissionModel::firstOrNew([
'title' => $permission_name,
]);
// If the role does not already have the permission
// add it. We will also apply the inverse rule as an
// extra attribute on save()
if (! $role->permissions->contains($permission->id))
$role->permissions()->save($permission, ['not' => $inverse]);
} | php | public function giveRolePermission(int $role_id, string $permission_name, bool $inverse)
{
$role = $this->getRole($role_id);
$permission = PermissionModel::firstOrNew([
'title' => $permission_name,
]);
// If the role does not already have the permission
// add it. We will also apply the inverse rule as an
// extra attribute on save()
if (! $role->permissions->contains($permission->id))
$role->permissions()->save($permission, ['not' => $inverse]);
} | [
"public",
"function",
"giveRolePermission",
"(",
"int",
"$",
"role_id",
",",
"string",
"$",
"permission_name",
",",
"bool",
"$",
"inverse",
")",
"{",
"$",
"role",
"=",
"$",
"this",
"->",
"getRole",
"(",
"$",
"role_id",
")",
";",
"$",
"permission",
"=",
... | Give a Role a permission.
@param int $role_id
@param string $permission_name
@param bool $inverse | [
"Give",
"a",
"Role",
"a",
"permission",
"."
] | train | https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Acl/AccessManager.php#L126-L141 |
eveseat/web | src/Acl/AccessManager.php | AccessManager.removePermissionFromRole | public function removePermissionFromRole(int $permission_id, int $role_id)
{
$role = $this->getRole($role_id);
$role->permissions()->detach($permission_id);
} | php | public function removePermissionFromRole(int $permission_id, int $role_id)
{
$role = $this->getRole($role_id);
$role->permissions()->detach($permission_id);
} | [
"public",
"function",
"removePermissionFromRole",
"(",
"int",
"$",
"permission_id",
",",
"int",
"$",
"role_id",
")",
"{",
"$",
"role",
"=",
"$",
"this",
"->",
"getRole",
"(",
"$",
"role_id",
")",
";",
"$",
"role",
"->",
"permissions",
"(",
")",
"->",
"... | Remove a permission from a Role.
@param int $permission_id
@param int $role_id | [
"Remove",
"a",
"permission",
"from",
"a",
"Role",
"."
] | train | https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Acl/AccessManager.php#L162-L168 |
eveseat/web | src/Acl/AccessManager.php | AccessManager.giveGroupsRole | public function giveGroupsRole(array $group_ids, int $role_id)
{
foreach ($group_ids as $group_id) {
$group = Group::where('id', $group_id)->first();
$this->giveGroupRole($group->id, $role_id);
}
} | php | public function giveGroupsRole(array $group_ids, int $role_id)
{
foreach ($group_ids as $group_id) {
$group = Group::where('id', $group_id)->first();
$this->giveGroupRole($group->id, $role_id);
}
} | [
"public",
"function",
"giveGroupsRole",
"(",
"array",
"$",
"group_ids",
",",
"int",
"$",
"role_id",
")",
"{",
"foreach",
"(",
"$",
"group_ids",
"as",
"$",
"group_id",
")",
"{",
"$",
"group",
"=",
"Group",
"::",
"where",
"(",
"'id'",
",",
"$",
"group_id... | Give an array of group_ids a role.
@param array $group_ids
@param int $role_id | [
"Give",
"an",
"array",
"of",
"group_ids",
"a",
"role",
"."
] | train | https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Acl/AccessManager.php#L176-L184 |
eveseat/web | src/Acl/AccessManager.php | AccessManager.giveGroupRole | public function giveGroupRole(int $group_id, int $role_id)
{
$group = Group::find($group_id);
$role = RoleModel::firstOrNew(['id' => $role_id]);
// If the role does not already have the group add it.
if (! $role->groups->contains($group_id)) {
$role->groups()->save($group);
event(new UserGroupRoleAdded($group_id, $role));
}
} | php | public function giveGroupRole(int $group_id, int $role_id)
{
$group = Group::find($group_id);
$role = RoleModel::firstOrNew(['id' => $role_id]);
// If the role does not already have the group add it.
if (! $role->groups->contains($group_id)) {
$role->groups()->save($group);
event(new UserGroupRoleAdded($group_id, $role));
}
} | [
"public",
"function",
"giveGroupRole",
"(",
"int",
"$",
"group_id",
",",
"int",
"$",
"role_id",
")",
"{",
"$",
"group",
"=",
"Group",
"::",
"find",
"(",
"$",
"group_id",
")",
";",
"$",
"role",
"=",
"RoleModel",
"::",
"firstOrNew",
"(",
"[",
"'id'",
"... | Give a group a Role.
@param int $group_id
@param int $role_id | [
"Give",
"a",
"group",
"a",
"Role",
"."
] | train | https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Acl/AccessManager.php#L192-L203 |
eveseat/web | src/Acl/AccessManager.php | AccessManager.removeGroupFromRole | public function removeGroupFromRole(int $group_id, int $role_id)
{
$role = $this->getRole($role_id);
if ($role->groups()->detach($group_id) > 0)
event(new UserGroupRoleRemoved($group_id, $role));
} | php | public function removeGroupFromRole(int $group_id, int $role_id)
{
$role = $this->getRole($role_id);
if ($role->groups()->detach($group_id) > 0)
event(new UserGroupRoleRemoved($group_id, $role));
} | [
"public",
"function",
"removeGroupFromRole",
"(",
"int",
"$",
"group_id",
",",
"int",
"$",
"role_id",
")",
"{",
"$",
"role",
"=",
"$",
"this",
"->",
"getRole",
"(",
"$",
"role_id",
")",
";",
"if",
"(",
"$",
"role",
"->",
"groups",
"(",
")",
"->",
"... | Remove a group from a role.
@param int $group_id
@param int $role_id | [
"Remove",
"a",
"group",
"from",
"a",
"role",
"."
] | train | https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Acl/AccessManager.php#L211-L218 |
eveseat/web | src/Http/Controllers/Character/MiningLedgerController.php | MiningLedgerController.getDetailedLedger | public function getDetailedLedger(int $character_id, $date, int $system_id, int $type_id): JsonResponse
{
if (! request()->has('all_linked_characters'))
return abort(500);
$character_ids = collect($character_id);
$entries = $this->getCharacterLedger($character_ids)
->addSelect('time', 'quantity')
->where('character_minings.date', $date)
->where('solar_system_id', $system_id)
->where('character_minings.type_id', $type_id)
->get();
return DataTables::of($entries)
->removeColumn('solar_system_id')
->removeColumn('date')
->removeColumn('type_id')
->removeColumn('average_price')
->removeColumn('type')
->editColumn('quantity', function ($row) {
return view('web::partials.miningquantity', compact('row'));
})
->editColumn('volume', function ($row) {
return view('web::partials.miningvolume', compact('row'));
})
->addColumn('value', function ($row) {
$value = $row->average_price * $row->quantity;
if(empty($value))
// If historical price has not been set, get historical price.
$value = $this->getHistoricalPrice($row->type_id, $row->date)->average_price;
return view('web::partials.miningvalue', compact('value'));
})
->rawColumns(['value', 'volume'])
->make(true);
} | php | public function getDetailedLedger(int $character_id, $date, int $system_id, int $type_id): JsonResponse
{
if (! request()->has('all_linked_characters'))
return abort(500);
$character_ids = collect($character_id);
$entries = $this->getCharacterLedger($character_ids)
->addSelect('time', 'quantity')
->where('character_minings.date', $date)
->where('solar_system_id', $system_id)
->where('character_minings.type_id', $type_id)
->get();
return DataTables::of($entries)
->removeColumn('solar_system_id')
->removeColumn('date')
->removeColumn('type_id')
->removeColumn('average_price')
->removeColumn('type')
->editColumn('quantity', function ($row) {
return view('web::partials.miningquantity', compact('row'));
})
->editColumn('volume', function ($row) {
return view('web::partials.miningvolume', compact('row'));
})
->addColumn('value', function ($row) {
$value = $row->average_price * $row->quantity;
if(empty($value))
// If historical price has not been set, get historical price.
$value = $this->getHistoricalPrice($row->type_id, $row->date)->average_price;
return view('web::partials.miningvalue', compact('value'));
})
->rawColumns(['value', 'volume'])
->make(true);
} | [
"public",
"function",
"getDetailedLedger",
"(",
"int",
"$",
"character_id",
",",
"$",
"date",
",",
"int",
"$",
"system_id",
",",
"int",
"$",
"type_id",
")",
":",
"JsonResponse",
"{",
"if",
"(",
"!",
"request",
"(",
")",
"->",
"has",
"(",
"'all_linked_cha... | @param int $character_id
@param $date
@param int $system_id
@param int $type_id
@return \Illuminate\Http\JsonResponse
@throws \Exception | [
"@param",
"int",
"$character_id",
"@param",
"$date",
"@param",
"int",
"$system_id",
"@param",
"int",
"$type_id"
] | train | https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Http/Controllers/Character/MiningLedgerController.php#L115-L155 |
eveseat/web | src/Models/Acl/Role.php | Role.delete | public function delete()
{
// Remove the Role from users, permissions
// and affiliations that it had
$this->groups()->detach();
$this->permissions()->detach();
$this->affiliations()->detach();
return parent::delete();
} | php | public function delete()
{
// Remove the Role from users, permissions
// and affiliations that it had
$this->groups()->detach();
$this->permissions()->detach();
$this->affiliations()->detach();
return parent::delete();
} | [
"public",
"function",
"delete",
"(",
")",
"{",
"// Remove the Role from users, permissions",
"// and affiliations that it had",
"$",
"this",
"->",
"groups",
"(",
")",
"->",
"detach",
"(",
")",
";",
"$",
"this",
"->",
"permissions",
"(",
")",
"->",
"detach",
"(",... | Make sure we cleanup on delete.
@return bool|null
@throws \Exception | [
"Make",
"sure",
"we",
"cleanup",
"on",
"delete",
"."
] | train | https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Models/Acl/Role.php#L50-L60 |
eveseat/web | src/Http/Controllers/Character/MarketController.php | MarketController.getMarketData | public function getMarketData(int $character_id)
{
if (! request()->has('all_linked_characters'))
return abort(500);
if (request('all_linked_characters') === 'false')
$character_ids = collect($character_id);
$user_group = User::find($character_id)->group->users
->filter(function ($user) {
return $user->name !== 'admin' && $user->id !== 1;
})
->pluck('id');
if (request('all_linked_characters') === 'true')
$character_ids = $user_group;
$orders = $this->getCharacterMarketOrders($character_ids);
return DataTables::of($orders)
->addColumn('bs', function ($row) {
return view('web::partials.marketbuysell', compact('row'));
})
->addColumn('vol', function ($row) {
if ($row->is_buy_order)
return number($row->volume_total, 0);
return number($row->volume_remain, 0) . ' / ' . number($row->volume_total, 0);
})
->editColumn('price', function ($row) {
return number($row->price);
})
->addColumn('total', function ($row) {
return number($row->price * $row->volume_total);
})
->editColumn('typeName', function ($row) {
return view('web::partials.markettype', compact('row'));
})
->rawColumns(['bs', 'typeName'])
->make(true);
} | php | public function getMarketData(int $character_id)
{
if (! request()->has('all_linked_characters'))
return abort(500);
if (request('all_linked_characters') === 'false')
$character_ids = collect($character_id);
$user_group = User::find($character_id)->group->users
->filter(function ($user) {
return $user->name !== 'admin' && $user->id !== 1;
})
->pluck('id');
if (request('all_linked_characters') === 'true')
$character_ids = $user_group;
$orders = $this->getCharacterMarketOrders($character_ids);
return DataTables::of($orders)
->addColumn('bs', function ($row) {
return view('web::partials.marketbuysell', compact('row'));
})
->addColumn('vol', function ($row) {
if ($row->is_buy_order)
return number($row->volume_total, 0);
return number($row->volume_remain, 0) . ' / ' . number($row->volume_total, 0);
})
->editColumn('price', function ($row) {
return number($row->price);
})
->addColumn('total', function ($row) {
return number($row->price * $row->volume_total);
})
->editColumn('typeName', function ($row) {
return view('web::partials.markettype', compact('row'));
})
->rawColumns(['bs', 'typeName'])
->make(true);
} | [
"public",
"function",
"getMarketData",
"(",
"int",
"$",
"character_id",
")",
"{",
"if",
"(",
"!",
"request",
"(",
")",
"->",
"has",
"(",
"'all_linked_characters'",
")",
")",
"return",
"abort",
"(",
"500",
")",
";",
"if",
"(",
"request",
"(",
"'all_linked... | @param int $character_id
@return mixed
@throws \Exception | [
"@param",
"int",
"$character_id"
] | train | https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Http/Controllers/Character/MarketController.php#L58-L105 |
eveseat/web | src/Http/Composers/CharacterMenu.php | CharacterMenu.compose | public function compose(View $view)
{
// This menu item declares the menu and
// sets it as an array of arrays.
$menu = [];
// Load any package menus
if (! empty(config('package.character.menu'))) {
foreach (config('package.character.menu') as $menu_data) {
$prepared_menu = $this->load_plugin_menu('character', $menu_data, true);
if (! is_null($prepared_menu))
array_push($menu, $prepared_menu);
}
}
// Sort the menu alphabetically.
$menu = array_values(array_sort($menu, function ($value) {
return $value['name'];
}));
$view->with('menu', $menu);
} | php | public function compose(View $view)
{
// This menu item declares the menu and
// sets it as an array of arrays.
$menu = [];
// Load any package menus
if (! empty(config('package.character.menu'))) {
foreach (config('package.character.menu') as $menu_data) {
$prepared_menu = $this->load_plugin_menu('character', $menu_data, true);
if (! is_null($prepared_menu))
array_push($menu, $prepared_menu);
}
}
// Sort the menu alphabetically.
$menu = array_values(array_sort($menu, function ($value) {
return $value['name'];
}));
$view->with('menu', $menu);
} | [
"public",
"function",
"compose",
"(",
"View",
"$",
"view",
")",
"{",
"// This menu item declares the menu and",
"// sets it as an array of arrays.",
"$",
"menu",
"=",
"[",
"]",
";",
"// Load any package menus",
"if",
"(",
"!",
"empty",
"(",
"config",
"(",
"'package.... | Bind data to the view.
@param View $view
@return void
@throws \Seat\Web\Exceptions\PackageMenuBuilderException | [
"Bind",
"data",
"to",
"the",
"view",
"."
] | train | https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Http/Composers/CharacterMenu.php#L62-L89 |
eveseat/web | src/Http/Middleware/RegistrationAllowed.php | RegistrationAllowed.handle | public function handle($request, Closure $next)
{
if (setting('registration', true) == 'no')
return redirect()->guest('auth/login')
->with('error', 'Registration is administratively disabled.');
return $next($request);
} | php | public function handle($request, Closure $next)
{
if (setting('registration', true) == 'no')
return redirect()->guest('auth/login')
->with('error', 'Registration is administratively disabled.');
return $next($request);
} | [
"public",
"function",
"handle",
"(",
"$",
"request",
",",
"Closure",
"$",
"next",
")",
"{",
"if",
"(",
"setting",
"(",
"'registration'",
",",
"true",
")",
"==",
"'no'",
")",
"return",
"redirect",
"(",
")",
"->",
"guest",
"(",
"'auth/login'",
")",
"->",... | Handle an incoming request.
@param \Illuminate\Http\Request $request
@param \Closure $next
@return mixed
@throws \Seat\Services\Exceptions\SettingException | [
"Handle",
"an",
"incoming",
"request",
"."
] | train | https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Http/Middleware/RegistrationAllowed.php#L38-L46 |
eveseat/web | src/Http/Controllers/Configuration/SeatController.php | SeatController.postUpdateSettings | public function postUpdateSettings(SeatSettings $request)
{
setting(['registration', $request->registration], true);
setting(['admin_contact', $request->admin_contact], true);
setting(['allow_tracking', $request->allow_tracking], true);
setting(['cleanup_data', $request->cleanup_data], true);
return redirect()->back()
->with('success', 'SeAT settings updated!');
} | php | public function postUpdateSettings(SeatSettings $request)
{
setting(['registration', $request->registration], true);
setting(['admin_contact', $request->admin_contact], true);
setting(['allow_tracking', $request->allow_tracking], true);
setting(['cleanup_data', $request->cleanup_data], true);
return redirect()->back()
->with('success', 'SeAT settings updated!');
} | [
"public",
"function",
"postUpdateSettings",
"(",
"SeatSettings",
"$",
"request",
")",
"{",
"setting",
"(",
"[",
"'registration'",
",",
"$",
"request",
"->",
"registration",
"]",
",",
"true",
")",
";",
"setting",
"(",
"[",
"'admin_contact'",
",",
"$",
"reques... | @param \Seat\Web\Http\Validation\SeatSettings $request
@return \Illuminate\Http\RedirectResponse
@throws \Seat\Services\Exceptions\SettingException | [
"@param",
"\\",
"Seat",
"\\",
"Web",
"\\",
"Http",
"\\",
"Validation",
"\\",
"SeatSettings",
"$request"
] | train | https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Http/Controllers/Configuration/SeatController.php#L69-L79 |
eveseat/web | src/Http/Controllers/Configuration/SeatController.php | SeatController.postPackagesCheck | public function postPackagesCheck(PackageVersionCheck $request)
{
// construct the packagist uri to its API
$packagist_url = sprintf('https://packagist.org/packages/%s/%s.json',
$request->input('vendor'), $request->input('package'));
// retrieve package meta-data
$response = (new Client())->request('GET', $packagist_url);
if ($response->getStatusCode() !== 200)
return response()->json([
'error' => 'An error occurred while attempting to retrieve the package version.',
], 500);
// convert the body into an array
$json_array = json_decode($response->getBody(), true);
// in case we miss either versions or package attribute, return an error as those attribute should contains version information
if (! array_key_exists('package', $json_array) || ! array_key_exists('versions', $json_array['package']))
return response()->json([
'error' => 'The returned metadata was not properly structured or does not contain the package.versions property',
], 500);
// extract published versions from packagist response
$versions = $json_array['package']['versions'];
foreach ($versions as $available_version => $metadata) {
// ignore any untagged versions
if (strpos($available_version, 'dev') !== false)
continue;
// return outdated on the first package which is greater than installed version
if (version_compare($request->input('version'), $metadata['version']) < 0)
return response()->json([
'error' => '',
'outdated' => true,
]);
}
// return up-to-date only once we loop over each available versions
return response()->json([
'error' => '',
'outdated' => false,
]);
} | php | public function postPackagesCheck(PackageVersionCheck $request)
{
// construct the packagist uri to its API
$packagist_url = sprintf('https://packagist.org/packages/%s/%s.json',
$request->input('vendor'), $request->input('package'));
// retrieve package meta-data
$response = (new Client())->request('GET', $packagist_url);
if ($response->getStatusCode() !== 200)
return response()->json([
'error' => 'An error occurred while attempting to retrieve the package version.',
], 500);
// convert the body into an array
$json_array = json_decode($response->getBody(), true);
// in case we miss either versions or package attribute, return an error as those attribute should contains version information
if (! array_key_exists('package', $json_array) || ! array_key_exists('versions', $json_array['package']))
return response()->json([
'error' => 'The returned metadata was not properly structured or does not contain the package.versions property',
], 500);
// extract published versions from packagist response
$versions = $json_array['package']['versions'];
foreach ($versions as $available_version => $metadata) {
// ignore any untagged versions
if (strpos($available_version, 'dev') !== false)
continue;
// return outdated on the first package which is greater than installed version
if (version_compare($request->input('version'), $metadata['version']) < 0)
return response()->json([
'error' => '',
'outdated' => true,
]);
}
// return up-to-date only once we loop over each available versions
return response()->json([
'error' => '',
'outdated' => false,
]);
} | [
"public",
"function",
"postPackagesCheck",
"(",
"PackageVersionCheck",
"$",
"request",
")",
"{",
"// construct the packagist uri to its API",
"$",
"packagist_url",
"=",
"sprintf",
"(",
"'https://packagist.org/packages/%s/%s.json'",
",",
"$",
"request",
"->",
"input",
"(",
... | Determine if a package is or not outdated.
@return \Illuminate\Http\JsonResponse
@throws \GuzzleHttp\Exception\GuzzleException | [
"Determine",
"if",
"a",
"package",
"is",
"or",
"not",
"outdated",
"."
] | train | https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Http/Controllers/Configuration/SeatController.php#L118-L162 |
eveseat/web | src/Http/Controllers/Configuration/SeatController.php | SeatController.postPackagesChangelog | public function postPackagesChangelog(PackageChangelog $request)
{
$changelog_uri = $request->input('uri');
$changelog_body = $request->input('body');
$changelog_tag = $request->input('tag');
if (! is_null($changelog_body) && ! is_null($changelog_tag))
return $this->getChangelogFromApi($changelog_uri, $changelog_body, $changelog_tag);
return $this->getChangelogFromFile($changelog_uri);
} | php | public function postPackagesChangelog(PackageChangelog $request)
{
$changelog_uri = $request->input('uri');
$changelog_body = $request->input('body');
$changelog_tag = $request->input('tag');
if (! is_null($changelog_body) && ! is_null($changelog_tag))
return $this->getChangelogFromApi($changelog_uri, $changelog_body, $changelog_tag);
return $this->getChangelogFromFile($changelog_uri);
} | [
"public",
"function",
"postPackagesChangelog",
"(",
"PackageChangelog",
"$",
"request",
")",
"{",
"$",
"changelog_uri",
"=",
"$",
"request",
"->",
"input",
"(",
"'uri'",
")",
";",
"$",
"changelog_body",
"=",
"$",
"request",
"->",
"input",
"(",
"'body'",
")",... | Return the changelog based on provided parameters.
@return mixed|string
@throws \GuzzleHttp\Exception\GuzzleException | [
"Return",
"the",
"changelog",
"based",
"on",
"provided",
"parameters",
"."
] | train | https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Http/Controllers/Configuration/SeatController.php#L170-L180 |
eveseat/web | src/Http/Controllers/Configuration/SeatController.php | SeatController.getPluginsMetadataList | private function getPluginsMetadataList(): stdClass
{
app()->loadDeferredProviders();
$providers = array_keys(app()->getLoadedProviders());
$packages = (object) [
'core' => collect(),
'plugins' => collect(),
];
foreach ($providers as $class) {
// attempt to retrieve the class from booted app
$provider = app()->getProvider($class);
if (is_null($provider))
continue;
// ensure the provider is a valid SeAT package
if (! is_a($provider, AbstractSeatPlugin::class))
continue;
// seed proper collection according to package vendor
$provider->getPackagistVendorName() === 'eveseat' ?
$packages->core->push($provider) : $packages->plugins->push($provider);
}
return $packages;
} | php | private function getPluginsMetadataList(): stdClass
{
app()->loadDeferredProviders();
$providers = array_keys(app()->getLoadedProviders());
$packages = (object) [
'core' => collect(),
'plugins' => collect(),
];
foreach ($providers as $class) {
// attempt to retrieve the class from booted app
$provider = app()->getProvider($class);
if (is_null($provider))
continue;
// ensure the provider is a valid SeAT package
if (! is_a($provider, AbstractSeatPlugin::class))
continue;
// seed proper collection according to package vendor
$provider->getPackagistVendorName() === 'eveseat' ?
$packages->core->push($provider) : $packages->plugins->push($provider);
}
return $packages;
} | [
"private",
"function",
"getPluginsMetadataList",
"(",
")",
":",
"stdClass",
"{",
"app",
"(",
")",
"->",
"loadDeferredProviders",
"(",
")",
";",
"$",
"providers",
"=",
"array_keys",
"(",
"app",
"(",
")",
"->",
"getLoadedProviders",
"(",
")",
")",
";",
"$",
... | Compute a list of provider class which are implementing SeAT package structure.
@return \stdClass | [
"Compute",
"a",
"list",
"of",
"provider",
"class",
"which",
"are",
"implementing",
"SeAT",
"package",
"structure",
"."
] | train | https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Http/Controllers/Configuration/SeatController.php#L187-L214 |
eveseat/web | src/Http/Controllers/Configuration/SeatController.php | SeatController.getChangelogFromApi | private function getChangelogFromApi(string $uri, string $body_attribute, string $tag_attribute): string
{
try {
return cache()->remember($this->getChangelogCacheKey($uri), 30, function () use ($uri, $body_attribute, $tag_attribute) {
$changelog = '';
// retrieve releases from provided API endpoint
$client = new Client();
$response = $client->request('GET', $uri);
// decode the response
$json_object = json_decode($response->getBody());
// spawn a new Markdown parser
$parser = new Parsedown();
$parser->setSafeMode(true);
// iterate over each release and build proper view
foreach ($json_object as $release) {
$changelog .= view('web::configuration.settings.partials.packages.changelog.header', [
'version' => $release->{$tag_attribute},
]);
$changelog .= view('web::configuration.settings.partials.packages.changelog.body', [
'body' => $parser->parse($release->{$body_attribute}),
]);
}
// return a rendered release list
return $changelog;
});
} catch (Exception $e) {
logger()->error('An error occurred while fetching changelog from API.', [
'code' => $e->getCode(),
'error' => $e->getMessage(),
'trace' => $e->getTrace(),
'uri' => $uri,
'attributes' => [
'body' => $body_attribute,
'tag' => $tag_attribute,
],
]);
}
return '';
} | php | private function getChangelogFromApi(string $uri, string $body_attribute, string $tag_attribute): string
{
try {
return cache()->remember($this->getChangelogCacheKey($uri), 30, function () use ($uri, $body_attribute, $tag_attribute) {
$changelog = '';
// retrieve releases from provided API endpoint
$client = new Client();
$response = $client->request('GET', $uri);
// decode the response
$json_object = json_decode($response->getBody());
// spawn a new Markdown parser
$parser = new Parsedown();
$parser->setSafeMode(true);
// iterate over each release and build proper view
foreach ($json_object as $release) {
$changelog .= view('web::configuration.settings.partials.packages.changelog.header', [
'version' => $release->{$tag_attribute},
]);
$changelog .= view('web::configuration.settings.partials.packages.changelog.body', [
'body' => $parser->parse($release->{$body_attribute}),
]);
}
// return a rendered release list
return $changelog;
});
} catch (Exception $e) {
logger()->error('An error occurred while fetching changelog from API.', [
'code' => $e->getCode(),
'error' => $e->getMessage(),
'trace' => $e->getTrace(),
'uri' => $uri,
'attributes' => [
'body' => $body_attribute,
'tag' => $tag_attribute,
],
]);
}
return '';
} | [
"private",
"function",
"getChangelogFromApi",
"(",
"string",
"$",
"uri",
",",
"string",
"$",
"body_attribute",
",",
"string",
"$",
"tag_attribute",
")",
":",
"string",
"{",
"try",
"{",
"return",
"cache",
"(",
")",
"->",
"remember",
"(",
"$",
"this",
"->",
... | Return a rendered changelog based on the provided release API endpoint.
@param string $uri
@param string $body_attribute
@param string $tag_attribute
@return string | [
"Return",
"a",
"rendered",
"changelog",
"based",
"on",
"the",
"provided",
"release",
"API",
"endpoint",
"."
] | train | https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Http/Controllers/Configuration/SeatController.php#L224-L269 |
eveseat/web | src/Http/Controllers/Configuration/SeatController.php | SeatController.getChangelogFromFile | private function getChangelogFromFile(string $uri)
{
try {
return cache()->remember($this->getChangelogCacheKey($uri), 30, function () use ($uri) {
// retrieve changelog from provided uri
$client = new Client();
$response = $client->request('GET', $uri);
// spawn a new Markdown parser
$parser = new Parsedown();
$parser->setSafeMode(true);
// return the parsed changelog
return $parser->parse($response->getBody());
});
} catch (Exception $e) {
logger()->error('An error occurred while fetching changelog from file.', [
'code' => $e->getCode(),
'error' => $e->getMessage(),
'trace' => $e->getTrace(),
'uri' => $uri,
]);
}
return '';
} | php | private function getChangelogFromFile(string $uri)
{
try {
return cache()->remember($this->getChangelogCacheKey($uri), 30, function () use ($uri) {
// retrieve changelog from provided uri
$client = new Client();
$response = $client->request('GET', $uri);
// spawn a new Markdown parser
$parser = new Parsedown();
$parser->setSafeMode(true);
// return the parsed changelog
return $parser->parse($response->getBody());
});
} catch (Exception $e) {
logger()->error('An error occurred while fetching changelog from file.', [
'code' => $e->getCode(),
'error' => $e->getMessage(),
'trace' => $e->getTrace(),
'uri' => $uri,
]);
}
return '';
} | [
"private",
"function",
"getChangelogFromFile",
"(",
"string",
"$",
"uri",
")",
"{",
"try",
"{",
"return",
"cache",
"(",
")",
"->",
"remember",
"(",
"$",
"this",
"->",
"getChangelogCacheKey",
"(",
"$",
"uri",
")",
",",
"30",
",",
"function",
"(",
")",
"... | Return parsed markdown from the file located at the provided URI.
@param string $uri
@return mixed
@throws \GuzzleHttp\Exception\GuzzleException | [
"Return",
"parsed",
"markdown",
"from",
"the",
"file",
"located",
"at",
"the",
"provided",
"URI",
"."
] | train | https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Http/Controllers/Configuration/SeatController.php#L278-L303 |
eveseat/web | src/Http/Controllers/Corporation/KillmailsController.php | KillmailsController.getKillmailsData | public function getKillmailsData(int $corporation_id)
{
$killmails = $this->getCorporationKillmails($corporation_id);
return DataTables::of($killmails)
->addColumn('victim', function ($row) {
if (is_null($row->killmail_victim))
return '';
$character_id = $row->character_id;
$character = CharacterInfo::find($row->killmail_victim->character_id) ?: $row->killmail_victim->character_id;
$corporation = CorporationInfo::find($row->killmail_victim->corporation_id) ?: $row->killmail_victim->corporation_id;
$view = view('web::partials.character', compact('character', 'character_id'))
. '</br>'
. view('web::partials.corporation', compact('corporation', 'character_id'));
$alliance = '';
if (! empty($row->killmail_victim->alliance_id)) {
$alliance = view('web::partials.alliance', ['alliance' => $row->killmail_victim->alliance_id, 'character_id' => $character_id]);
}
return $view . $alliance;
})
->addColumn('ship', function ($row) {
if (is_null($row->killmail_victim))
return '';
$ship_type = $row->killmail_victim->ship_type;
return view('web::partials.killmailtype', compact('ship_type'));
})
->addColumn('place', function ($row) {
if (is_null($row->killmail_detail))
return '';
$place = $row->killmail_detail->solar_system;
return view('web::partials.killmailsystem', compact('place'));
})
->addColumn('zkb', function ($row) {
return view('web::partials.killmailzkb', compact('row'));
})
->rawColumns(['victim', 'ship', 'place', 'zkb'])
->make(true);
} | php | public function getKillmailsData(int $corporation_id)
{
$killmails = $this->getCorporationKillmails($corporation_id);
return DataTables::of($killmails)
->addColumn('victim', function ($row) {
if (is_null($row->killmail_victim))
return '';
$character_id = $row->character_id;
$character = CharacterInfo::find($row->killmail_victim->character_id) ?: $row->killmail_victim->character_id;
$corporation = CorporationInfo::find($row->killmail_victim->corporation_id) ?: $row->killmail_victim->corporation_id;
$view = view('web::partials.character', compact('character', 'character_id'))
. '</br>'
. view('web::partials.corporation', compact('corporation', 'character_id'));
$alliance = '';
if (! empty($row->killmail_victim->alliance_id)) {
$alliance = view('web::partials.alliance', ['alliance' => $row->killmail_victim->alliance_id, 'character_id' => $character_id]);
}
return $view . $alliance;
})
->addColumn('ship', function ($row) {
if (is_null($row->killmail_victim))
return '';
$ship_type = $row->killmail_victim->ship_type;
return view('web::partials.killmailtype', compact('ship_type'));
})
->addColumn('place', function ($row) {
if (is_null($row->killmail_detail))
return '';
$place = $row->killmail_detail->solar_system;
return view('web::partials.killmailsystem', compact('place'));
})
->addColumn('zkb', function ($row) {
return view('web::partials.killmailzkb', compact('row'));
})
->rawColumns(['victim', 'ship', 'place', 'zkb'])
->make(true);
} | [
"public",
"function",
"getKillmailsData",
"(",
"int",
"$",
"corporation_id",
")",
"{",
"$",
"killmails",
"=",
"$",
"this",
"->",
"getCorporationKillmails",
"(",
"$",
"corporation_id",
")",
";",
"return",
"DataTables",
"::",
"of",
"(",
"$",
"killmails",
")",
... | @param int $corporation_id
@return mixed
@throws \Exception | [
"@param",
"int",
"$corporation_id"
] | train | https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Http/Controllers/Corporation/KillmailsController.php#L56-L109 |
eveseat/eseye | src/Containers/EsiResponse.php | EsiResponse.parseHeaders | private function parseHeaders(array $headers)
{
// Set the raw headers as we got from the constructor.
$this->raw_headers = $headers;
// flatten the headers array so that values are not arrays themselves
// but rather simple key value pairs.
$headers = array_map(function ($value) {
if (! is_array($value))
return $value;
return implode(';', $value);
}, $headers);
// Set the parsed headers.
$this->headers = $headers;
// Check for some header values that might be interesting
// such as the current error limit and number of pages
// available.
$this->hasHeader('X-Esi-Error-Limit-Remain') ?
$this->error_limit = (int) $this->getHeader('X-Esi-Error-Limit-Remain') : null;
$this->hasHeader('X-Pages') ? $this->pages = (int) $this->getHeader('X-Pages') : null;
} | php | private function parseHeaders(array $headers)
{
// Set the raw headers as we got from the constructor.
$this->raw_headers = $headers;
// flatten the headers array so that values are not arrays themselves
// but rather simple key value pairs.
$headers = array_map(function ($value) {
if (! is_array($value))
return $value;
return implode(';', $value);
}, $headers);
// Set the parsed headers.
$this->headers = $headers;
// Check for some header values that might be interesting
// such as the current error limit and number of pages
// available.
$this->hasHeader('X-Esi-Error-Limit-Remain') ?
$this->error_limit = (int) $this->getHeader('X-Esi-Error-Limit-Remain') : null;
$this->hasHeader('X-Pages') ? $this->pages = (int) $this->getHeader('X-Pages') : null;
} | [
"private",
"function",
"parseHeaders",
"(",
"array",
"$",
"headers",
")",
"{",
"// Set the raw headers as we got from the constructor.",
"$",
"this",
"->",
"raw_headers",
"=",
"$",
"headers",
";",
"// flatten the headers array so that values are not arrays themselves",
"// but ... | Parse an array of header key value pairs.
Interesting header values such as X-Esi-Error-Limit-Remain
and X-Pages are automatically mapped to properties in this
object.
@param array $headers | [
"Parse",
"an",
"array",
"of",
"header",
"key",
"value",
"pairs",
"."
] | train | https://github.com/eveseat/eseye/blob/55a90ccd49b548cb417ace32075a9188b8d9c1af/src/Containers/EsiResponse.php#L133-L159 |
eveseat/eseye | src/Containers/EsiResponse.php | EsiResponse.expired | public function expired(): bool
{
if ($this->expires()->lte(
carbon()->now($this->expires()->timezoneName))
)
return true;
return false;
} | php | public function expired(): bool
{
if ($this->expires()->lte(
carbon()->now($this->expires()->timezoneName))
)
return true;
return false;
} | [
"public",
"function",
"expired",
"(",
")",
":",
"bool",
"{",
"if",
"(",
"$",
"this",
"->",
"expires",
"(",
")",
"->",
"lte",
"(",
"carbon",
"(",
")",
"->",
"now",
"(",
"$",
"this",
"->",
"expires",
"(",
")",
"->",
"timezoneName",
")",
")",
")",
... | Determine if this containers data should be considered
expired.
Expiry is calculated by taking the expiry time and comparing
that to the local time. Before comparison though, the local
time is converted to the timezone in which the expiry time
is recorded. The resultant local time is then checked to
ensure that the expiry is not less than local time.
@return bool | [
"Determine",
"if",
"this",
"containers",
"data",
"should",
"be",
"considered",
"expired",
"."
] | train | https://github.com/eveseat/eseye/blob/55a90ccd49b548cb417ace32075a9188b8d9c1af/src/Containers/EsiResponse.php#L190-L199 |
eveseat/eseye | src/Fetchers/GuzzleFetcher.php | GuzzleFetcher.call | public function call(
string $method, string $uri, array $body, array $headers = []): EsiResponse
{
// If we have authentication data, add the
// Authorization header.
if ($this->getAuthentication())
$headers = array_merge($headers, [
'Authorization' => 'Bearer ' . $this->getToken(),
]);
return $this->httpRequest($method, $uri, $headers, $body);
} | php | public function call(
string $method, string $uri, array $body, array $headers = []): EsiResponse
{
// If we have authentication data, add the
// Authorization header.
if ($this->getAuthentication())
$headers = array_merge($headers, [
'Authorization' => 'Bearer ' . $this->getToken(),
]);
return $this->httpRequest($method, $uri, $headers, $body);
} | [
"public",
"function",
"call",
"(",
"string",
"$",
"method",
",",
"string",
"$",
"uri",
",",
"array",
"$",
"body",
",",
"array",
"$",
"headers",
"=",
"[",
"]",
")",
":",
"EsiResponse",
"{",
"// If we have authentication data, add the",
"// Authorization header.",... | @param string $method
@param string $uri
@param array $body
@param array $headers
@return mixed|\Seat\Eseye\Containers\EsiResponse
@throws \Seat\Eseye\Exceptions\InvalidAuthenticationException
@throws \Seat\Eseye\Exceptions\RequestFailedException
@throws \Seat\Eseye\Exceptions\InvalidContainerDataException | [
"@param",
"string",
"$method",
"@param",
"string",
"$uri",
"@param",
"array",
"$body",
"@param",
"array",
"$headers"
] | train | https://github.com/eveseat/eseye/blob/55a90ccd49b548cb417ace32075a9188b8d9c1af/src/Fetchers/GuzzleFetcher.php#L95-L107 |
eveseat/eseye | src/Fetchers/GuzzleFetcher.php | GuzzleFetcher.refreshToken | private function refreshToken()
{
// Make the post request for a new access_token
$response = $this->httpRequest('post',
$this->sso_base . '/token/?grant_type=refresh_token&refresh_token=' .
$this->authentication->refresh_token, [
'Authorization' => 'Basic ' . base64_encode(
$this->authentication->client_id . ':' . $this->authentication->secret),
]
);
// Get the current EsiAuth container
$authentication = $this->getAuthentication();
// Set the new authentication values from the request
$authentication->access_token = $response->access_token;
$authentication->refresh_token = $response->refresh_token;
$authentication->token_expires = carbon('now')
->addSeconds($response->expires_in);
// ... and update the container
$this->setAuthentication($authentication);
} | php | private function refreshToken()
{
// Make the post request for a new access_token
$response = $this->httpRequest('post',
$this->sso_base . '/token/?grant_type=refresh_token&refresh_token=' .
$this->authentication->refresh_token, [
'Authorization' => 'Basic ' . base64_encode(
$this->authentication->client_id . ':' . $this->authentication->secret),
]
);
// Get the current EsiAuth container
$authentication = $this->getAuthentication();
// Set the new authentication values from the request
$authentication->access_token = $response->access_token;
$authentication->refresh_token = $response->refresh_token;
$authentication->token_expires = carbon('now')
->addSeconds($response->expires_in);
// ... and update the container
$this->setAuthentication($authentication);
} | [
"private",
"function",
"refreshToken",
"(",
")",
"{",
"// Make the post request for a new access_token",
"$",
"response",
"=",
"$",
"this",
"->",
"httpRequest",
"(",
"'post'",
",",
"$",
"this",
"->",
"sso_base",
".",
"'/token/?grant_type=refresh_token&refresh_token='",
... | Refresh the Access token that we have in the EsiAccess container.
@throws \Seat\Eseye\Exceptions\RequestFailedException
@throws \Seat\Eseye\Exceptions\InvalidAuthenticationException
@throws \Seat\Eseye\Exceptions\InvalidContainerDataException | [
"Refresh",
"the",
"Access",
"token",
"that",
"we",
"have",
"in",
"the",
"EsiAccess",
"container",
"."
] | train | https://github.com/eveseat/eseye/blob/55a90ccd49b548cb417ace32075a9188b8d9c1af/src/Fetchers/GuzzleFetcher.php#L164-L187 |
eveseat/eseye | src/Fetchers/GuzzleFetcher.php | GuzzleFetcher.httpRequest | public function httpRequest(
string $method, string $uri, array $headers = [], array $body = []): EsiResponse
{
// Include some basic headers to those already passed in. Everything
// is considered to be Json.
$headers = array_merge($headers, [
'Accept' => 'application/json',
'Content-Type' => 'application/json',
'User-Agent' => 'Eseye/' . Eseye::VERSION . '/' .
Configuration::getInstance()->http_user_agent,
]);
// Add some debug logging and start measuring how long the request took.
$this->logger->debug('Making ' . $method . ' request to ' . $uri);
$start = microtime(true);
// Json encode the body if it has data, else just null it
if (count($body) > 0)
$body = json_encode($body);
else
$body = null;
try {
// Make the _actual_ request to ESI
$response = $this->getClient()->send(
new Request($method, $uri, $headers, $body));
} catch (ClientException | ServerException $e) {
// Log the event as failed
$this->logger->error('[http ' . $e->getResponse()->getStatusCode() . ', ' .
strtolower($e->getResponse()->getReasonPhrase()) . '] ' .
$method . ' -> ' . $this->stripRefreshTokenValue($uri) . ' [t/e: ' .
number_format(microtime(true) - $start, 2) . 's/' .
implode(' ', $e->getResponse()->getHeader('X-Esi-Error-Limit-Remain')) . ']'
);
// Grab the body from the StreamInterface intance.
$responseBody = $e->getResponse()->getBody()->getContents();
// For debugging purposes, log the response body
$this->logger->debug('Request for ' . $method . ' -> ' . $uri . ' failed. Response body was: ' .
$responseBody);
// Raise the exception that should be handled by the caller
throw new RequestFailedException($e, $this->makeEsiResponse(
$responseBody,
$e->getResponse()->getHeaders(),
'now',
$e->getResponse()->getStatusCode())
);
}
// Log the successful request.
$this->logger->log('[http ' . $response->getStatusCode() . ', ' .
strtolower($response->getReasonPhrase()) . '] ' .
$method . ' -> ' . $this->stripRefreshTokenValue($uri) . ' [t/e: ' .
number_format(microtime(true) - $start, 2) . 's/' .
implode(' ', $response->getHeader('X-Esi-Error-Limit-Remain')) . ']'
);
// Return a container response that can be parsed.
return $this->makeEsiResponse(
$response->getBody()->getContents(),
$response->getHeaders(),
$response->hasHeader('Expires') ? $response->getHeader('Expires')[0] : 'now',
$response->getStatusCode()
);
} | php | public function httpRequest(
string $method, string $uri, array $headers = [], array $body = []): EsiResponse
{
// Include some basic headers to those already passed in. Everything
// is considered to be Json.
$headers = array_merge($headers, [
'Accept' => 'application/json',
'Content-Type' => 'application/json',
'User-Agent' => 'Eseye/' . Eseye::VERSION . '/' .
Configuration::getInstance()->http_user_agent,
]);
// Add some debug logging and start measuring how long the request took.
$this->logger->debug('Making ' . $method . ' request to ' . $uri);
$start = microtime(true);
// Json encode the body if it has data, else just null it
if (count($body) > 0)
$body = json_encode($body);
else
$body = null;
try {
// Make the _actual_ request to ESI
$response = $this->getClient()->send(
new Request($method, $uri, $headers, $body));
} catch (ClientException | ServerException $e) {
// Log the event as failed
$this->logger->error('[http ' . $e->getResponse()->getStatusCode() . ', ' .
strtolower($e->getResponse()->getReasonPhrase()) . '] ' .
$method . ' -> ' . $this->stripRefreshTokenValue($uri) . ' [t/e: ' .
number_format(microtime(true) - $start, 2) . 's/' .
implode(' ', $e->getResponse()->getHeader('X-Esi-Error-Limit-Remain')) . ']'
);
// Grab the body from the StreamInterface intance.
$responseBody = $e->getResponse()->getBody()->getContents();
// For debugging purposes, log the response body
$this->logger->debug('Request for ' . $method . ' -> ' . $uri . ' failed. Response body was: ' .
$responseBody);
// Raise the exception that should be handled by the caller
throw new RequestFailedException($e, $this->makeEsiResponse(
$responseBody,
$e->getResponse()->getHeaders(),
'now',
$e->getResponse()->getStatusCode())
);
}
// Log the successful request.
$this->logger->log('[http ' . $response->getStatusCode() . ', ' .
strtolower($response->getReasonPhrase()) . '] ' .
$method . ' -> ' . $this->stripRefreshTokenValue($uri) . ' [t/e: ' .
number_format(microtime(true) - $start, 2) . 's/' .
implode(' ', $response->getHeader('X-Esi-Error-Limit-Remain')) . ']'
);
// Return a container response that can be parsed.
return $this->makeEsiResponse(
$response->getBody()->getContents(),
$response->getHeaders(),
$response->hasHeader('Expires') ? $response->getHeader('Expires')[0] : 'now',
$response->getStatusCode()
);
} | [
"public",
"function",
"httpRequest",
"(",
"string",
"$",
"method",
",",
"string",
"$",
"uri",
",",
"array",
"$",
"headers",
"=",
"[",
"]",
",",
"array",
"$",
"body",
"=",
"[",
"]",
")",
":",
"EsiResponse",
"{",
"// Include some basic headers to those already... | @param string $method
@param string $uri
@param array $headers
@param array $body
@return mixed|\Seat\Eseye\Containers\EsiResponse
@throws \Seat\Eseye\Exceptions\RequestFailedException
@throws \Seat\Eseye\Exceptions\InvalidContainerDataException | [
"@param",
"string",
"$method",
"@param",
"string",
"$uri",
"@param",
"array",
"$headers",
"@param",
"array",
"$body"
] | train | https://github.com/eveseat/eseye/blob/55a90ccd49b548cb417ace32075a9188b8d9c1af/src/Fetchers/GuzzleFetcher.php#L199-L269 |
eveseat/eseye | src/Fetchers/GuzzleFetcher.php | GuzzleFetcher.stripRefreshTokenValue | public function stripRefreshTokenValue(string $uri): string
{
// If we have 'refresh_token' in the URI, strip it.
if (strpos($uri, 'refresh_token'))
return Uri::withoutQueryValue((new Uri($uri)), 'refresh_token')
->__toString();
return $uri;
} | php | public function stripRefreshTokenValue(string $uri): string
{
// If we have 'refresh_token' in the URI, strip it.
if (strpos($uri, 'refresh_token'))
return Uri::withoutQueryValue((new Uri($uri)), 'refresh_token')
->__toString();
return $uri;
} | [
"public",
"function",
"stripRefreshTokenValue",
"(",
"string",
"$",
"uri",
")",
":",
"string",
"{",
"// If we have 'refresh_token' in the URI, strip it.",
"if",
"(",
"strpos",
"(",
"$",
"uri",
",",
"'refresh_token'",
")",
")",
"return",
"Uri",
"::",
"withoutQueryVal... | @param string $uri
@return string | [
"@param",
"string",
"$uri"
] | train | https://github.com/eveseat/eseye/blob/55a90ccd49b548cb417ace32075a9188b8d9c1af/src/Fetchers/GuzzleFetcher.php#L299-L308 |
eveseat/eseye | src/Fetchers/GuzzleFetcher.php | GuzzleFetcher.makeEsiResponse | public function makeEsiResponse(
string $body, array $headers, string $expires, int $status_code): EsiResponse
{
return new EsiResponse($body, $headers, $expires, $status_code);
} | php | public function makeEsiResponse(
string $body, array $headers, string $expires, int $status_code): EsiResponse
{
return new EsiResponse($body, $headers, $expires, $status_code);
} | [
"public",
"function",
"makeEsiResponse",
"(",
"string",
"$",
"body",
",",
"array",
"$",
"headers",
",",
"string",
"$",
"expires",
",",
"int",
"$",
"status_code",
")",
":",
"EsiResponse",
"{",
"return",
"new",
"EsiResponse",
"(",
"$",
"body",
",",
"$",
"h... | @param string $body
@param array $headers
@param string $expires
@param int $status_code
@return \Seat\Eseye\Containers\EsiResponse | [
"@param",
"string",
"$body",
"@param",
"array",
"$headers",
"@param",
"string",
"$expires",
"@param",
"int",
"$status_code"
] | train | https://github.com/eveseat/eseye/blob/55a90ccd49b548cb417ace32075a9188b8d9c1af/src/Fetchers/GuzzleFetcher.php#L318-L323 |
eveseat/eseye | src/Fetchers/GuzzleFetcher.php | GuzzleFetcher.getAuthenticationScopes | public function getAuthenticationScopes(): array
{
// If we don't have any authentication data, then
// only public calls can be made.
if (is_null($this->getAuthentication()))
return ['public'];
// If there are no scopes that we know of, update them.
// There will always be at least 1 as we add the internal
// 'public' scope.
if (count($this->getAuthentication()->scopes) <= 0)
$this->setAuthenticationScopes();
return $this->getAuthentication()->scopes;
} | php | public function getAuthenticationScopes(): array
{
// If we don't have any authentication data, then
// only public calls can be made.
if (is_null($this->getAuthentication()))
return ['public'];
// If there are no scopes that we know of, update them.
// There will always be at least 1 as we add the internal
// 'public' scope.
if (count($this->getAuthentication()->scopes) <= 0)
$this->setAuthenticationScopes();
return $this->getAuthentication()->scopes;
} | [
"public",
"function",
"getAuthenticationScopes",
"(",
")",
":",
"array",
"{",
"// If we don't have any authentication data, then",
"// only public calls can be made.",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"getAuthentication",
"(",
")",
")",
")",
"return",
"[",
... | @return array
@throws \Seat\Eseye\Exceptions\InvalidAuthenticationException
@throws \Seat\Eseye\Exceptions\InvalidContainerDataException
@throws \Seat\Eseye\Exceptions\RequestFailedException | [
"@return",
"array"
] | train | https://github.com/eveseat/eseye/blob/55a90ccd49b548cb417ace32075a9188b8d9c1af/src/Fetchers/GuzzleFetcher.php#L332-L347 |
eveseat/eseye | src/Fetchers/GuzzleFetcher.php | GuzzleFetcher.setAuthenticationScopes | public function setAuthenticationScopes()
{
$scopes = $this->verifyToken()['Scopes'];
// Add the internal 'public' scope
$scopes = $scopes . ' public';
$this->authentication->scopes = explode(' ', $scopes);
} | php | public function setAuthenticationScopes()
{
$scopes = $this->verifyToken()['Scopes'];
// Add the internal 'public' scope
$scopes = $scopes . ' public';
$this->authentication->scopes = explode(' ', $scopes);
} | [
"public",
"function",
"setAuthenticationScopes",
"(",
")",
"{",
"$",
"scopes",
"=",
"$",
"this",
"->",
"verifyToken",
"(",
")",
"[",
"'Scopes'",
"]",
";",
"// Add the internal 'public' scope",
"$",
"scopes",
"=",
"$",
"scopes",
".",
"' public'",
";",
"$",
"t... | Query the eveseat/resources repository for SDE
related information.
@throws \Seat\Eseye\Exceptions\InvalidAuthenticationException
@throws \Seat\Eseye\Exceptions\InvalidContainerDataException
@throws \Seat\Eseye\Exceptions\RequestFailedException | [
"Query",
"the",
"eveseat",
"/",
"resources",
"repository",
"for",
"SDE",
"related",
"information",
"."
] | train | https://github.com/eveseat/eseye/blob/55a90ccd49b548cb417ace32075a9188b8d9c1af/src/Fetchers/GuzzleFetcher.php#L357-L365 |
eveseat/eseye | src/Cache/FileCache.php | FileCache.set | public function set(string $uri, string $query, EsiResponse $data)
{
$path = $this->buildRelativePath($this->safePath($uri), $query);
// Create the subpath if that does not already exist
if (! file_exists($path))
@mkdir($path, 0775, true);
// Dump the contents to file
file_put_contents($path . $this->results_filename, serialize($data));
} | php | public function set(string $uri, string $query, EsiResponse $data)
{
$path = $this->buildRelativePath($this->safePath($uri), $query);
// Create the subpath if that does not already exist
if (! file_exists($path))
@mkdir($path, 0775, true);
// Dump the contents to file
file_put_contents($path . $this->results_filename, serialize($data));
} | [
"public",
"function",
"set",
"(",
"string",
"$",
"uri",
",",
"string",
"$",
"query",
",",
"EsiResponse",
"$",
"data",
")",
"{",
"$",
"path",
"=",
"$",
"this",
"->",
"buildRelativePath",
"(",
"$",
"this",
"->",
"safePath",
"(",
"$",
"uri",
")",
",",
... | @param string $uri
@param string $query
@param \Seat\Eseye\Containers\EsiResponse $data
@return mixed|void | [
"@param",
"string",
"$uri",
"@param",
"string",
"$query",
"@param",
"\\",
"Seat",
"\\",
"Eseye",
"\\",
"Containers",
"\\",
"EsiResponse",
"$data"
] | train | https://github.com/eveseat/eseye/blob/55a90ccd49b548cb417ace32075a9188b8d9c1af/src/Cache/FileCache.php#L107-L118 |
eveseat/eseye | src/Cache/FileCache.php | FileCache.buildRelativePath | public function buildRelativePath(string $path, string $query = ''): string
{
// If the query string has data, hash it.
if ($query != '')
$query = $this->hashString($query);
return rtrim(rtrim($this->cache_path, '/') . rtrim($path), '/') .
'/' . $query . '/';
} | php | public function buildRelativePath(string $path, string $query = ''): string
{
// If the query string has data, hash it.
if ($query != '')
$query = $this->hashString($query);
return rtrim(rtrim($this->cache_path, '/') . rtrim($path), '/') .
'/' . $query . '/';
} | [
"public",
"function",
"buildRelativePath",
"(",
"string",
"$",
"path",
",",
"string",
"$",
"query",
"=",
"''",
")",
":",
"string",
"{",
"// If the query string has data, hash it.",
"if",
"(",
"$",
"query",
"!=",
"''",
")",
"$",
"query",
"=",
"$",
"this",
"... | @param string $path
@param string $query
@return string | [
"@param",
"string",
"$path",
"@param",
"string",
"$query"
] | train | https://github.com/eveseat/eseye/blob/55a90ccd49b548cb417ace32075a9188b8d9c1af/src/Cache/FileCache.php#L126-L135 |
eveseat/eseye | src/Cache/FileCache.php | FileCache.has | public function has(string $uri, string $query = ''): bool
{
if ($status = $this->get($uri, $query))
return true;
return false;
} | php | public function has(string $uri, string $query = ''): bool
{
if ($status = $this->get($uri, $query))
return true;
return false;
} | [
"public",
"function",
"has",
"(",
"string",
"$",
"uri",
",",
"string",
"$",
"query",
"=",
"''",
")",
":",
"bool",
"{",
"if",
"(",
"$",
"status",
"=",
"$",
"this",
"->",
"get",
"(",
"$",
"uri",
",",
"$",
"query",
")",
")",
"return",
"true",
";",... | @param string $uri
@param string $query
@return bool|mixed | [
"@param",
"string",
"$uri",
"@param",
"string",
"$query"
] | train | https://github.com/eveseat/eseye/blob/55a90ccd49b548cb417ace32075a9188b8d9c1af/src/Cache/FileCache.php#L154-L161 |
eveseat/eseye | src/Cache/FileCache.php | FileCache.get | public function get(string $uri, string $query = '')
{
$path = $this->buildRelativePath($this->safePath($uri), $query);
$cache_file_path = $path . $this->results_filename;
// If we cant read from the cache, then just return false.
if (! is_readable($cache_file_path))
return false;
// Get the data from the file and unserialize it
$file = unserialize(file_get_contents($cache_file_path));
// If the cached entry is expired and does not have any ETag, remove it.
if ($file->expired() && ! $file->hasHeader('ETag')) {
$this->forget($uri, $query);
return false;
}
return $file;
} | php | public function get(string $uri, string $query = '')
{
$path = $this->buildRelativePath($this->safePath($uri), $query);
$cache_file_path = $path . $this->results_filename;
// If we cant read from the cache, then just return false.
if (! is_readable($cache_file_path))
return false;
// Get the data from the file and unserialize it
$file = unserialize(file_get_contents($cache_file_path));
// If the cached entry is expired and does not have any ETag, remove it.
if ($file->expired() && ! $file->hasHeader('ETag')) {
$this->forget($uri, $query);
return false;
}
return $file;
} | [
"public",
"function",
"get",
"(",
"string",
"$",
"uri",
",",
"string",
"$",
"query",
"=",
"''",
")",
"{",
"$",
"path",
"=",
"$",
"this",
"->",
"buildRelativePath",
"(",
"$",
"this",
"->",
"safePath",
"(",
"$",
"uri",
")",
",",
"$",
"query",
")",
... | @param string $uri
@param string $query
@return mixed | [
"@param",
"string",
"$uri",
"@param",
"string",
"$query"
] | train | https://github.com/eveseat/eseye/blob/55a90ccd49b548cb417ace32075a9188b8d9c1af/src/Cache/FileCache.php#L169-L191 |
eveseat/eseye | src/Cache/FileCache.php | FileCache.forget | public function forget(string $uri, string $query = '')
{
$path = $this->buildRelativePath($uri, $query);
$cache_file_path = $path . $this->results_filename;
@unlink($cache_file_path);
} | php | public function forget(string $uri, string $query = '')
{
$path = $this->buildRelativePath($uri, $query);
$cache_file_path = $path . $this->results_filename;
@unlink($cache_file_path);
} | [
"public",
"function",
"forget",
"(",
"string",
"$",
"uri",
",",
"string",
"$",
"query",
"=",
"''",
")",
"{",
"$",
"path",
"=",
"$",
"this",
"->",
"buildRelativePath",
"(",
"$",
"uri",
",",
"$",
"query",
")",
";",
"$",
"cache_file_path",
"=",
"$",
"... | @param string $uri
@param string $query
@return void | [
"@param",
"string",
"$uri",
"@param",
"string",
"$query"
] | train | https://github.com/eveseat/eseye/blob/55a90ccd49b548cb417ace32075a9188b8d9c1af/src/Cache/FileCache.php#L199-L206 |
eveseat/eseye | src/Cache/MemcachedCache.php | MemcachedCache.set | public function set(string $uri, string $query, EsiResponse $data)
{
if ($this->is_memcached)
$this->memcached->set($this->buildCacheKey($uri, $query), serialize($data), 0);
else
$this->memcached->set($this->buildCacheKey($uri, $query), serialize($data), $this->flags, 0);
} | php | public function set(string $uri, string $query, EsiResponse $data)
{
if ($this->is_memcached)
$this->memcached->set($this->buildCacheKey($uri, $query), serialize($data), 0);
else
$this->memcached->set($this->buildCacheKey($uri, $query), serialize($data), $this->flags, 0);
} | [
"public",
"function",
"set",
"(",
"string",
"$",
"uri",
",",
"string",
"$",
"query",
",",
"EsiResponse",
"$",
"data",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"is_memcached",
")",
"$",
"this",
"->",
"memcached",
"->",
"set",
"(",
"$",
"this",
"->",
... | @param string $uri
@param string $query
@param \Seat\Eseye\Containers\EsiResponse $data
@return void | [
"@param",
"string",
"$uri",
"@param",
"string",
"$query",
"@param",
"\\",
"Seat",
"\\",
"Eseye",
"\\",
"Containers",
"\\",
"EsiResponse",
"$data"
] | train | https://github.com/eveseat/eseye/blob/55a90ccd49b548cb417ace32075a9188b8d9c1af/src/Cache/MemcachedCache.php#L97-L104 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.