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
dapphp/securimage
securimage.php
Securimage.saveAudioData
protected function saveAudioData($data) { if ($this->no_session != true) { $_SESSION['securimage_code_audio'][$this->namespace] = $data; } if ($this->use_database) { $this->saveAudioToDatabase($data); } }
php
protected function saveAudioData($data) { if ($this->no_session != true) { $_SESSION['securimage_code_audio'][$this->namespace] = $data; } if ($this->use_database) { $this->saveAudioToDatabase($data); } }
[ "protected", "function", "saveAudioData", "(", "$", "data", ")", "{", "if", "(", "$", "this", "->", "no_session", "!=", "true", ")", "{", "$", "_SESSION", "[", "'securimage_code_audio'", "]", "[", "$", "this", "->", "namespace", "]", "=", "$", "data", ...
Save audio data to session and/or the configured database @param string $data The CAPTCHA audio data
[ "Save", "audio", "data", "to", "session", "and", "/", "or", "the", "configured", "database" ]
train
https://github.com/dapphp/securimage/blob/1ecb884797c66e01a875c058def46c85aecea45b/securimage.php#L2658-L2667
dapphp/securimage
securimage.php
Securimage.getAudioData
protected function getAudioData() { if ($this->no_session != true) { if (isset($_SESSION['securimage_code_audio'][$this->namespace])) { return $_SESSION['securimage_code_audio'][$this->namespace]; } } if ($this->use_database) { $this->openDatabase(); $code = $this->getCodeFromDatabase(); if (!empty($code['audio_data'])) { return $code['audio_data']; } } return false; }
php
protected function getAudioData() { if ($this->no_session != true) { if (isset($_SESSION['securimage_code_audio'][$this->namespace])) { return $_SESSION['securimage_code_audio'][$this->namespace]; } } if ($this->use_database) { $this->openDatabase(); $code = $this->getCodeFromDatabase(); if (!empty($code['audio_data'])) { return $code['audio_data']; } } return false; }
[ "protected", "function", "getAudioData", "(", ")", "{", "if", "(", "$", "this", "->", "no_session", "!=", "true", ")", "{", "if", "(", "isset", "(", "$", "_SESSION", "[", "'securimage_code_audio'", "]", "[", "$", "this", "->", "namespace", "]", ")", ")...
Gets audio file contents from the session or database @return string|boolean Audio contents on success, or false if no audio found in session or DB
[ "Gets", "audio", "file", "contents", "from", "the", "session", "or", "database" ]
train
https://github.com/dapphp/securimage/blob/1ecb884797c66e01a875c058def46c85aecea45b/securimage.php#L2674-L2692
dapphp/securimage
securimage.php
Securimage.saveCodeToDatabase
protected function saveCodeToDatabase() { $success = false; $this->openDatabase(); if ($this->use_database && $this->pdo_conn) { $id = $this->getCaptchaId(false); $ip = $_SERVER['REMOTE_ADDR']; if (empty($id)) { $id = $ip; } $time = time(); $code = $this->code; $code_disp = $this->code_display; // This is somewhat expensive in PDO Sqlite3 (when there is something to delete) // Clears previous captcha for this client from database so we can do a straight insert // without having to do INSERT ... ON DUPLICATE KEY or a find/update $this->clearCodeFromDatabase(); $query = "INSERT INTO {$this->database_table} (" ."id, code, code_display, namespace, created) " ."VALUES(?, ?, ?, ?, ?)"; $stmt = $this->pdo_conn->prepare($query); $success = $stmt->execute(array($id, $code, $code_disp, $this->namespace, $time)); if (!$success) { $err = $stmt->errorInfo(); $error = "Failed to insert code into database. {$err[1]}: {$err[2]}."; if ($this->database_driver == self::SI_DRIVER_SQLITE3) { $err14 = ($err[1] == 14); if ($err14) $error .= sprintf(" Ensure database directory and file are writeable by user '%s' (%d).", get_current_user(), getmyuid()); } trigger_error($error, E_USER_WARNING); } } return $success !== false; }
php
protected function saveCodeToDatabase() { $success = false; $this->openDatabase(); if ($this->use_database && $this->pdo_conn) { $id = $this->getCaptchaId(false); $ip = $_SERVER['REMOTE_ADDR']; if (empty($id)) { $id = $ip; } $time = time(); $code = $this->code; $code_disp = $this->code_display; // This is somewhat expensive in PDO Sqlite3 (when there is something to delete) // Clears previous captcha for this client from database so we can do a straight insert // without having to do INSERT ... ON DUPLICATE KEY or a find/update $this->clearCodeFromDatabase(); $query = "INSERT INTO {$this->database_table} (" ."id, code, code_display, namespace, created) " ."VALUES(?, ?, ?, ?, ?)"; $stmt = $this->pdo_conn->prepare($query); $success = $stmt->execute(array($id, $code, $code_disp, $this->namespace, $time)); if (!$success) { $err = $stmt->errorInfo(); $error = "Failed to insert code into database. {$err[1]}: {$err[2]}."; if ($this->database_driver == self::SI_DRIVER_SQLITE3) { $err14 = ($err[1] == 14); if ($err14) $error .= sprintf(" Ensure database directory and file are writeable by user '%s' (%d).", get_current_user(), getmyuid()); } trigger_error($error, E_USER_WARNING); } } return $success !== false; }
[ "protected", "function", "saveCodeToDatabase", "(", ")", "{", "$", "success", "=", "false", ";", "$", "this", "->", "openDatabase", "(", ")", ";", "if", "(", "$", "this", "->", "use_database", "&&", "$", "this", "->", "pdo_conn", ")", "{", "$", "id", ...
Saves the CAPTCHA data to the configured database.
[ "Saves", "the", "CAPTCHA", "data", "to", "the", "configured", "database", "." ]
train
https://github.com/dapphp/securimage/blob/1ecb884797c66e01a875c058def46c85aecea45b/securimage.php#L2697-L2741
dapphp/securimage
securimage.php
Securimage.saveAudioToDatabase
protected function saveAudioToDatabase($data) { $success = false; $this->openDatabase(); if ($this->use_database && $this->pdo_conn) { $id = $this->getCaptchaId(false); $ip = $_SERVER['REMOTE_ADDR']; $ns = $this->namespace; if (empty($id)) { $id = $ip; } $query = "UPDATE {$this->database_table} SET audio_data = :audioData WHERE id = :id AND namespace = :namespace"; $stmt = $this->pdo_conn->prepare($query); $stmt->bindParam(':audioData', $data, PDO::PARAM_LOB); $stmt->bindParam(':id', $id); $stmt->bindParam(':namespace', $ns); $success = $stmt->execute(); } return $success !== false; }
php
protected function saveAudioToDatabase($data) { $success = false; $this->openDatabase(); if ($this->use_database && $this->pdo_conn) { $id = $this->getCaptchaId(false); $ip = $_SERVER['REMOTE_ADDR']; $ns = $this->namespace; if (empty($id)) { $id = $ip; } $query = "UPDATE {$this->database_table} SET audio_data = :audioData WHERE id = :id AND namespace = :namespace"; $stmt = $this->pdo_conn->prepare($query); $stmt->bindParam(':audioData', $data, PDO::PARAM_LOB); $stmt->bindParam(':id', $id); $stmt->bindParam(':namespace', $ns); $success = $stmt->execute(); } return $success !== false; }
[ "protected", "function", "saveAudioToDatabase", "(", "$", "data", ")", "{", "$", "success", "=", "false", ";", "$", "this", "->", "openDatabase", "(", ")", ";", "if", "(", "$", "this", "->", "use_database", "&&", "$", "this", "->", "pdo_conn", ")", "{"...
Saves CAPTCHA audio to the configured database @param string $data Audio data @return boolean true on success, false on failure
[ "Saves", "CAPTCHA", "audio", "to", "the", "configured", "database" ]
train
https://github.com/dapphp/securimage/blob/1ecb884797c66e01a875c058def46c85aecea45b/securimage.php#L2749-L2772
dapphp/securimage
securimage.php
Securimage.openDatabase
protected function openDatabase() { $this->pdo_conn = false; if ($this->use_database) { $pdo_extension = 'PDO_' . strtoupper($this->database_driver); if (!extension_loaded($pdo_extension)) { trigger_error("Database support is turned on in Securimage, but the chosen extension $pdo_extension is not loaded in PHP.", E_USER_WARNING); return false; } } if ($this->database_driver == self::SI_DRIVER_SQLITE3) { if (!file_exists($this->database_file)) { $fp = fopen($this->database_file, 'w+'); if (!$fp) { $err = error_get_last(); trigger_error("Securimage failed to create SQLite3 database file '{$this->database_file}'. Reason: {$err['message']}", E_USER_WARNING); return false; } fclose($fp); chmod($this->database_file, 0666); } else if (!is_writeable($this->database_file)) { trigger_error("Securimage does not have read/write access to database file '{$this->database_file}. Make sure permissions are 0666 and writeable by user '" . get_current_user() . "'", E_USER_WARNING); return false; } } try { $dsn = $this->getDsn(); $options = array(); $this->pdo_conn = new PDO($dsn, $this->database_user, $this->database_pass, $options); } catch (PDOException $pdoex) { trigger_error("Database connection failed: " . $pdoex->getMessage(), E_USER_WARNING); return false; } catch (Exception $ex) { trigger_error($ex->getMessage(), E_USER_WARNING); return false; } try { if (!$this->skip_table_check && !$this->checkTablesExist()) { // create tables... $this->createDatabaseTables(); } } catch (Exception $ex) { trigger_error($ex->getMessage(), E_USER_WARNING); $this->pdo_conn = false; return false; } if (mt_rand(0, 100) / 100.0 == 1.0) { $this->purgeOldCodesFromDatabase(); } return $this->pdo_conn; }
php
protected function openDatabase() { $this->pdo_conn = false; if ($this->use_database) { $pdo_extension = 'PDO_' . strtoupper($this->database_driver); if (!extension_loaded($pdo_extension)) { trigger_error("Database support is turned on in Securimage, but the chosen extension $pdo_extension is not loaded in PHP.", E_USER_WARNING); return false; } } if ($this->database_driver == self::SI_DRIVER_SQLITE3) { if (!file_exists($this->database_file)) { $fp = fopen($this->database_file, 'w+'); if (!$fp) { $err = error_get_last(); trigger_error("Securimage failed to create SQLite3 database file '{$this->database_file}'. Reason: {$err['message']}", E_USER_WARNING); return false; } fclose($fp); chmod($this->database_file, 0666); } else if (!is_writeable($this->database_file)) { trigger_error("Securimage does not have read/write access to database file '{$this->database_file}. Make sure permissions are 0666 and writeable by user '" . get_current_user() . "'", E_USER_WARNING); return false; } } try { $dsn = $this->getDsn(); $options = array(); $this->pdo_conn = new PDO($dsn, $this->database_user, $this->database_pass, $options); } catch (PDOException $pdoex) { trigger_error("Database connection failed: " . $pdoex->getMessage(), E_USER_WARNING); return false; } catch (Exception $ex) { trigger_error($ex->getMessage(), E_USER_WARNING); return false; } try { if (!$this->skip_table_check && !$this->checkTablesExist()) { // create tables... $this->createDatabaseTables(); } } catch (Exception $ex) { trigger_error($ex->getMessage(), E_USER_WARNING); $this->pdo_conn = false; return false; } if (mt_rand(0, 100) / 100.0 == 1.0) { $this->purgeOldCodesFromDatabase(); } return $this->pdo_conn; }
[ "protected", "function", "openDatabase", "(", ")", "{", "$", "this", "->", "pdo_conn", "=", "false", ";", "if", "(", "$", "this", "->", "use_database", ")", "{", "$", "pdo_extension", "=", "'PDO_'", ".", "strtoupper", "(", "$", "this", "->", "database_dr...
Opens a connection to the configured database. @see Securimage::$use_database Use database @see Securimage::$database_driver Database driver @see Securimage::$pdo_conn pdo_conn @return bool true if the database connection was successful, false if not
[ "Opens", "a", "connection", "to", "the", "configured", "database", "." ]
train
https://github.com/dapphp/securimage/blob/1ecb884797c66e01a875c058def46c85aecea45b/securimage.php#L2782-L2840
dapphp/securimage
securimage.php
Securimage.getDsn
protected function getDsn() { $dsn = sprintf('%s:', $this->database_driver); switch($this->database_driver) { case self::SI_DRIVER_SQLITE3: $dsn .= $this->database_file; break; case self::SI_DRIVER_MYSQL: case self::SI_DRIVER_PGSQL: if (empty($this->database_host)) { throw new Exception('Securimage::database_host is not set'); } else if (empty($this->database_name)) { throw new Exception('Securimage::database_name is not set'); } $dsn .= sprintf('host=%s;dbname=%s', $this->database_host, $this->database_name); break; } return $dsn; }
php
protected function getDsn() { $dsn = sprintf('%s:', $this->database_driver); switch($this->database_driver) { case self::SI_DRIVER_SQLITE3: $dsn .= $this->database_file; break; case self::SI_DRIVER_MYSQL: case self::SI_DRIVER_PGSQL: if (empty($this->database_host)) { throw new Exception('Securimage::database_host is not set'); } else if (empty($this->database_name)) { throw new Exception('Securimage::database_name is not set'); } $dsn .= sprintf('host=%s;dbname=%s', $this->database_host, $this->database_name); break; } return $dsn; }
[ "protected", "function", "getDsn", "(", ")", "{", "$", "dsn", "=", "sprintf", "(", "'%s:'", ",", "$", "this", "->", "database_driver", ")", ";", "switch", "(", "$", "this", "->", "database_driver", ")", "{", "case", "self", "::", "SI_DRIVER_SQLITE3", ":"...
Get the PDO DSN string for connecting to the database @see Securimage::$database_driver Database driver @throws Exception If database specific options are not configured @return string The DSN for connecting to the database
[ "Get", "the", "PDO", "DSN", "string", "for", "connecting", "to", "the", "database" ]
train
https://github.com/dapphp/securimage/blob/1ecb884797c66e01a875c058def46c85aecea45b/securimage.php#L2849-L2874
dapphp/securimage
securimage.php
Securimage.checkTablesExist
protected function checkTablesExist() { $table = $this->pdo_conn->quote($this->database_table); switch($this->database_driver) { case self::SI_DRIVER_SQLITE3: // query row count for sqlite, PRAGMA queries seem to return no // rowCount using PDO even if there are rows returned $query = "SELECT COUNT(id) FROM $table"; break; case self::SI_DRIVER_MYSQL: $query = "SHOW TABLES LIKE $table"; break; case self::SI_DRIVER_PGSQL: $query = "SELECT * FROM information_schema.columns WHERE table_name = $table;"; break; } $result = $this->pdo_conn->query($query); if (!$result) { $err = $this->pdo_conn->errorInfo(); if ($this->database_driver == self::SI_DRIVER_SQLITE3 && $err[1] === 1 && strpos($err[2], 'no such table') !== false) { return false; } throw new Exception("Failed to check tables: {$err[0]} - {$err[1]}: {$err[2]}"); } else if ($this->database_driver == self::SI_DRIVER_SQLITE3) { // successful here regardless of row count for sqlite return true; } else if ($result->rowCount() == 0) { return false; } else { return true; } }
php
protected function checkTablesExist() { $table = $this->pdo_conn->quote($this->database_table); switch($this->database_driver) { case self::SI_DRIVER_SQLITE3: // query row count for sqlite, PRAGMA queries seem to return no // rowCount using PDO even if there are rows returned $query = "SELECT COUNT(id) FROM $table"; break; case self::SI_DRIVER_MYSQL: $query = "SHOW TABLES LIKE $table"; break; case self::SI_DRIVER_PGSQL: $query = "SELECT * FROM information_schema.columns WHERE table_name = $table;"; break; } $result = $this->pdo_conn->query($query); if (!$result) { $err = $this->pdo_conn->errorInfo(); if ($this->database_driver == self::SI_DRIVER_SQLITE3 && $err[1] === 1 && strpos($err[2], 'no such table') !== false) { return false; } throw new Exception("Failed to check tables: {$err[0]} - {$err[1]}: {$err[2]}"); } else if ($this->database_driver == self::SI_DRIVER_SQLITE3) { // successful here regardless of row count for sqlite return true; } else if ($result->rowCount() == 0) { return false; } else { return true; } }
[ "protected", "function", "checkTablesExist", "(", ")", "{", "$", "table", "=", "$", "this", "->", "pdo_conn", "->", "quote", "(", "$", "this", "->", "database_table", ")", ";", "switch", "(", "$", "this", "->", "database_driver", ")", "{", "case", "self"...
Checks if the necessary database tables for storing captcha codes exist @throws Exception If the table check failed for some reason @return boolean true if the database do exist, false if not
[ "Checks", "if", "the", "necessary", "database", "tables", "for", "storing", "captcha", "codes", "exist" ]
train
https://github.com/dapphp/securimage/blob/1ecb884797c66e01a875c058def46c85aecea45b/securimage.php#L2882-L2922
dapphp/securimage
securimage.php
Securimage.createDatabaseTables
protected function createDatabaseTables() { $queries = array(); switch($this->database_driver) { case self::SI_DRIVER_SQLITE3: $queries[] = "CREATE TABLE \"{$this->database_table}\" ( id VARCHAR(40), namespace VARCHAR(32) NOT NULL, code VARCHAR(32) NOT NULL, code_display VARCHAR(32) NOT NULL, created INTEGER NOT NULL, audio_data BLOB NULL, PRIMARY KEY(id, namespace) )"; $queries[] = "CREATE INDEX ndx_created ON {$this->database_table} (created)"; break; case self::SI_DRIVER_MYSQL: $queries[] = "CREATE TABLE `{$this->database_table}` ( `id` VARCHAR(40) NOT NULL, `namespace` VARCHAR(32) NOT NULL, `code` VARCHAR(32) NOT NULL, `code_display` VARCHAR(32) NOT NULL, `created` INT NOT NULL, `audio_data` MEDIUMBLOB NULL, PRIMARY KEY(id, namespace), INDEX(created) )"; break; case self::SI_DRIVER_PGSQL: $queries[] = "CREATE TABLE {$this->database_table} ( id character varying(40) NOT NULL, namespace character varying(32) NOT NULL, code character varying(32) NOT NULL, code_display character varying(32) NOT NULL, created integer NOT NULL, audio_data bytea NULL, CONSTRAINT pkey_id_namespace PRIMARY KEY (id, namespace) )"; $queries[] = "CREATE INDEX ndx_created ON {$this->database_table} (created);"; break; } $this->pdo_conn->beginTransaction(); foreach($queries as $query) { $result = $this->pdo_conn->query($query); if (!$result) { $err = $this->pdo_conn->errorInfo(); trigger_error("Failed to create table. {$err[1]}: {$err[2]}", E_USER_WARNING); $this->pdo_conn->rollBack(); $this->pdo_conn = false; return false; } } $this->pdo_conn->commit(); return true; }
php
protected function createDatabaseTables() { $queries = array(); switch($this->database_driver) { case self::SI_DRIVER_SQLITE3: $queries[] = "CREATE TABLE \"{$this->database_table}\" ( id VARCHAR(40), namespace VARCHAR(32) NOT NULL, code VARCHAR(32) NOT NULL, code_display VARCHAR(32) NOT NULL, created INTEGER NOT NULL, audio_data BLOB NULL, PRIMARY KEY(id, namespace) )"; $queries[] = "CREATE INDEX ndx_created ON {$this->database_table} (created)"; break; case self::SI_DRIVER_MYSQL: $queries[] = "CREATE TABLE `{$this->database_table}` ( `id` VARCHAR(40) NOT NULL, `namespace` VARCHAR(32) NOT NULL, `code` VARCHAR(32) NOT NULL, `code_display` VARCHAR(32) NOT NULL, `created` INT NOT NULL, `audio_data` MEDIUMBLOB NULL, PRIMARY KEY(id, namespace), INDEX(created) )"; break; case self::SI_DRIVER_PGSQL: $queries[] = "CREATE TABLE {$this->database_table} ( id character varying(40) NOT NULL, namespace character varying(32) NOT NULL, code character varying(32) NOT NULL, code_display character varying(32) NOT NULL, created integer NOT NULL, audio_data bytea NULL, CONSTRAINT pkey_id_namespace PRIMARY KEY (id, namespace) )"; $queries[] = "CREATE INDEX ndx_created ON {$this->database_table} (created);"; break; } $this->pdo_conn->beginTransaction(); foreach($queries as $query) { $result = $this->pdo_conn->query($query); if (!$result) { $err = $this->pdo_conn->errorInfo(); trigger_error("Failed to create table. {$err[1]}: {$err[2]}", E_USER_WARNING); $this->pdo_conn->rollBack(); $this->pdo_conn = false; return false; } } $this->pdo_conn->commit(); return true; }
[ "protected", "function", "createDatabaseTables", "(", ")", "{", "$", "queries", "=", "array", "(", ")", ";", "switch", "(", "$", "this", "->", "database_driver", ")", "{", "case", "self", "::", "SI_DRIVER_SQLITE3", ":", "$", "queries", "[", "]", "=", "\"...
Create the necessary databaes table for storing captcha codes. Based on the database adapter used, the tables will created in the existing connection. @see Securimage::$database_driver Database driver @return boolean true if the tables were created, false if not
[ "Create", "the", "necessary", "databaes", "table", "for", "storing", "captcha", "codes", "." ]
train
https://github.com/dapphp/securimage/blob/1ecb884797c66e01a875c058def46c85aecea45b/securimage.php#L2932-L2996
dapphp/securimage
securimage.php
Securimage.getCodeFromDatabase
protected function getCodeFromDatabase() { $code = ''; if ($this->use_database == true && $this->pdo_conn) { if (Securimage::$_captchaId !== null) { $query = "SELECT * FROM {$this->database_table} WHERE id = ?"; $stmt = $this->pdo_conn->prepare($query); $result = $stmt->execute(array(Securimage::$_captchaId)); } else { $ip = $_SERVER['REMOTE_ADDR']; $ns = $this->namespace; // ip is stored in id column when no captchaId $query = "SELECT * FROM {$this->database_table} WHERE id = ? AND namespace = ?"; $stmt = $this->pdo_conn->prepare($query); $result = $stmt->execute(array($ip, $ns)); } if (!$result) { $err = $this->pdo_conn->errorInfo(); trigger_error("Failed to select code from database. {$err[0]}: {$err[1]}", E_USER_WARNING); } else { if ( ($row = $stmt->fetch()) !== false ) { if (false == $this->isCodeExpired($row['created'])) { if ($this->database_driver == self::SI_DRIVER_PGSQL && is_resource($row['audio_data'])) { // pg bytea data returned as stream resource $data = ''; while (!feof($row['audio_data'])) { $data .= fgets($row['audio_data']); } $row['audio_data'] = $data; } $code = array( 'code' => $row['code'], 'code_disp' => $row['code_display'], 'time' => $row['created'], 'audio_data' => $row['audio_data'], ); } } } } return $code; }
php
protected function getCodeFromDatabase() { $code = ''; if ($this->use_database == true && $this->pdo_conn) { if (Securimage::$_captchaId !== null) { $query = "SELECT * FROM {$this->database_table} WHERE id = ?"; $stmt = $this->pdo_conn->prepare($query); $result = $stmt->execute(array(Securimage::$_captchaId)); } else { $ip = $_SERVER['REMOTE_ADDR']; $ns = $this->namespace; // ip is stored in id column when no captchaId $query = "SELECT * FROM {$this->database_table} WHERE id = ? AND namespace = ?"; $stmt = $this->pdo_conn->prepare($query); $result = $stmt->execute(array($ip, $ns)); } if (!$result) { $err = $this->pdo_conn->errorInfo(); trigger_error("Failed to select code from database. {$err[0]}: {$err[1]}", E_USER_WARNING); } else { if ( ($row = $stmt->fetch()) !== false ) { if (false == $this->isCodeExpired($row['created'])) { if ($this->database_driver == self::SI_DRIVER_PGSQL && is_resource($row['audio_data'])) { // pg bytea data returned as stream resource $data = ''; while (!feof($row['audio_data'])) { $data .= fgets($row['audio_data']); } $row['audio_data'] = $data; } $code = array( 'code' => $row['code'], 'code_disp' => $row['code_display'], 'time' => $row['created'], 'audio_data' => $row['audio_data'], ); } } } } return $code; }
[ "protected", "function", "getCodeFromDatabase", "(", ")", "{", "$", "code", "=", "''", ";", "if", "(", "$", "this", "->", "use_database", "==", "true", "&&", "$", "this", "->", "pdo_conn", ")", "{", "if", "(", "Securimage", "::", "$", "_captchaId", "!=...
Retrieves a stored code from the database for based on the captchaId or IP address if captcha ID not used. @return string|array Empty string if no code was found or has expired, otherwise returns array of code information.
[ "Retrieves", "a", "stored", "code", "from", "the", "database", "for", "based", "on", "the", "captchaId", "or", "IP", "address", "if", "captcha", "ID", "not", "used", "." ]
train
https://github.com/dapphp/securimage/blob/1ecb884797c66e01a875c058def46c85aecea45b/securimage.php#L3005-L3050
dapphp/securimage
securimage.php
Securimage.clearCodeFromDatabase
protected function clearCodeFromDatabase() { if ($this->pdo_conn) { $ip = $_SERVER['REMOTE_ADDR']; $ns = $this->pdo_conn->quote($this->namespace); $id = Securimage::$_captchaId; if (empty($id)) { $id = $ip; // if no captchaId set, IP address is captchaId. } $id = $this->pdo_conn->quote($id); $query = sprintf("DELETE FROM %s WHERE id = %s AND namespace = %s", $this->database_table, $id, $ns); $result = $this->pdo_conn->query($query); if (!$result) { trigger_error("Failed to delete code from database.", E_USER_WARNING); } } }
php
protected function clearCodeFromDatabase() { if ($this->pdo_conn) { $ip = $_SERVER['REMOTE_ADDR']; $ns = $this->pdo_conn->quote($this->namespace); $id = Securimage::$_captchaId; if (empty($id)) { $id = $ip; // if no captchaId set, IP address is captchaId. } $id = $this->pdo_conn->quote($id); $query = sprintf("DELETE FROM %s WHERE id = %s AND namespace = %s", $this->database_table, $id, $ns); $result = $this->pdo_conn->query($query); if (!$result) { trigger_error("Failed to delete code from database.", E_USER_WARNING); } } }
[ "protected", "function", "clearCodeFromDatabase", "(", ")", "{", "if", "(", "$", "this", "->", "pdo_conn", ")", "{", "$", "ip", "=", "$", "_SERVER", "[", "'REMOTE_ADDR'", "]", ";", "$", "ns", "=", "$", "this", "->", "pdo_conn", "->", "quote", "(", "$...
Remove a stored code from the database based on captchaId or IP address.
[ "Remove", "a", "stored", "code", "from", "the", "database", "based", "on", "captchaId", "or", "IP", "address", "." ]
train
https://github.com/dapphp/securimage/blob/1ecb884797c66e01a875c058def46c85aecea45b/securimage.php#L3055-L3076
dapphp/securimage
securimage.php
Securimage.purgeOldCodesFromDatabase
protected function purgeOldCodesFromDatabase() { if ($this->use_database && $this->pdo_conn) { $now = time(); $limit = (!is_numeric($this->expiry_time) || $this->expiry_time < 1) ? 86400 : $this->expiry_time; $query = sprintf("DELETE FROM %s WHERE %s - created > %s", $this->database_table, $now, $this->pdo_conn->quote("$limit", PDO::PARAM_INT)); $result = $this->pdo_conn->query($query); } }
php
protected function purgeOldCodesFromDatabase() { if ($this->use_database && $this->pdo_conn) { $now = time(); $limit = (!is_numeric($this->expiry_time) || $this->expiry_time < 1) ? 86400 : $this->expiry_time; $query = sprintf("DELETE FROM %s WHERE %s - created > %s", $this->database_table, $now, $this->pdo_conn->quote("$limit", PDO::PARAM_INT)); $result = $this->pdo_conn->query($query); } }
[ "protected", "function", "purgeOldCodesFromDatabase", "(", ")", "{", "if", "(", "$", "this", "->", "use_database", "&&", "$", "this", "->", "pdo_conn", ")", "{", "$", "now", "=", "time", "(", ")", ";", "$", "limit", "=", "(", "!", "is_numeric", "(", ...
Deletes old (expired) codes from the database
[ "Deletes", "old", "(", "expired", ")", "codes", "from", "the", "database" ]
train
https://github.com/dapphp/securimage/blob/1ecb884797c66e01a875c058def46c85aecea45b/securimage.php#L3081-L3094
dapphp/securimage
securimage.php
Securimage.isCodeExpired
protected function isCodeExpired($creation_time) { $expired = true; if (!is_numeric($this->expiry_time) || $this->expiry_time < 1) { $expired = false; } else if (time() - $creation_time < $this->expiry_time) { $expired = false; } return $expired; }
php
protected function isCodeExpired($creation_time) { $expired = true; if (!is_numeric($this->expiry_time) || $this->expiry_time < 1) { $expired = false; } else if (time() - $creation_time < $this->expiry_time) { $expired = false; } return $expired; }
[ "protected", "function", "isCodeExpired", "(", "$", "creation_time", ")", "{", "$", "expired", "=", "true", ";", "if", "(", "!", "is_numeric", "(", "$", "this", "->", "expiry_time", ")", "||", "$", "this", "->", "expiry_time", "<", "1", ")", "{", "$", ...
Checks to see if the captcha code has expired and can no longer be used. @see Securimage::$expiry_time expiry_time @param int $creation_time The Unix timestamp of when the captcha code was created @return bool true if the code is expired, false if it is still valid
[ "Checks", "to", "see", "if", "the", "captcha", "code", "has", "expired", "and", "can", "no", "longer", "be", "used", "." ]
train
https://github.com/dapphp/securimage/blob/1ecb884797c66e01a875c058def46c85aecea45b/securimage.php#L3103-L3114
dapphp/securimage
securimage.php
Securimage.generateWAV
protected function generateWAV($letters) { $wavCaptcha = new WavFile(); $first = true; // reading first wav file if ($this->audio_use_sox && !is_executable($this->sox_binary_path)) { throw new Exception("Path to SoX binary is incorrect or not executable"); } foreach ($letters as $letter) { $letter = strtoupper($letter); try { $letter_file = realpath($this->audio_path) . DIRECTORY_SEPARATOR . $letter . '.wav'; if ($this->audio_use_sox) { $sox_cmd = sprintf("%s %s -t wav - %s", $this->sox_binary_path, $letter_file, $this->getSoxEffectChain()); $data = `$sox_cmd`; $l = new WavFile(); $l->setIgnoreChunkSizes(true); $l->setWavData($data); } else { $l = new WavFile($letter_file); } if ($first) { // set sample rate, bits/sample, and # of channels for file based on first letter $wavCaptcha->setSampleRate($l->getSampleRate()) ->setBitsPerSample($l->getBitsPerSample()) ->setNumChannels($l->getNumChannels()); $first = false; } // append letter to the captcha audio $wavCaptcha->appendWav($l); // random length of silence between $audio_gap_min and $audio_gap_max if ($this->audio_gap_max > 0 && $this->audio_gap_max > $this->audio_gap_min) { $wavCaptcha->insertSilence( mt_rand($this->audio_gap_min, $this->audio_gap_max) / 1000.0 ); } } catch (Exception $ex) { // failed to open file, or the wav file is broken or not supported // 2 wav files were not compatible, different # channels, bits/sample, or sample rate throw new Exception("Error generating audio captcha on letter '$letter': " . $ex->getMessage()); } } /********* Set up audio filters *****************************/ $filters = array(); if ($this->audio_use_noise == true) { // use background audio - find random file $wavNoise = false; $randOffset = 0; /* // uncomment to try experimental SoX noise generation. // warning: sounds may be considered annoying if ($this->audio_use_sox) { $duration = $wavCaptcha->getDataSize() / ($wavCaptcha->getBitsPerSample() / 8) / $wavCaptcha->getNumChannels() / $wavCaptcha->getSampleRate(); $duration = round($duration, 2); $wavNoise = new WavFile(); $wavNoise->setIgnoreChunkSizes(true); $noiseData = $this->getSoxNoiseData($duration, $wavCaptcha->getNumChannels(), $wavCaptcha->getSampleRate(), $wavCaptcha->getBitsPerSample()); $wavNoise->setWavData($noiseData, true); } else */ if ( ($noiseFile = $this->getRandomNoiseFile()) !== false) { try { $wavNoise = new WavFile($noiseFile, false); } catch(Exception $ex) { throw $ex; } // start at a random offset from the beginning of the wavfile // in order to add more randomness $randOffset = 0; if ($wavNoise->getNumBlocks() > 2 * $wavCaptcha->getNumBlocks()) { $randBlock = mt_rand(0, $wavNoise->getNumBlocks() - $wavCaptcha->getNumBlocks()); $wavNoise->readWavData($randBlock * $wavNoise->getBlockAlign(), $wavCaptcha->getNumBlocks() * $wavNoise->getBlockAlign()); } else { $wavNoise->readWavData(); $randOffset = mt_rand(0, $wavNoise->getNumBlocks() - 1); } } if ($wavNoise !== false) { $mixOpts = array('wav' => $wavNoise, 'loop' => true, 'blockOffset' => $randOffset); $filters[WavFile::FILTER_MIX] = $mixOpts; $filters[WavFile::FILTER_NORMALIZE] = $this->audio_mix_normalization; } } if ($this->degrade_audio == true) { // add random noise. // any noise level below 95% is intensely distorted and not pleasant to the ear $filters[WavFile::FILTER_DEGRADE] = mt_rand(95, 98) / 100.0; } if (!empty($filters)) { $wavCaptcha->filter($filters); // apply filters to captcha audio } return $wavCaptcha->__toString(); }
php
protected function generateWAV($letters) { $wavCaptcha = new WavFile(); $first = true; // reading first wav file if ($this->audio_use_sox && !is_executable($this->sox_binary_path)) { throw new Exception("Path to SoX binary is incorrect or not executable"); } foreach ($letters as $letter) { $letter = strtoupper($letter); try { $letter_file = realpath($this->audio_path) . DIRECTORY_SEPARATOR . $letter . '.wav'; if ($this->audio_use_sox) { $sox_cmd = sprintf("%s %s -t wav - %s", $this->sox_binary_path, $letter_file, $this->getSoxEffectChain()); $data = `$sox_cmd`; $l = new WavFile(); $l->setIgnoreChunkSizes(true); $l->setWavData($data); } else { $l = new WavFile($letter_file); } if ($first) { // set sample rate, bits/sample, and # of channels for file based on first letter $wavCaptcha->setSampleRate($l->getSampleRate()) ->setBitsPerSample($l->getBitsPerSample()) ->setNumChannels($l->getNumChannels()); $first = false; } // append letter to the captcha audio $wavCaptcha->appendWav($l); // random length of silence between $audio_gap_min and $audio_gap_max if ($this->audio_gap_max > 0 && $this->audio_gap_max > $this->audio_gap_min) { $wavCaptcha->insertSilence( mt_rand($this->audio_gap_min, $this->audio_gap_max) / 1000.0 ); } } catch (Exception $ex) { // failed to open file, or the wav file is broken or not supported // 2 wav files were not compatible, different # channels, bits/sample, or sample rate throw new Exception("Error generating audio captcha on letter '$letter': " . $ex->getMessage()); } } /********* Set up audio filters *****************************/ $filters = array(); if ($this->audio_use_noise == true) { // use background audio - find random file $wavNoise = false; $randOffset = 0; /* // uncomment to try experimental SoX noise generation. // warning: sounds may be considered annoying if ($this->audio_use_sox) { $duration = $wavCaptcha->getDataSize() / ($wavCaptcha->getBitsPerSample() / 8) / $wavCaptcha->getNumChannels() / $wavCaptcha->getSampleRate(); $duration = round($duration, 2); $wavNoise = new WavFile(); $wavNoise->setIgnoreChunkSizes(true); $noiseData = $this->getSoxNoiseData($duration, $wavCaptcha->getNumChannels(), $wavCaptcha->getSampleRate(), $wavCaptcha->getBitsPerSample()); $wavNoise->setWavData($noiseData, true); } else */ if ( ($noiseFile = $this->getRandomNoiseFile()) !== false) { try { $wavNoise = new WavFile($noiseFile, false); } catch(Exception $ex) { throw $ex; } // start at a random offset from the beginning of the wavfile // in order to add more randomness $randOffset = 0; if ($wavNoise->getNumBlocks() > 2 * $wavCaptcha->getNumBlocks()) { $randBlock = mt_rand(0, $wavNoise->getNumBlocks() - $wavCaptcha->getNumBlocks()); $wavNoise->readWavData($randBlock * $wavNoise->getBlockAlign(), $wavCaptcha->getNumBlocks() * $wavNoise->getBlockAlign()); } else { $wavNoise->readWavData(); $randOffset = mt_rand(0, $wavNoise->getNumBlocks() - 1); } } if ($wavNoise !== false) { $mixOpts = array('wav' => $wavNoise, 'loop' => true, 'blockOffset' => $randOffset); $filters[WavFile::FILTER_MIX] = $mixOpts; $filters[WavFile::FILTER_NORMALIZE] = $this->audio_mix_normalization; } } if ($this->degrade_audio == true) { // add random noise. // any noise level below 95% is intensely distorted and not pleasant to the ear $filters[WavFile::FILTER_DEGRADE] = mt_rand(95, 98) / 100.0; } if (!empty($filters)) { $wavCaptcha->filter($filters); // apply filters to captcha audio } return $wavCaptcha->__toString(); }
[ "protected", "function", "generateWAV", "(", "$", "letters", ")", "{", "$", "wavCaptcha", "=", "new", "WavFile", "(", ")", ";", "$", "first", "=", "true", ";", "// reading first wav file", "if", "(", "$", "this", "->", "audio_use_sox", "&&", "!", "is_execu...
Generate a wav file given the $letters in the code @param array $letters The letters making up the captcha @return string The audio content in WAV format
[ "Generate", "a", "wav", "file", "given", "the", "$letters", "in", "the", "code" ]
train
https://github.com/dapphp/securimage/blob/1ecb884797c66e01a875c058def46c85aecea45b/securimage.php#L3122-L3241
dapphp/securimage
securimage.php
Securimage.getRandomNoiseFile
public function getRandomNoiseFile() { $return = false; if ( ($dh = opendir($this->audio_noise_path)) !== false ) { $list = array(); while ( ($file = readdir($dh)) !== false ) { if ($file == '.' || $file == '..') continue; if (strtolower(substr($file, -4)) != '.wav') continue; $list[] = $file; } closedir($dh); if (sizeof($list) > 0) { $file = $list[array_rand($list, 1)]; $return = $this->audio_noise_path . DIRECTORY_SEPARATOR . $file; if (!is_readable($return)) $return = false; } } return $return; }
php
public function getRandomNoiseFile() { $return = false; if ( ($dh = opendir($this->audio_noise_path)) !== false ) { $list = array(); while ( ($file = readdir($dh)) !== false ) { if ($file == '.' || $file == '..') continue; if (strtolower(substr($file, -4)) != '.wav') continue; $list[] = $file; } closedir($dh); if (sizeof($list) > 0) { $file = $list[array_rand($list, 1)]; $return = $this->audio_noise_path . DIRECTORY_SEPARATOR . $file; if (!is_readable($return)) $return = false; } } return $return; }
[ "public", "function", "getRandomNoiseFile", "(", ")", "{", "$", "return", "=", "false", ";", "if", "(", "(", "$", "dh", "=", "opendir", "(", "$", "this", "->", "audio_noise_path", ")", ")", "!==", "false", ")", "{", "$", "list", "=", "array", "(", ...
Gets and returns the path to a random noise file from the audio noise directory. @return bool|string false if a file could not be found, or a string containing the path to the file.
[ "Gets", "and", "returns", "the", "path", "to", "a", "random", "noise", "file", "from", "the", "audio", "noise", "directory", "." ]
train
https://github.com/dapphp/securimage/blob/1ecb884797c66e01a875c058def46c85aecea45b/securimage.php#L3248-L3273
dapphp/securimage
securimage.php
Securimage.getSoxEffectChain
protected function getSoxEffectChain($numEffects = 2) { $effectsList = array('bend', 'chorus', 'overdrive', 'pitch', 'reverb', 'tempo', 'tremolo'); $effects = array_rand($effectsList, $numEffects); $outEffects = array(); if (!is_array($effects)) $effects = array($effects); foreach($effects as $effect) { $effect = $effectsList[$effect]; switch($effect) { case 'bend': $delay = mt_rand(0, 15) / 100.0; $cents = mt_rand(-120, 120); $dur = mt_rand(75, 400) / 100.0; $outEffects[] = "$effect $delay,$cents,$dur"; break; case 'chorus': $gainIn = mt_rand(75, 90) / 100.0; $gainOut = mt_rand(70, 95) / 100.0; $chorStr = "$effect $gainIn $gainOut"; for ($i = 0; $i < mt_rand(2, 3); ++$i) { $delay = mt_rand(20, 100); $decay = mt_rand(10, 100) / 100.0; $speed = mt_rand(20, 50) / 100.0; $depth = mt_rand(150, 250) / 100.0; $chorStr .= " $delay $decay $speed $depth -s"; } $outEffects[] = $chorStr; break; case 'overdrive': $gain = mt_rand(5, 25); $color = mt_rand(20, 70); $outEffects[] = "$effect $gain $color"; break; case 'pitch': $cents = mt_rand(-300, 300); $outEffects[] = "$effect $cents"; break; case 'reverb': $reverberance = mt_rand(20, 80); $damping = mt_rand(10, 80); $scale = mt_rand(85, 100); $depth = mt_rand(90, 100); $predelay = mt_rand(0, 5); $outEffects[] = "$effect $reverberance $damping $scale $depth $predelay"; break; case 'tempo': $factor = mt_rand(65, 135) / 100.0; $outEffects[] = "$effect -s $factor"; break; case 'tremolo': $hz = mt_rand(10, 30); $depth = mt_rand(40, 85); $outEffects[] = "$effect $hz $depth"; break; } } return implode(' ', $outEffects); }
php
protected function getSoxEffectChain($numEffects = 2) { $effectsList = array('bend', 'chorus', 'overdrive', 'pitch', 'reverb', 'tempo', 'tremolo'); $effects = array_rand($effectsList, $numEffects); $outEffects = array(); if (!is_array($effects)) $effects = array($effects); foreach($effects as $effect) { $effect = $effectsList[$effect]; switch($effect) { case 'bend': $delay = mt_rand(0, 15) / 100.0; $cents = mt_rand(-120, 120); $dur = mt_rand(75, 400) / 100.0; $outEffects[] = "$effect $delay,$cents,$dur"; break; case 'chorus': $gainIn = mt_rand(75, 90) / 100.0; $gainOut = mt_rand(70, 95) / 100.0; $chorStr = "$effect $gainIn $gainOut"; for ($i = 0; $i < mt_rand(2, 3); ++$i) { $delay = mt_rand(20, 100); $decay = mt_rand(10, 100) / 100.0; $speed = mt_rand(20, 50) / 100.0; $depth = mt_rand(150, 250) / 100.0; $chorStr .= " $delay $decay $speed $depth -s"; } $outEffects[] = $chorStr; break; case 'overdrive': $gain = mt_rand(5, 25); $color = mt_rand(20, 70); $outEffects[] = "$effect $gain $color"; break; case 'pitch': $cents = mt_rand(-300, 300); $outEffects[] = "$effect $cents"; break; case 'reverb': $reverberance = mt_rand(20, 80); $damping = mt_rand(10, 80); $scale = mt_rand(85, 100); $depth = mt_rand(90, 100); $predelay = mt_rand(0, 5); $outEffects[] = "$effect $reverberance $damping $scale $depth $predelay"; break; case 'tempo': $factor = mt_rand(65, 135) / 100.0; $outEffects[] = "$effect -s $factor"; break; case 'tremolo': $hz = mt_rand(10, 30); $depth = mt_rand(40, 85); $outEffects[] = "$effect $hz $depth"; break; } } return implode(' ', $outEffects); }
[ "protected", "function", "getSoxEffectChain", "(", "$", "numEffects", "=", "2", ")", "{", "$", "effectsList", "=", "array", "(", "'bend'", ",", "'chorus'", ",", "'overdrive'", ",", "'pitch'", ",", "'reverb'", ",", "'tempo'", ",", "'tremolo'", ")", ";", "$"...
Get a random effect or chain of effects to apply to a segment of the audio file. These effects should increase the randomness of the audio for a particular letter/number by modulating the signal. The SoX effects used are *bend*, *chorus*, *overdrive*, *pitch*, *reverb*, *tempo*, and *tremolo*. For each effect selected, random parameters are supplied to the effect. @param int $numEffects How many effects to chain together @return string A string of valid SoX effects and their respective options.
[ "Get", "a", "random", "effect", "or", "chain", "of", "effects", "to", "apply", "to", "a", "segment", "of", "the", "audio", "file", "." ]
train
https://github.com/dapphp/securimage/blob/1ecb884797c66e01a875c058def46c85aecea45b/securimage.php#L3289-L3360
dapphp/securimage
securimage.php
Securimage.getSoxNoiseData
protected function getSoxNoiseData($duration, $numChannels, $sampleRate, $bitRate) { $shapes = array('sine', 'square', 'triangle', 'sawtooth', 'trapezium'); $steps = array(':', '+', '/', '-'); $selShapes = array_rand($shapes, 2); $selSteps = array_rand($steps, 2); $sweep0 = array(); $sweep0[0] = mt_rand(100, 700); $sweep0[1] = mt_rand(1500, 2500); $sweep1 = array(); $sweep1[0] = mt_rand(500, 1000); $sweep1[1] = mt_rand(1200, 2000); if (mt_rand(0, 10) % 2 == 0) $sweep0 = array_reverse($sweep0); if (mt_rand(0, 10) % 2 == 0) $sweep1 = array_reverse($sweep1); $cmd = sprintf("%s -c %d -r %d -b %d -n -t wav - synth noise create vol 0.3 synth %.2f %s mix %d%s%d vol 0.3 synth %.2f %s fmod %d%s%d vol 0.3", $this->sox_binary_path, $numChannels, $sampleRate, $bitRate, $duration, $shapes[$selShapes[0]], $sweep0[0], $steps[$selSteps[0]], $sweep0[1], $duration, $shapes[$selShapes[1]], $sweep1[0], $steps[$selSteps[1]], $sweep1[1] ); $data = `$cmd`; return $data; }
php
protected function getSoxNoiseData($duration, $numChannels, $sampleRate, $bitRate) { $shapes = array('sine', 'square', 'triangle', 'sawtooth', 'trapezium'); $steps = array(':', '+', '/', '-'); $selShapes = array_rand($shapes, 2); $selSteps = array_rand($steps, 2); $sweep0 = array(); $sweep0[0] = mt_rand(100, 700); $sweep0[1] = mt_rand(1500, 2500); $sweep1 = array(); $sweep1[0] = mt_rand(500, 1000); $sweep1[1] = mt_rand(1200, 2000); if (mt_rand(0, 10) % 2 == 0) $sweep0 = array_reverse($sweep0); if (mt_rand(0, 10) % 2 == 0) $sweep1 = array_reverse($sweep1); $cmd = sprintf("%s -c %d -r %d -b %d -n -t wav - synth noise create vol 0.3 synth %.2f %s mix %d%s%d vol 0.3 synth %.2f %s fmod %d%s%d vol 0.3", $this->sox_binary_path, $numChannels, $sampleRate, $bitRate, $duration, $shapes[$selShapes[0]], $sweep0[0], $steps[$selSteps[0]], $sweep0[1], $duration, $shapes[$selShapes[1]], $sweep1[0], $steps[$selSteps[1]], $sweep1[1] ); $data = `$cmd`; return $data; }
[ "protected", "function", "getSoxNoiseData", "(", "$", "duration", ",", "$", "numChannels", ",", "$", "sampleRate", ",", "$", "bitRate", ")", "{", "$", "shapes", "=", "array", "(", "'sine'", ",", "'square'", ",", "'triangle'", ",", "'sawtooth'", ",", "'trap...
This function is not yet used. Generate random background noise from sweeping oscillators @param float $duration How long in seconds the generated sound will be @param int $numChannels Number of channels in output wav @param int $sampleRate Sample rate of output wav @param int $bitRate Bits per sample (8, 16, 24) @return string Audio data in wav format
[ "This", "function", "is", "not", "yet", "used", "." ]
train
https://github.com/dapphp/securimage/blob/1ecb884797c66e01a875c058def46c85aecea45b/securimage.php#L3373-L3411
dapphp/securimage
securimage.php
Securimage.wavToMp3
protected function wavToMp3($data) { if (!file_exists(self::$lame_binary_path) || !is_executable(self::$lame_binary_path)) { throw new Exception('Lame binary "' . $this->lame_binary_path . '" does not exist or is not executable'); } // size of wav data input $size = strlen($data); // file descriptors for reading and writing to the Lame process $descriptors = array( 0 => array('pipe', 'r'), // stdin 1 => array('pipe', 'w'), // stdout 2 => array('pipe', 'a'), // stderr ); if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { // workaround for Windows conversion // writing to STDIN seems to hang indefinitely after writing approximately 0xC400 bytes $wavinput = tempnam(sys_get_temp_dir(), 'wav'); if (!$wavinput) { throw new Exception('Failed to create temporary file for WAV to MP3 conversion'); } file_put_contents($wavinput, $data); $size = 0; } else { $wavinput = '-'; // stdin } // Mono, variable bit rate, 32 kHz sampling rate, read WAV from stdin, write MP3 to stdout $cmd = sprintf("%s -m m -v -b 32 %s -", self::$lame_binary_path, $wavinput); $proc = proc_open($cmd, $descriptors, $pipes); if (!is_resource($proc)) { throw new Exception('Failed to open process for MP3 encoding'); } stream_set_blocking($pipes[0], 0); // set stdin to be non-blocking for ($written = 0; $written < $size; $written += $len) { // write to stdin until all WAV data is written $len = fwrite($pipes[0], substr($data, $written, 0x20000)); if ($len === 0) { // fwrite wrote no data, make sure process is still alive, otherwise wait for it to process $status = proc_get_status($proc); if ($status['running'] === false) break; usleep(25000); } else if ($written < $size) { // couldn't write all data, small pause and try again usleep(10000); } else if ($len === false) { // fwrite failed, should not happen break; } } fclose($pipes[0]); $data = stream_get_contents($pipes[1]); $err = trim(stream_get_contents($pipes[2])); fclose($pipes[1]); fclose($pipes[2]); $return = proc_close($proc); if ($wavinput != '-') unlink($wavinput); // delete temp file on Windows if ($return !== 0) { throw new Exception("Failed to convert WAV to MP3. Shell returned ({$return}): {$err}"); } else if ($written < $size) { throw new Exception('Failed to convert WAV to MP3. Failed to write all data to encoder'); } return $data; }
php
protected function wavToMp3($data) { if (!file_exists(self::$lame_binary_path) || !is_executable(self::$lame_binary_path)) { throw new Exception('Lame binary "' . $this->lame_binary_path . '" does not exist or is not executable'); } // size of wav data input $size = strlen($data); // file descriptors for reading and writing to the Lame process $descriptors = array( 0 => array('pipe', 'r'), // stdin 1 => array('pipe', 'w'), // stdout 2 => array('pipe', 'a'), // stderr ); if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { // workaround for Windows conversion // writing to STDIN seems to hang indefinitely after writing approximately 0xC400 bytes $wavinput = tempnam(sys_get_temp_dir(), 'wav'); if (!$wavinput) { throw new Exception('Failed to create temporary file for WAV to MP3 conversion'); } file_put_contents($wavinput, $data); $size = 0; } else { $wavinput = '-'; // stdin } // Mono, variable bit rate, 32 kHz sampling rate, read WAV from stdin, write MP3 to stdout $cmd = sprintf("%s -m m -v -b 32 %s -", self::$lame_binary_path, $wavinput); $proc = proc_open($cmd, $descriptors, $pipes); if (!is_resource($proc)) { throw new Exception('Failed to open process for MP3 encoding'); } stream_set_blocking($pipes[0], 0); // set stdin to be non-blocking for ($written = 0; $written < $size; $written += $len) { // write to stdin until all WAV data is written $len = fwrite($pipes[0], substr($data, $written, 0x20000)); if ($len === 0) { // fwrite wrote no data, make sure process is still alive, otherwise wait for it to process $status = proc_get_status($proc); if ($status['running'] === false) break; usleep(25000); } else if ($written < $size) { // couldn't write all data, small pause and try again usleep(10000); } else if ($len === false) { // fwrite failed, should not happen break; } } fclose($pipes[0]); $data = stream_get_contents($pipes[1]); $err = trim(stream_get_contents($pipes[2])); fclose($pipes[1]); fclose($pipes[2]); $return = proc_close($proc); if ($wavinput != '-') unlink($wavinput); // delete temp file on Windows if ($return !== 0) { throw new Exception("Failed to convert WAV to MP3. Shell returned ({$return}): {$err}"); } else if ($written < $size) { throw new Exception('Failed to convert WAV to MP3. Failed to write all data to encoder'); } return $data; }
[ "protected", "function", "wavToMp3", "(", "$", "data", ")", "{", "if", "(", "!", "file_exists", "(", "self", "::", "$", "lame_binary_path", ")", "||", "!", "is_executable", "(", "self", "::", "$", "lame_binary_path", ")", ")", "{", "throw", "new", "Excep...
Convert WAV data to MP3 using the Lame MP3 encoder binary @param string $data Contents of the WAV file to convert @return string MP3 file data
[ "Convert", "WAV", "data", "to", "MP3", "using", "the", "Lame", "MP3", "encoder", "binary" ]
train
https://github.com/dapphp/securimage/blob/1ecb884797c66e01a875c058def46c85aecea45b/securimage.php#L3419-L3495
dapphp/securimage
securimage.php
Securimage.initColor
protected function initColor($color, $default) { if ($color == null) { return new Securimage_Color($default); } else if (is_string($color)) { try { return new Securimage_Color($color); } catch(Exception $e) { return new Securimage_Color($default); } } else if (is_array($color) && sizeof($color) == 3) { return new Securimage_Color($color[0], $color[1], $color[2]); } else { return new Securimage_Color($default); } }
php
protected function initColor($color, $default) { if ($color == null) { return new Securimage_Color($default); } else if (is_string($color)) { try { return new Securimage_Color($color); } catch(Exception $e) { return new Securimage_Color($default); } } else if (is_array($color) && sizeof($color) == 3) { return new Securimage_Color($color[0], $color[1], $color[2]); } else { return new Securimage_Color($default); } }
[ "protected", "function", "initColor", "(", "$", "color", ",", "$", "default", ")", "{", "if", "(", "$", "color", "==", "null", ")", "{", "return", "new", "Securimage_Color", "(", "$", "default", ")", ";", "}", "else", "if", "(", "is_string", "(", "$"...
Convert an html color code to a Securimage_Color @param string $color @param Securimage_Color|string $default The defalt color to use if $color is invalid
[ "Convert", "an", "html", "color", "code", "to", "a", "Securimage_Color" ]
train
https://github.com/dapphp/securimage/blob/1ecb884797c66e01a875c058def46c85aecea45b/securimage.php#L3578-L3593
dapphp/securimage
securimage.php
Securimage.errorHandler
public function errorHandler($errno, $errstr, $errfile = '', $errline = 0, $errcontext = array()) { // get the current error reporting level $level = error_reporting(); // if error was supressed or $errno not set in current error level if ($level == 0 || ($level & $errno) == 0) { return true; } return false; }
php
public function errorHandler($errno, $errstr, $errfile = '', $errline = 0, $errcontext = array()) { // get the current error reporting level $level = error_reporting(); // if error was supressed or $errno not set in current error level if ($level == 0 || ($level & $errno) == 0) { return true; } return false; }
[ "public", "function", "errorHandler", "(", "$", "errno", ",", "$", "errstr", ",", "$", "errfile", "=", "''", ",", "$", "errline", "=", "0", ",", "$", "errcontext", "=", "array", "(", ")", ")", "{", "// get the current error reporting level", "$", "level", ...
The error handling function used when outputting captcha image or audio. This error handler helps determine if any errors raised would prevent captcha image or audio from displaying. If they have no effect on the output buffer or headers, true is returned so the script can continue processing. See https://github.com/dapphp/securimage/issues/15 @param int $errno PHP error number @param string $errstr String description of the error @param string $errfile File error occurred in @param int $errline Line the error occurred on in file @param array $errcontext Additional context information @return boolean true if the error was handled, false if PHP should handle the error
[ "The", "error", "handling", "function", "used", "when", "outputting", "captcha", "image", "or", "audio", "." ]
train
https://github.com/dapphp/securimage/blob/1ecb884797c66e01a875c058def46c85aecea45b/securimage.php#L3623-L3634
dapphp/securimage
securimage.php
Securimage_Color.constructRGB
protected function constructRGB($red, $green, $blue) { if ($red < 0) $red = 0; if ($red > 255) $red = 255; if ($green < 0) $green = 0; if ($green > 255) $green = 255; if ($blue < 0) $blue = 0; if ($blue > 255) $blue = 255; $this->r = $red; $this->g = $green; $this->b = $blue; }
php
protected function constructRGB($red, $green, $blue) { if ($red < 0) $red = 0; if ($red > 255) $red = 255; if ($green < 0) $green = 0; if ($green > 255) $green = 255; if ($blue < 0) $blue = 0; if ($blue > 255) $blue = 255; $this->r = $red; $this->g = $green; $this->b = $blue; }
[ "protected", "function", "constructRGB", "(", "$", "red", ",", "$", "green", ",", "$", "blue", ")", "{", "if", "(", "$", "red", "<", "0", ")", "$", "red", "=", "0", ";", "if", "(", "$", "red", ">", "255", ")", "$", "red", "=", "255", ";", "...
Construct from an rgb triplet @param int $red The red component, 0-255 @param int $green The green component, 0-255 @param int $blue The blue component, 0-255
[ "Construct", "from", "an", "rgb", "triplet" ]
train
https://github.com/dapphp/securimage/blob/1ecb884797c66e01a875c058def46c85aecea45b/securimage.php#L3735-L3747
dapphp/securimage
securimage.php
Securimage_Color.constructHTML
protected function constructHTML($color) { if (strlen($color) == 3) { $red = str_repeat(substr($color, 0, 1), 2); $green = str_repeat(substr($color, 1, 1), 2); $blue = str_repeat(substr($color, 2, 1), 2); } else { $red = substr($color, 0, 2); $green = substr($color, 2, 2); $blue = substr($color, 4, 2); } $this->r = hexdec($red); $this->g = hexdec($green); $this->b = hexdec($blue); }
php
protected function constructHTML($color) { if (strlen($color) == 3) { $red = str_repeat(substr($color, 0, 1), 2); $green = str_repeat(substr($color, 1, 1), 2); $blue = str_repeat(substr($color, 2, 1), 2); } else { $red = substr($color, 0, 2); $green = substr($color, 2, 2); $blue = substr($color, 4, 2); } $this->r = hexdec($red); $this->g = hexdec($green); $this->b = hexdec($blue); }
[ "protected", "function", "constructHTML", "(", "$", "color", ")", "{", "if", "(", "strlen", "(", "$", "color", ")", "==", "3", ")", "{", "$", "red", "=", "str_repeat", "(", "substr", "(", "$", "color", ",", "0", ",", "1", ")", ",", "2", ")", ";...
Construct from an html hex color code @param string $color
[ "Construct", "from", "an", "html", "hex", "color", "code" ]
train
https://github.com/dapphp/securimage/blob/1ecb884797c66e01a875c058def46c85aecea45b/securimage.php#L3754-L3769
eveseat/web
src/Http/Composers/AbstractMenu.php
AbstractMenu.load_plugin_menu
public function load_plugin_menu($package_name, $menu_data, bool $require_affiliation = false) { // Validate the package menu $this->validate_menu($package_name, $menu_data); // Check if the current user has the permission // required to see the menu if (isset($menu_data['permission'])) { // Check if the parameter is an array // in such case, we grant access if user has at least one permission if (is_array($menu_data['permission'])) { foreach ($menu_data['permission'] as $menu_permission) if (auth()->user()->has($menu_permission, $require_affiliation)) return $menu_data; return null; } if (! auth()->user()->has($menu_data['permission'], $require_affiliation)) return null; } return $menu_data; }
php
public function load_plugin_menu($package_name, $menu_data, bool $require_affiliation = false) { // Validate the package menu $this->validate_menu($package_name, $menu_data); // Check if the current user has the permission // required to see the menu if (isset($menu_data['permission'])) { // Check if the parameter is an array // in such case, we grant access if user has at least one permission if (is_array($menu_data['permission'])) { foreach ($menu_data['permission'] as $menu_permission) if (auth()->user()->has($menu_permission, $require_affiliation)) return $menu_data; return null; } if (! auth()->user()->has($menu_data['permission'], $require_affiliation)) return null; } return $menu_data; }
[ "public", "function", "load_plugin_menu", "(", "$", "package_name", ",", "$", "menu_data", ",", "bool", "$", "require_affiliation", "=", "false", ")", "{", "// Validate the package menu", "$", "this", "->", "validate_menu", "(", "$", "package_name", ",", "$", "m...
Load menus from any registered plugins. This may end up being quite a complex method, as we need to validate a lot of the menu structure that is set out. Packages should register menu items in a config file, loaded in a ServiceProvider's register() method in the 'package.sidebar' namespace. The structure of these menus can be seen in the SeAT Wiki. @param $package_name @param $menu_data @param $require_affiliation bool True if the menu is requiring affiliation @return array @throws \Seat\Web\Exceptions\PackageMenuBuilderException
[ "Load", "menus", "from", "any", "registered", "plugins", "." ]
train
https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Http/Composers/AbstractMenu.php#L58-L83
eveseat/web
src/Http/Composers/AbstractMenu.php
AbstractMenu.validate_menu
public function validate_menu($package_name, $menu_data) { if (! is_string($package_name)) throw new PackageMenuBuilderException( 'Package root menu items should be named by string type'); if (! is_array($menu_data)) throw new PackageMenuBuilderException( 'Package menu data should be defined in an array'); // check if required keys are all sets foreach ($this->getRequiredKeys() as $key) if (! array_key_exists($key, $menu_data)) throw new PackageMenuBuilderException( 'Menu should contain a ' . $key . ' entry'); // Check if we have sub entries. If not, we have to // check if we have a route defined in the parent // menu. if (! array_key_exists('entries', $menu_data)) if (! array_key_exists('route', $menu_data)) throw new PackageMenuBuilderException( 'A parent or sub-menu route is required.'); // Ensure that the entries is actually an array if (array_key_exists('entries', $menu_data) && ! is_array($menu_data['entries'])) throw new PackageMenuBuilderException( 'Root menu must define entries'); // Loop over the sub menu entries, validating the // required fields if (isset($menu_data['entries'])) { foreach ($menu_data['entries'] as $entry) { if (! array_key_exists('name', $entry)) throw new PackageMenuBuilderException( 'A sub menu entry failed to define a name'); if (! array_key_exists('icon', $entry)) throw new PackageMenuBuilderException( 'A sub menu entry failed to define an icon'); if (! array_key_exists('route', $entry)) throw new PackageMenuBuilderException( 'A sub menu entry failed to define a route'); if (isset($entry['entries'])) { foreach ($entry['entries'] as $subentry) { if (! array_key_exists('name', $subentry)) throw new PackageMenuBuilderException( 'A sub menu entry failed to define a name'); if (! array_key_exists('icon', $subentry)) throw new PackageMenuBuilderException( 'A sub menu entry failed to define an icon'); if (! array_key_exists('route', $subentry)) throw new PackageMenuBuilderException( 'A sub menu entry failed to define a route'); } } } } }
php
public function validate_menu($package_name, $menu_data) { if (! is_string($package_name)) throw new PackageMenuBuilderException( 'Package root menu items should be named by string type'); if (! is_array($menu_data)) throw new PackageMenuBuilderException( 'Package menu data should be defined in an array'); // check if required keys are all sets foreach ($this->getRequiredKeys() as $key) if (! array_key_exists($key, $menu_data)) throw new PackageMenuBuilderException( 'Menu should contain a ' . $key . ' entry'); // Check if we have sub entries. If not, we have to // check if we have a route defined in the parent // menu. if (! array_key_exists('entries', $menu_data)) if (! array_key_exists('route', $menu_data)) throw new PackageMenuBuilderException( 'A parent or sub-menu route is required.'); // Ensure that the entries is actually an array if (array_key_exists('entries', $menu_data) && ! is_array($menu_data['entries'])) throw new PackageMenuBuilderException( 'Root menu must define entries'); // Loop over the sub menu entries, validating the // required fields if (isset($menu_data['entries'])) { foreach ($menu_data['entries'] as $entry) { if (! array_key_exists('name', $entry)) throw new PackageMenuBuilderException( 'A sub menu entry failed to define a name'); if (! array_key_exists('icon', $entry)) throw new PackageMenuBuilderException( 'A sub menu entry failed to define an icon'); if (! array_key_exists('route', $entry)) throw new PackageMenuBuilderException( 'A sub menu entry failed to define a route'); if (isset($entry['entries'])) { foreach ($entry['entries'] as $subentry) { if (! array_key_exists('name', $subentry)) throw new PackageMenuBuilderException( 'A sub menu entry failed to define a name'); if (! array_key_exists('icon', $subentry)) throw new PackageMenuBuilderException( 'A sub menu entry failed to define an icon'); if (! array_key_exists('route', $subentry)) throw new PackageMenuBuilderException( 'A sub menu entry failed to define a route'); } } } } }
[ "public", "function", "validate_menu", "(", "$", "package_name", ",", "$", "menu_data", ")", "{", "if", "(", "!", "is_string", "(", "$", "package_name", ")", ")", "throw", "new", "PackageMenuBuilderException", "(", "'Package root menu items should be named by string t...
The actual menu validation logic. @param $package_name @param $menu_data @throws \Seat\Web\Exceptions\PackageMenuBuilderException
[ "The", "actual", "menu", "validation", "logic", "." ]
train
https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Http/Composers/AbstractMenu.php#L93-L162
eveseat/web
src/Http/Controllers/Character/MailController.php
MailController.getMailData
public function getMailData(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; $mail = $this->getCharacterMail($character_ids); return DataTables::of($mail) ->editColumn('from', function ($row) { $character_id = $row->character_id; $character = CharacterInfo::find($row->from) ?: $row->from; return view('web::partials.character', compact('character', 'character_id')); }) ->editColumn('subject', function ($row) { return view('web::character.partials.mailtitle', compact('row')); }) ->editColumn('tocounts', function ($row) { return view('web::character.partials.mailtocounts', compact('row')); }) ->addColumn('read', function ($row) { return view('web::character.partials.mailread', compact('row')); }) ->rawColumns(['from', 'subject', 'tocounts', 'read']) ->make(true); }
php
public function getMailData(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; $mail = $this->getCharacterMail($character_ids); return DataTables::of($mail) ->editColumn('from', function ($row) { $character_id = $row->character_id; $character = CharacterInfo::find($row->from) ?: $row->from; return view('web::partials.character', compact('character', 'character_id')); }) ->editColumn('subject', function ($row) { return view('web::character.partials.mailtitle', compact('row')); }) ->editColumn('tocounts', function ($row) { return view('web::character.partials.mailtocounts', compact('row')); }) ->addColumn('read', function ($row) { return view('web::character.partials.mailread', compact('row')); }) ->rawColumns(['from', 'subject', 'tocounts', 'read']) ->make(true); }
[ "public", "function", "getMailData", "(", "int", "$", "character_id", ")", "{", "if", "(", "!", "request", "(", ")", "->", "has", "(", "'all_linked_characters'", ")", ")", "return", "abort", "(", "500", ")", ";", "if", "(", "request", "(", "'all_linked_c...
@param int $character_id @return mixed @throws \Exception
[ "@param", "int", "$character_id" ]
train
https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Http/Controllers/Character/MailController.php#L58-L104
eveseat/web
src/Http/Controllers/Character/MailController.php
MailController.getMailRead
public function getMailRead(int $character_id, int $message_id) { $message = $this->getCharacterMailMessage($character_id, $message_id); $from = CharacterInfo::find($message->from) ?: $message->from; $characters = $message ->recipients ->where('recipient_type', 'character') ->map(function ($recipient) { return CharacterInfo::find($recipient->recipient_id) ?: $recipient->recipient_id; }); $corporations = $message ->recipients ->where('recipient_type', 'corporation') ->map(function ($recipient) { return CorporationInfo::find($recipient->recipient_id) ?: $recipient->recipient_id; }); return view('web::character.mail-read', compact('message', 'from', 'characters', 'corporations')) ->render(); }
php
public function getMailRead(int $character_id, int $message_id) { $message = $this->getCharacterMailMessage($character_id, $message_id); $from = CharacterInfo::find($message->from) ?: $message->from; $characters = $message ->recipients ->where('recipient_type', 'character') ->map(function ($recipient) { return CharacterInfo::find($recipient->recipient_id) ?: $recipient->recipient_id; }); $corporations = $message ->recipients ->where('recipient_type', 'corporation') ->map(function ($recipient) { return CorporationInfo::find($recipient->recipient_id) ?: $recipient->recipient_id; }); return view('web::character.mail-read', compact('message', 'from', 'characters', 'corporations')) ->render(); }
[ "public", "function", "getMailRead", "(", "int", "$", "character_id", ",", "int", "$", "message_id", ")", "{", "$", "message", "=", "$", "this", "->", "getCharacterMailMessage", "(", "$", "character_id", ",", "$", "message_id", ")", ";", "$", "from", "=", ...
@param int $character_id @param int $message_id @return \Illuminate\View\View @throws \Throwable
[ "@param", "int", "$character_id", "@param", "int", "$message_id" ]
train
https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Http/Controllers/Character/MailController.php#L113-L139
eveseat/web
src/Http/Controllers/Corporation/WalletController.php
WalletController.getJournalData
public function getJournalData(int $corporation_id) { if (! request()->has('division')) return abort(500); $journal = $this->getCorporationWalletJournal($corporation_id, (int) request('division')); return DataTables::of($journal) ->editColumn('ref_type', function ($row) { return view('web::partials.journaltranstype', compact('row')); }) ->editColumn('first_party_id', function ($row) { $character_id = $row->character_id; if (optional($row->first_party)->category === 'character') { $character = CharacterInfo::find($row->first_party_id) ?: $row->first_party_id; return view('web::partials.character', compact('character', 'character_id')); } if (optional($row->first_party)->category === 'corporation'){ $corporation = CorporationInfo::find($row->first_party_id) ?: $row->first_party_id; return view('web::partials.corporation', compact('corporation', 'character_id')); } return view('web::partials.unknown', [ 'unknown_id' => $row->first_party_id, 'character_id' => $character_id, ]); }) ->editColumn('second_party_id', function ($row) { $character_id = $row->character_id; if (optional($row->second_party)->category === 'character') { $character = CharacterInfo::find($row->second_party_id) ?: $row->second_party_id; return view('web::partials.character', compact('character', 'character_id')); } if (optional($row->second_party)->category === 'corporation') { $corporation = CorporationInfo::find($row->second_party_id) ?: $row->second_party_id; return view('web::partials.corporation', compact('corporation', 'character_id')); } return view('web::partials.unknown', [ 'unknown_id' => $row->second_party_id, 'character_id' => $character_id, ]); }) ->editColumn('amount', function ($row) { return number($row->amount); }) ->editColumn('balance', function ($row) { return number($row->balance); }) ->rawColumns(['ref_type', 'first_party_id', 'second_party_id']) ->make(true); }
php
public function getJournalData(int $corporation_id) { if (! request()->has('division')) return abort(500); $journal = $this->getCorporationWalletJournal($corporation_id, (int) request('division')); return DataTables::of($journal) ->editColumn('ref_type', function ($row) { return view('web::partials.journaltranstype', compact('row')); }) ->editColumn('first_party_id', function ($row) { $character_id = $row->character_id; if (optional($row->first_party)->category === 'character') { $character = CharacterInfo::find($row->first_party_id) ?: $row->first_party_id; return view('web::partials.character', compact('character', 'character_id')); } if (optional($row->first_party)->category === 'corporation'){ $corporation = CorporationInfo::find($row->first_party_id) ?: $row->first_party_id; return view('web::partials.corporation', compact('corporation', 'character_id')); } return view('web::partials.unknown', [ 'unknown_id' => $row->first_party_id, 'character_id' => $character_id, ]); }) ->editColumn('second_party_id', function ($row) { $character_id = $row->character_id; if (optional($row->second_party)->category === 'character') { $character = CharacterInfo::find($row->second_party_id) ?: $row->second_party_id; return view('web::partials.character', compact('character', 'character_id')); } if (optional($row->second_party)->category === 'corporation') { $corporation = CorporationInfo::find($row->second_party_id) ?: $row->second_party_id; return view('web::partials.corporation', compact('corporation', 'character_id')); } return view('web::partials.unknown', [ 'unknown_id' => $row->second_party_id, 'character_id' => $character_id, ]); }) ->editColumn('amount', function ($row) { return number($row->amount); }) ->editColumn('balance', function ($row) { return number($row->balance); }) ->rawColumns(['ref_type', 'first_party_id', 'second_party_id']) ->make(true); }
[ "public", "function", "getJournalData", "(", "int", "$", "corporation_id", ")", "{", "if", "(", "!", "request", "(", ")", "->", "has", "(", "'division'", ")", ")", "return", "abort", "(", "500", ")", ";", "$", "journal", "=", "$", "this", "->", "getC...
@param int $corporation_id @return mixed @throws \Exception
[ "@param", "int", "$corporation_id" ]
train
https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Http/Controllers/Corporation/WalletController.php#L59-L128
eveseat/web
src/Http/Controllers/Corporation/WalletController.php
WalletController.getTransactionsData
public function getTransactionsData(int $corporation_id) { $transactions = $this->getCorporationWalletTransactions($corporation_id, false); return DataTables::of($transactions) ->editColumn('is_buy', function ($row) { return view('web::partials.transactiontype', compact('row')) ->render(); }) ->editColumn('unit_price', function ($row) { return number($row->unit_price); }) ->addColumn('total', function ($row) { return number($row->unit_price * $row->quantity); }) ->editColumn('client_id', function ($row) { return view('web::partials.transactionclient', compact('row')) ->render(); }) ->rawColumns(['is_buy', 'client_id']) ->make(true); }
php
public function getTransactionsData(int $corporation_id) { $transactions = $this->getCorporationWalletTransactions($corporation_id, false); return DataTables::of($transactions) ->editColumn('is_buy', function ($row) { return view('web::partials.transactiontype', compact('row')) ->render(); }) ->editColumn('unit_price', function ($row) { return number($row->unit_price); }) ->addColumn('total', function ($row) { return number($row->unit_price * $row->quantity); }) ->editColumn('client_id', function ($row) { return view('web::partials.transactionclient', compact('row')) ->render(); }) ->rawColumns(['is_buy', 'client_id']) ->make(true); }
[ "public", "function", "getTransactionsData", "(", "int", "$", "corporation_id", ")", "{", "$", "transactions", "=", "$", "this", "->", "getCorporationWalletTransactions", "(", "$", "corporation_id", ",", "false", ")", ";", "return", "DataTables", "::", "of", "("...
@param int $corporation_id @return mixed @throws \Exception
[ "@param", "int", "$corporation_id" ]
train
https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Http/Controllers/Corporation/WalletController.php#L147-L174
eveseat/web
src/Http/Controllers/Corporation/LedgerController.php
LedgerController.getBountyPrizesByMonth
public function getBountyPrizesByMonth(int $corporation_id, $year = null, $month = null) { ! is_null($year) ? $year : $year = date('Y'); ! is_null($month) ? $year : $month = date('m'); $bountyprizes = $this->getCorporationLedgerBountyPrizeDates( $corporation_id); $bountyprizedates = $this->getCorporationLedgerBountyPrizeByMonth( $corporation_id, $year, $month); return view('web::corporation.ledger.bountyprizesbymonth', compact('bountyprizes', 'bountyprizedates', 'corporation_id', 'month', 'year')); }
php
public function getBountyPrizesByMonth(int $corporation_id, $year = null, $month = null) { ! is_null($year) ? $year : $year = date('Y'); ! is_null($month) ? $year : $month = date('m'); $bountyprizes = $this->getCorporationLedgerBountyPrizeDates( $corporation_id); $bountyprizedates = $this->getCorporationLedgerBountyPrizeByMonth( $corporation_id, $year, $month); return view('web::corporation.ledger.bountyprizesbymonth', compact('bountyprizes', 'bountyprizedates', 'corporation_id', 'month', 'year')); }
[ "public", "function", "getBountyPrizesByMonth", "(", "int", "$", "corporation_id", ",", "$", "year", "=", "null", ",", "$", "month", "=", "null", ")", "{", "!", "is_null", "(", "$", "year", ")", "?", "$", "year", ":", "$", "year", "=", "date", "(", ...
@param $corporation_id @param null $year @param null $month @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
[ "@param", "$corporation_id", "@param", "null", "$year", "@param", "null", "$month" ]
train
https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Http/Controllers/Corporation/LedgerController.php#L61-L76
eveseat/web
src/Http/Controllers/Corporation/LedgerController.php
LedgerController.getPlanetaryInteractionByMonth
public function getPlanetaryInteractionByMonth(int $corporation_id, $year = null, $month = null) { ! is_null($year) ? $year : $year = date('Y'); ! is_null($month) ? $year : $month = date('m'); $pidates = $this->getCorporationLedgerPIDates($corporation_id); $pitotals = $this->getCorporationLedgerPITotalsByMonth( $corporation_id, $year, $month); return view('web::corporation.ledger.planetaryinteraction', compact('pidates', 'pitotals', 'corporation_id', 'month', 'year')); }
php
public function getPlanetaryInteractionByMonth(int $corporation_id, $year = null, $month = null) { ! is_null($year) ? $year : $year = date('Y'); ! is_null($month) ? $year : $month = date('m'); $pidates = $this->getCorporationLedgerPIDates($corporation_id); $pitotals = $this->getCorporationLedgerPITotalsByMonth( $corporation_id, $year, $month); return view('web::corporation.ledger.planetaryinteraction', compact('pidates', 'pitotals', 'corporation_id', 'month', 'year')); }
[ "public", "function", "getPlanetaryInteractionByMonth", "(", "int", "$", "corporation_id", ",", "$", "year", "=", "null", ",", "$", "month", "=", "null", ")", "{", "!", "is_null", "(", "$", "year", ")", "?", "$", "year", ":", "$", "year", "=", "date", ...
@param $corporation_id @param null $year @param null $month @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
[ "@param", "$corporation_id", "@param", "null", "$year", "@param", "null", "$month" ]
train
https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Http/Controllers/Corporation/LedgerController.php#L85-L98
eveseat/web
src/Events/SecLog.php
SecLog.handle
public static function handle($message, $category = null) { SecurityLog::create([ 'message' => $message, 'category' => $category, 'user_id' => auth()->user() ? auth()->user()->id : null, ]); }
php
public static function handle($message, $category = null) { SecurityLog::create([ 'message' => $message, 'category' => $category, 'user_id' => auth()->user() ? auth()->user()->id : null, ]); }
[ "public", "static", "function", "handle", "(", "$", "message", ",", "$", "category", "=", "null", ")", "{", "SecurityLog", "::", "create", "(", "[", "'message'", "=>", "$", "message", ",", "'category'", "=>", "$", "category", ",", "'user_id'", "=>", "aut...
Write an entry in the security log. @param $message @param $category
[ "Write", "an", "entry", "in", "the", "security", "log", "." ]
train
https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Events/SecLog.php#L35-L45
eveseat/web
src/Extentions/EveOnlineProvider.php
EveOnlineProvider.user
public function user() { if ($this->hasInvalidState()) throw new InvalidStateException; $tokens = $this->getAccessTokenResponse($this->getCode()); $user = $this->mapUserToObject( array_merge( $this->getUserByToken($tokens['access_token']), [ 'RefreshToken' => $tokens['refresh_token'], ] ) ); return $user->setToken($tokens['access_token']); }
php
public function user() { if ($this->hasInvalidState()) throw new InvalidStateException; $tokens = $this->getAccessTokenResponse($this->getCode()); $user = $this->mapUserToObject( array_merge( $this->getUserByToken($tokens['access_token']), [ 'RefreshToken' => $tokens['refresh_token'], ] ) ); return $user->setToken($tokens['access_token']); }
[ "public", "function", "user", "(", ")", "{", "if", "(", "$", "this", "->", "hasInvalidState", "(", ")", ")", "throw", "new", "InvalidStateException", ";", "$", "tokens", "=", "$", "this", "->", "getAccessTokenResponse", "(", "$", "this", "->", "getCode", ...
Get the User instance for the authenticated user. @return \Laravel\Socialite\Contracts\User
[ "Get", "the", "User", "instance", "for", "the", "authenticated", "user", "." ]
train
https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Extentions/EveOnlineProvider.php#L56-L73
eveseat/web
src/Extentions/EveOnlineProvider.php
EveOnlineProvider.mapUserToObject
protected function mapUserToObject(array $user): User { return (new User)->setRaw($user)->map([ 'character_id' => $user['CharacterID'], 'name' => $user['CharacterName'], 'character_owner_hash' => $user['CharacterOwnerHash'], 'scopes' => $user['Scopes'], 'refresh_token' => $user['RefreshToken'], 'expires_on' => Carbon($user['ExpiresOn']), 'avatar' => $this->imageUrl . $user['CharacterID'] . '_128.jpg', ]); }
php
protected function mapUserToObject(array $user): User { return (new User)->setRaw($user)->map([ 'character_id' => $user['CharacterID'], 'name' => $user['CharacterName'], 'character_owner_hash' => $user['CharacterOwnerHash'], 'scopes' => $user['Scopes'], 'refresh_token' => $user['RefreshToken'], 'expires_on' => Carbon($user['ExpiresOn']), 'avatar' => $this->imageUrl . $user['CharacterID'] . '_128.jpg', ]); }
[ "protected", "function", "mapUserToObject", "(", "array", "$", "user", ")", ":", "User", "{", "return", "(", "new", "User", ")", "->", "setRaw", "(", "$", "user", ")", "->", "map", "(", "[", "'character_id'", "=>", "$", "user", "[", "'CharacterID'", "]...
Map the raw user array to a Socialite User instance. @param array $user @return \Laravel\Socialite\Two\User
[ "Map", "the", "raw", "user", "array", "to", "a", "Socialite", "User", "instance", "." ]
train
https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Extentions/EveOnlineProvider.php#L82-L94
eveseat/web
src/Http/Composers/CharacterSummary.php
CharacterSummary.compose
public function compose(View $view) { $owner = $this->getUser($this->request->character_id); $summary = $owner->character; $characters = $owner->group->users; $view->with('summary', $summary); $view->with('characters', $characters); }
php
public function compose(View $view) { $owner = $this->getUser($this->request->character_id); $summary = $owner->character; $characters = $owner->group->users; $view->with('summary', $summary); $view->with('characters', $characters); }
[ "public", "function", "compose", "(", "View", "$", "view", ")", "{", "$", "owner", "=", "$", "this", "->", "getUser", "(", "$", "this", "->", "request", "->", "character_id", ")", ";", "$", "summary", "=", "$", "owner", "->", "character", ";", "$", ...
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/CharacterSummary.php#L60-L69
eveseat/web
src/Http/Controllers/Support/ListController.php
ListController.getInvTypes
public function getInvTypes(Request $request) { return response()->json([ 'results' => DB::table('invTypes') ->select('typeName as id', 'typeName as text') ->where('typeName', 'like', '%' . $request->q . '%')->get(), ]); }
php
public function getInvTypes(Request $request) { return response()->json([ 'results' => DB::table('invTypes') ->select('typeName as id', 'typeName as text') ->where('typeName', 'like', '%' . $request->q . '%')->get(), ]); }
[ "public", "function", "getInvTypes", "(", "Request", "$", "request", ")", "{", "return", "response", "(", ")", "->", "json", "(", "[", "'results'", "=>", "DB", "::", "table", "(", "'invTypes'", ")", "->", "select", "(", "'typeName as id'", ",", "'typeName ...
@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/Support/ListController.php#L40-L49
eveseat/web
src/Http/Controllers/Support/ListController.php
ListController.getSeatUserList
public function getSeatUserList(Request $request) { return response()->json([ 'results' => DB::table('users') ->select('id', 'name as text') ->where('name', 'like', '%' . $request->q . '%') ->orderBy('name', 'asc') ->get(), ]); }
php
public function getSeatUserList(Request $request) { return response()->json([ 'results' => DB::table('users') ->select('id', 'name as text') ->where('name', 'like', '%' . $request->q . '%') ->orderBy('name', 'asc') ->get(), ]); }
[ "public", "function", "getSeatUserList", "(", "Request", "$", "request", ")", "{", "return", "response", "(", ")", "->", "json", "(", "[", "'results'", "=>", "DB", "::", "table", "(", "'users'", ")", "->", "select", "(", "'id'", ",", "'name as text'", ")...
@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/Support/ListController.php#L56-L66
eveseat/web
src/Http/Validation/ReassignUser.php
ReassignUser.rules
public function rules() { return [ 'user_id' => 'required|exists:users,id', 'group_id' => [ 'required', 'exists:groups,id', function ($attribute, $value, $fail) { // retrieve admin group, if any $admin_group = Group::whereHas('users', function ($query) { $query->where('name', 'admin'); })->first(); // if the requested group_id is matching the admin one; skip if (! is_null($admin_group) && $admin_group->id == $value) { return $fail('You cannot attach any user to the admin group relationship.'); } }, ], ]; }
php
public function rules() { return [ 'user_id' => 'required|exists:users,id', 'group_id' => [ 'required', 'exists:groups,id', function ($attribute, $value, $fail) { // retrieve admin group, if any $admin_group = Group::whereHas('users', function ($query) { $query->where('name', 'admin'); })->first(); // if the requested group_id is matching the admin one; skip if (! is_null($admin_group) && $admin_group->id == $value) { return $fail('You cannot attach any user to the admin group relationship.'); } }, ], ]; }
[ "public", "function", "rules", "(", ")", "{", "return", "[", "'user_id'", "=>", "'required|exists:users,id'", ",", "'group_id'", "=>", "[", "'required'", ",", "'exists:groups,id'", ",", "function", "(", "$", "attribute", ",", "$", "value", ",", "$", "fail", ...
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/ReassignUser.php#L50-L73
eveseat/web
src/Http/Controllers/Character/SheetController.php
SheetController.getSheet
public function getSheet(int $character_id) { // TODO: Revert to repository pattern. // Ensure we've the public information for this character // If not, redirect back with an error. // TODO : queue a job which will pull public data for this toon if (! $character_info = CharacterInfo::find($character_id)) return redirect()->back() ->with('error', trans('web::seat.unknown_character')); $attributes = CharacterAttribute::find($character_id); $fatigue = CharacterFatigue::find($character_id); $employment = CharacterCorporationHistory::where('character_id', $character_id)->orderBy('record_id', 'desc')->get(); $implants = CharacterImplant::where('character_id', $character_id)->get(); $last_jump = CharacterClone::find($character_id); $jump_clones = CharacterJumpClone::where('character_id', $character_id)->get(); $skill_queue = CharacterSkillQueue::where('character_id', $character_id)->orderBy('queue_position')->get(); $titles = CharacterTitle::where('character_id', $character_id)->get(); return view('web::character.sheet', compact('attributes', 'fatigue', 'character_info', 'employment', 'implants', 'last_jump', 'jump_clones', 'skill_queue', 'titles')); }
php
public function getSheet(int $character_id) { // TODO: Revert to repository pattern. // Ensure we've the public information for this character // If not, redirect back with an error. // TODO : queue a job which will pull public data for this toon if (! $character_info = CharacterInfo::find($character_id)) return redirect()->back() ->with('error', trans('web::seat.unknown_character')); $attributes = CharacterAttribute::find($character_id); $fatigue = CharacterFatigue::find($character_id); $employment = CharacterCorporationHistory::where('character_id', $character_id)->orderBy('record_id', 'desc')->get(); $implants = CharacterImplant::where('character_id', $character_id)->get(); $last_jump = CharacterClone::find($character_id); $jump_clones = CharacterJumpClone::where('character_id', $character_id)->get(); $skill_queue = CharacterSkillQueue::where('character_id', $character_id)->orderBy('queue_position')->get(); $titles = CharacterTitle::where('character_id', $character_id)->get(); return view('web::character.sheet', compact('attributes', 'fatigue', 'character_info', 'employment', 'implants', 'last_jump', 'jump_clones', 'skill_queue', 'titles')); }
[ "public", "function", "getSheet", "(", "int", "$", "character_id", ")", "{", "// TODO: Revert to repository pattern.", "// Ensure we've the public information for this character", "// If not, redirect back with an error.", "// TODO : queue a job which will pull public data for this toon", ...
@param $character_id @return \Illuminate\View\View
[ "@param", "$character_id" ]
train
https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Http/Controllers/Character/SheetController.php#L54-L79
eveseat/web
src/Http/Controllers/Character/WalletController.php
WalletController.getJournalData
public function getJournalData(int $character_id) { 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) { return $user->name !== 'admin' && $user->id !== 1; }) ->pluck('id'); if (request('all_linked_characters') === 'true') $character_ids = $user_group; $journal = $this->getCharacterWalletJournal($character_ids); return DataTables::of($journal) ->editColumn('ref_type', function ($row) { return view('web::partials.journaltranstype', compact('row')); }) ->editColumn('first_party_id', function ($row) { $character_id = $row->character_id; if (optional($row->first_party)->category === 'character') { $character = CharacterInfo::find($row->first_party_id) ?: $row->first_party_id; return view('web::partials.character', compact('character', 'character_id')); } if (optional($row->first_party)->category === 'corporation'){ $corporation = CorporationInfo::find($row->first_party_id) ?: $row->first_party_id; return view('web::partials.corporation', compact('corporation', 'character_id')); } return view('web::partials.unknown', [ 'unknown_id' => $row->first_party_id, 'character_id' => $character_id, ]); }) ->editColumn('second_party_id', function ($row) { $character_id = $row->character_id; if (optional($row->second_party)->category === 'character') { $character = CharacterInfo::find($row->second_party_id) ?: $row->second_party_id; return view('web::partials.character', compact('character', 'character_id')); } if (optional($row->second_party)->category === 'corporation') { $corporation = CorporationInfo::find($row->second_party_id) ?: $row->second_party_id; return view('web::partials.corporation', compact('corporation', 'character_id')); } return view('web::partials.unknown', [ 'unknown_id' => $row->second_party_id, 'character_id' => $character_id, ]); }) ->editColumn('amount', function ($row) { return number($row->amount); }) ->editColumn('balance', function ($row) { return number($row->balance); }) ->addColumn('is_in_group', function ($row) use ($user_group) { return in_array($row->first_party_id, $user_group->toArray()) && in_array($row->second_party_id, $user_group->toArray()); }) ->rawColumns(['ref_type', 'first_party_id', 'second_party_id']) ->make(true); }
php
public function getJournalData(int $character_id) { 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) { return $user->name !== 'admin' && $user->id !== 1; }) ->pluck('id'); if (request('all_linked_characters') === 'true') $character_ids = $user_group; $journal = $this->getCharacterWalletJournal($character_ids); return DataTables::of($journal) ->editColumn('ref_type', function ($row) { return view('web::partials.journaltranstype', compact('row')); }) ->editColumn('first_party_id', function ($row) { $character_id = $row->character_id; if (optional($row->first_party)->category === 'character') { $character = CharacterInfo::find($row->first_party_id) ?: $row->first_party_id; return view('web::partials.character', compact('character', 'character_id')); } if (optional($row->first_party)->category === 'corporation'){ $corporation = CorporationInfo::find($row->first_party_id) ?: $row->first_party_id; return view('web::partials.corporation', compact('corporation', 'character_id')); } return view('web::partials.unknown', [ 'unknown_id' => $row->first_party_id, 'character_id' => $character_id, ]); }) ->editColumn('second_party_id', function ($row) { $character_id = $row->character_id; if (optional($row->second_party)->category === 'character') { $character = CharacterInfo::find($row->second_party_id) ?: $row->second_party_id; return view('web::partials.character', compact('character', 'character_id')); } if (optional($row->second_party)->category === 'corporation') { $corporation = CorporationInfo::find($row->second_party_id) ?: $row->second_party_id; return view('web::partials.corporation', compact('corporation', 'character_id')); } return view('web::partials.unknown', [ 'unknown_id' => $row->second_party_id, 'character_id' => $character_id, ]); }) ->editColumn('amount', function ($row) { return number($row->amount); }) ->editColumn('balance', function ($row) { return number($row->balance); }) ->addColumn('is_in_group', function ($row) use ($user_group) { return in_array($row->first_party_id, $user_group->toArray()) && in_array($row->second_party_id, $user_group->toArray()); }) ->rawColumns(['ref_type', 'first_party_id', 'second_party_id']) ->make(true); }
[ "public", "function", "getJournalData", "(", "int", "$", "character_id", ")", "{", "if", "(", "!", "request", "(", ")", "->", "has", "(", "'all_linked_characters'", ")", ")", "return", "response", "(", "'required url parameter is missing!'", ",", "400", ")", "...
@param int $character_id @return mixed @throws \Exception
[ "@param", "int", "$character_id" ]
train
https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Http/Controllers/Character/WalletController.php#L57-L142
eveseat/web
src/Http/Controllers/Character/WalletController.php
WalletController.getJournalGraphBalance
public function getJournalGraphBalance(int $character_id) { $data = $this->getCharacterWalletJournal(collect($character_id)) ->orderBy('date', 'desc') ->take(150) ->get(); return response()->json([ 'labels' => $data->map(function ($item) { return $item->date; })->toArray(), 'datasets' => [ [ 'label' => 'Balance', 'fill' => false, 'lineTension' => 0.1, 'backgroundColor' => 'rgba(60,141,188,0.9)', 'borderColor' => 'rgba(60,141,188,0.8)', 'data' => $data->map(function ($item) { return $item->balance; })->toArray(), ], [ 'label' => 'Amount', 'fill' => false, 'lineTension' => 0.1, 'backgroundColor' => 'rgba(210, 214, 222, 1)', 'borderColor' => 'rgba(210, 214, 222, 1)', 'data' => $data->map(function ($item) { return $item->amount; })->toArray(), ], ], ]); }
php
public function getJournalGraphBalance(int $character_id) { $data = $this->getCharacterWalletJournal(collect($character_id)) ->orderBy('date', 'desc') ->take(150) ->get(); return response()->json([ 'labels' => $data->map(function ($item) { return $item->date; })->toArray(), 'datasets' => [ [ 'label' => 'Balance', 'fill' => false, 'lineTension' => 0.1, 'backgroundColor' => 'rgba(60,141,188,0.9)', 'borderColor' => 'rgba(60,141,188,0.8)', 'data' => $data->map(function ($item) { return $item->balance; })->toArray(), ], [ 'label' => 'Amount', 'fill' => false, 'lineTension' => 0.1, 'backgroundColor' => 'rgba(210, 214, 222, 1)', 'borderColor' => 'rgba(210, 214, 222, 1)', 'data' => $data->map(function ($item) { return $item->amount; })->toArray(), ], ], ]); }
[ "public", "function", "getJournalGraphBalance", "(", "int", "$", "character_id", ")", "{", "$", "data", "=", "$", "this", "->", "getCharacterWalletJournal", "(", "collect", "(", "$", "character_id", ")", ")", "->", "orderBy", "(", "'date'", ",", "'desc'", ")...
@param int $character_id @return \Illuminate\Http\JsonResponse
[ "@param", "int", "$character_id" ]
train
https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Http/Controllers/Character/WalletController.php#L149-L187
eveseat/web
src/Http/Controllers/Character/WalletController.php
WalletController.getTransactionsData
public function getTransactionsData(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; $transactions = $this->getCharacterWalletTransactions($character_ids); return DataTables::of($transactions) ->editColumn('is_buy', function ($row) { return view('web::partials.transactionbuysell', compact('row')); }) ->editColumn('unit_price', function ($row) { return number($row->unit_price); }) ->addColumn('item_view', function ($row) { return view('web::partials.transactiontype', compact('row')); }) ->addColumn('total', function ($row) { return number($row->unit_price * $row->quantity); }) ->addColumn('client_view', function ($row) { $character_id = $row->character_id; $character = CharacterInfo::find($row->client_id) ?: $row->client_id; return view('web::partials.character', compact('character', 'character_id')); }) ->rawColumns(['is_buy', 'client_view', 'item_view']) ->make(true); }
php
public function getTransactionsData(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; $transactions = $this->getCharacterWalletTransactions($character_ids); return DataTables::of($transactions) ->editColumn('is_buy', function ($row) { return view('web::partials.transactionbuysell', compact('row')); }) ->editColumn('unit_price', function ($row) { return number($row->unit_price); }) ->addColumn('item_view', function ($row) { return view('web::partials.transactiontype', compact('row')); }) ->addColumn('total', function ($row) { return number($row->unit_price * $row->quantity); }) ->addColumn('client_view', function ($row) { $character_id = $row->character_id; $character = CharacterInfo::find($row->client_id) ?: $row->client_id; return view('web::partials.character', compact('character', 'character_id')); }) ->rawColumns(['is_buy', 'client_view', 'item_view']) ->make(true); }
[ "public", "function", "getTransactionsData", "(", "int", "$", "character_id", ")", "{", "if", "(", "!", "request", "(", ")", "->", "has", "(", "'all_linked_characters'", ")", ")", "return", "abort", "(", "500", ")", ";", "if", "(", "request", "(", "'all_...
@param int $character_id @return mixed @throws \Exception
[ "@param", "int", "$character_id" ]
train
https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Http/Controllers/Character/WalletController.php#L206-L254
eveseat/web
src/Http/Controllers/Character/IntelController.php
IntelController.getTopWalletJournalData
public function getTopWalletJournalData(int $character_id) { if (! request()->has('all_linked_characters')) return abort(500); $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; $top = $this->characterTopWalletJournalInteractions($character_ids); $user_group = User::find($character_id)->group->users ->filter(function ($user) { return $user->name !== 'admin' && $user->id !== 1; }) ->pluck('id'); return DataTables::of($top) ->editColumn('ref_type', function ($row) { return ucwords(str_replace('_', ' ', $row->ref_type)); }) ->addColumn('character', function ($row) { return $this->getIntelView('character', $row->character_id, $row->first_party_id, $row->second_party_id); }) ->addColumn('corporation', function ($row) { return $this->getIntelView('corporation', $row->character_id, $row->first_party_id, $row->second_party_id); }) ->addColumn('alliance', function ($row) { return $this->getIntelView('alliance', $row->character_id, $row->first_party_id, $row->second_party_id) . view('web::character.intel.partials.journalcontentbutton', compact('row')); }) ->addColumn('is_in_group', function ($row) use ($user_group) { return in_array($row->first_party_id, $user_group->toArray()) && in_array($row->second_party_id, $user_group->toArray()); }) ->rawColumns(['character', 'corporation', 'alliance', 'button']) ->make(true); }
php
public function getTopWalletJournalData(int $character_id) { if (! request()->has('all_linked_characters')) return abort(500); $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; $top = $this->characterTopWalletJournalInteractions($character_ids); $user_group = User::find($character_id)->group->users ->filter(function ($user) { return $user->name !== 'admin' && $user->id !== 1; }) ->pluck('id'); return DataTables::of($top) ->editColumn('ref_type', function ($row) { return ucwords(str_replace('_', ' ', $row->ref_type)); }) ->addColumn('character', function ($row) { return $this->getIntelView('character', $row->character_id, $row->first_party_id, $row->second_party_id); }) ->addColumn('corporation', function ($row) { return $this->getIntelView('corporation', $row->character_id, $row->first_party_id, $row->second_party_id); }) ->addColumn('alliance', function ($row) { return $this->getIntelView('alliance', $row->character_id, $row->first_party_id, $row->second_party_id) . view('web::character.intel.partials.journalcontentbutton', compact('row')); }) ->addColumn('is_in_group', function ($row) use ($user_group) { return in_array($row->first_party_id, $user_group->toArray()) && in_array($row->second_party_id, $user_group->toArray()); }) ->rawColumns(['character', 'corporation', 'alliance', 'button']) ->make(true); }
[ "public", "function", "getTopWalletJournalData", "(", "int", "$", "character_id", ")", "{", "if", "(", "!", "request", "(", ")", "->", "has", "(", "'all_linked_characters'", ")", ")", "return", "abort", "(", "500", ")", ";", "$", "character_ids", "=", "col...
@param int $character_id @return mixed @throws \Exception
[ "@param", "int", "$character_id" ]
train
https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Http/Controllers/Character/IntelController.php#L71-L119
eveseat/web
src/Http/Controllers/Character/IntelController.php
IntelController.getTopTransactionsData
public function getTopTransactionsData(int $character_id) { if (! request()->has('all_linked_characters')) return abort(500); $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; $top = $this->characterTopWalletTransactionInteractions($character_ids); return DataTables::of($top) ->addColumn('character', function ($row) { return $this->getIntelView('character', $row->character_id, $row->client_id); }) ->addColumn('corporation', function ($row) { return $this->getIntelView('corporation', $row->character_id, $row->client_id); }) ->addColumn('alliance', function ($row) { return $this->getIntelView('alliance', $row->character_id, $row->client_id) . view('web::character.intel.partials.transactioncontentbutton', compact('row')); }) ->rawColumns(['character', 'corporation', 'alliance']) ->make(true); }
php
public function getTopTransactionsData(int $character_id) { if (! request()->has('all_linked_characters')) return abort(500); $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; $top = $this->characterTopWalletTransactionInteractions($character_ids); return DataTables::of($top) ->addColumn('character', function ($row) { return $this->getIntelView('character', $row->character_id, $row->client_id); }) ->addColumn('corporation', function ($row) { return $this->getIntelView('corporation', $row->character_id, $row->client_id); }) ->addColumn('alliance', function ($row) { return $this->getIntelView('alliance', $row->character_id, $row->client_id) . view('web::character.intel.partials.transactioncontentbutton', compact('row')); }) ->rawColumns(['character', 'corporation', 'alliance']) ->make(true); }
[ "public", "function", "getTopTransactionsData", "(", "int", "$", "character_id", ")", "{", "if", "(", "!", "request", "(", ")", "->", "has", "(", "'all_linked_characters'", ")", ")", "return", "abort", "(", "500", ")", ";", "$", "character_ids", "=", "coll...
@param int $character_id @return mixed @throws \Exception
[ "@param", "int", "$character_id" ]
train
https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Http/Controllers/Character/IntelController.php#L127-L162
eveseat/web
src/Http/Controllers/Character/IntelController.php
IntelController.getTopMailFromData
public function getTopMailFromData(int $character_id) { if (! request()->has('all_linked_characters')) return abort(500); $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; $top = $this->characterTopMailInteractions($character_ids); return DataTables::of($top) ->editColumn('character_id', function ($row) { return $this->getIntelView('character', $row->character_id, $row->from); }) ->editColumn('corporation_id', function ($row) { return $this->getIntelView('corporation', $row->character_id, $row->from); }) ->editColumn('alliance_id', function ($row) { return $this->getIntelView('alliance', $row->character_id, $row->from) . view('web::character.intel.partials.mailcontentbutton', compact('row')); }) ->rawColumns(['character_id', 'corporation_id', 'alliance_id']) ->make(true); }
php
public function getTopMailFromData(int $character_id) { if (! request()->has('all_linked_characters')) return abort(500); $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; $top = $this->characterTopMailInteractions($character_ids); return DataTables::of($top) ->editColumn('character_id', function ($row) { return $this->getIntelView('character', $row->character_id, $row->from); }) ->editColumn('corporation_id', function ($row) { return $this->getIntelView('corporation', $row->character_id, $row->from); }) ->editColumn('alliance_id', function ($row) { return $this->getIntelView('alliance', $row->character_id, $row->from) . view('web::character.intel.partials.mailcontentbutton', compact('row')); }) ->rawColumns(['character_id', 'corporation_id', 'alliance_id']) ->make(true); }
[ "public", "function", "getTopMailFromData", "(", "int", "$", "character_id", ")", "{", "if", "(", "!", "request", "(", ")", "->", "has", "(", "'all_linked_characters'", ")", ")", "return", "abort", "(", "500", ")", ";", "$", "character_ids", "=", "collect"...
@param int $character_id @return mixed @throws \Exception
[ "@param", "int", "$character_id" ]
train
https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Http/Controllers/Character/IntelController.php#L170-L204
eveseat/web
src/Http/Controllers/Character/IntelController.php
IntelController.getCompareStandingsWithProfileData
public function getCompareStandingsWithProfileData(int $character_id, int $profile_id) { $journal = $this->getCharacterJournalStandingsWithProfile($character_id, $profile_id); return DataTables::of($journal) ->editColumn('characterName', function ($row) { return view('web::character.intel.partials.charactername', compact('row')) ->render(); }) ->editColumn('corporationName', function ($row) { return view('web::character.intel.partials.corporationname', compact('row')) ->render(); }) ->editColumn('allianceName', function ($row) { return view('web::character.intel.partials.alliancename', compact('row')) ->render(); }) ->rawColumns(['characterName', 'corporationName', 'allianceName']) ->make(true); }
php
public function getCompareStandingsWithProfileData(int $character_id, int $profile_id) { $journal = $this->getCharacterJournalStandingsWithProfile($character_id, $profile_id); return DataTables::of($journal) ->editColumn('characterName', function ($row) { return view('web::character.intel.partials.charactername', compact('row')) ->render(); }) ->editColumn('corporationName', function ($row) { return view('web::character.intel.partials.corporationname', compact('row')) ->render(); }) ->editColumn('allianceName', function ($row) { return view('web::character.intel.partials.alliancename', compact('row')) ->render(); }) ->rawColumns(['characterName', 'corporationName', 'allianceName']) ->make(true); }
[ "public", "function", "getCompareStandingsWithProfileData", "(", "int", "$", "character_id", ",", "int", "$", "profile_id", ")", "{", "$", "journal", "=", "$", "this", "->", "getCharacterJournalStandingsWithProfile", "(", "$", "character_id", ",", "$", "profile_id",...
@param int $character_id @param int $profile_id @return \Illuminate\Contracts\View\Factory|View @throws \Exception
[ "@param", "int", "$character_id", "@param", "int", "$profile_id" ]
train
https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Http/Controllers/Character/IntelController.php#L226-L250
eveseat/web
src/Http/Controllers/Character/IntelController.php
IntelController.getNotesData
public function getNotesData(int $character_id) { return DataTables::of(CharacterInfo::getNotes($character_id)) ->addColumn('actions', function ($row) { return view('web::character.intel.partials.notesactions', compact('row')) ->render(); }) ->rawColumns(['actions']) ->make(true); }
php
public function getNotesData(int $character_id) { return DataTables::of(CharacterInfo::getNotes($character_id)) ->addColumn('actions', function ($row) { return view('web::character.intel.partials.notesactions', compact('row')) ->render(); }) ->rawColumns(['actions']) ->make(true); }
[ "public", "function", "getNotesData", "(", "int", "$", "character_id", ")", "{", "return", "DataTables", "::", "of", "(", "CharacterInfo", "::", "getNotes", "(", "$", "character_id", ")", ")", "->", "addColumn", "(", "'actions'", ",", "function", "(", "$", ...
@param int $character_id @return mixed @throws \Exception
[ "@param", "int", "$character_id" ]
train
https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Http/Controllers/Character/IntelController.php#L270-L282
eveseat/web
src/Http/Controllers/Character/IntelController.php
IntelController.getSingleNotesData
public function getSingleNotesData(int $character_id, int $note_id) { return response()->json( CharacterInfo::getNote($character_id, $note_id)->first()); }
php
public function getSingleNotesData(int $character_id, int $note_id) { return response()->json( CharacterInfo::getNote($character_id, $note_id)->first()); }
[ "public", "function", "getSingleNotesData", "(", "int", "$", "character_id", ",", "int", "$", "note_id", ")", "{", "return", "response", "(", ")", "->", "json", "(", "CharacterInfo", "::", "getNote", "(", "$", "character_id", ",", "$", "note_id", ")", "->"...
@param int $character_id @param int $note_id @return \Illuminate\Http\JsonResponse
[ "@param", "int", "$character_id", "@param", "int", "$note_id" ]
train
https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Http/Controllers/Character/IntelController.php#L290-L296
eveseat/web
src/Http/Controllers/Character/IntelController.php
IntelController.postAddNew
public function postAddNew(NewIntelNote $request, int $character_id) { CharacterInfo::addNote( $character_id, $request->input('title'), $request->input('note')); return redirect()->back() ->with('success', 'Note Added'); }
php
public function postAddNew(NewIntelNote $request, int $character_id) { CharacterInfo::addNote( $character_id, $request->input('title'), $request->input('note')); return redirect()->back() ->with('success', 'Note Added'); }
[ "public", "function", "postAddNew", "(", "NewIntelNote", "$", "request", ",", "int", "$", "character_id", ")", "{", "CharacterInfo", "::", "addNote", "(", "$", "character_id", ",", "$", "request", "->", "input", "(", "'title'", ")", ",", "$", "request", "-...
@param \Seat\Web\Http\Validation\NewIntelNote $request @param int $character_id @return \Illuminate\Http\RedirectResponse
[ "@param", "\\", "Seat", "\\", "Web", "\\", "Http", "\\", "Validation", "\\", "NewIntelNote", "$request", "@param", "int", "$character_id" ]
train
https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Http/Controllers/Character/IntelController.php#L304-L313
eveseat/web
src/Http/Controllers/Character/IntelController.php
IntelController.getDeleteNote
public function getDeleteNote(int $character_id, int $note_id) { CharacterInfo::deleteNote($character_id, $note_id); return redirect()->back() ->with('success', 'Note deleted!'); }
php
public function getDeleteNote(int $character_id, int $note_id) { CharacterInfo::deleteNote($character_id, $note_id); return redirect()->back() ->with('success', 'Note deleted!'); }
[ "public", "function", "getDeleteNote", "(", "int", "$", "character_id", ",", "int", "$", "note_id", ")", "{", "CharacterInfo", "::", "deleteNote", "(", "$", "character_id", ",", "$", "note_id", ")", ";", "return", "redirect", "(", ")", "->", "back", "(", ...
@param int $character_id @param int $note_id @return \Illuminate\Http\RedirectResponse
[ "@param", "int", "$character_id", "@param", "int", "$note_id" ]
train
https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Http/Controllers/Character/IntelController.php#L321-L329
eveseat/web
src/Http/Controllers/Character/IntelController.php
IntelController.postUpdateNote
public function postUpdateNote(UpdateIntelNote $request, int $character_id) { CharacterInfo::updateNote( $character_id, $request->input('note_id'), $request->input('title'), $request->input('note')); return redirect()->back() ->with('success', 'Note updated!'); }
php
public function postUpdateNote(UpdateIntelNote $request, int $character_id) { CharacterInfo::updateNote( $character_id, $request->input('note_id'), $request->input('title'), $request->input('note')); return redirect()->back() ->with('success', 'Note updated!'); }
[ "public", "function", "postUpdateNote", "(", "UpdateIntelNote", "$", "request", ",", "int", "$", "character_id", ")", "{", "CharacterInfo", "::", "updateNote", "(", "$", "character_id", ",", "$", "request", "->", "input", "(", "'note_id'", ")", ",", "$", "re...
@param \Seat\Web\Http\Validation\UpdateIntelNote $request @param int $character_id @return \Illuminate\Http\RedirectResponse
[ "@param", "\\", "Seat", "\\", "Web", "\\", "Http", "\\", "Validation", "\\", "UpdateIntelNote", "$request", "@param", "int", "$character_id" ]
train
https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Http/Controllers/Character/IntelController.php#L337-L348
eveseat/web
src/Http/Controllers/Character/IntelController.php
IntelController.getJournalContent
public function getJournalContent(int $first_party_id, int $second_party_id) { $journal = $this->characterWalletJournalInteractions($first_party_id, $second_party_id); return DataTables::of($journal) ->editColumn('ref_type', function ($row) { return view('web::partials.journaltranstype', compact('row')); }) ->editColumn('first_party_id', function ($row) { $character_id = $row->character_id; if (optional($row->first_party)->category === 'character') { $character = CharacterInfo::find($row->first_party_id) ?: $row->first_party_id; return view('web::partials.character', compact('character', 'character_id')); } if (optional($row->first_party)->category === 'corporation'){ $corporation = CorporationInfo::find($row->first_party_id) ?: $row->first_party_id; return view('web::partials.corporation', compact('corporation', 'character_id')); } return view('web::partials.unknown', [ 'unknown_id' => $row->first_party_id, 'character_id' => $character_id, ]); }) ->editColumn('second_party_id', function ($row) { $character_id = $row->character_id; if (optional($row->second_party)->category === 'character') { $character = CharacterInfo::find($row->second_party_id) ?: $row->second_party_id; return view('web::partials.character', compact('character', 'character_id')); } if (optional($row->second_party)->category === 'corporation') { $corporation = CorporationInfo::find($row->second_party_id) ?: $row->second_party_id; return view('web::partials.corporation', compact('corporation', 'character_id')); } return view('web::partials.unknown', [ 'unknown_id' => $row->second_party_id, 'character_id' => $character_id, ]); }) ->editColumn('amount', function ($row) { return number($row->amount); }) ->editColumn('balance', function ($row) { return number($row->balance); }) ->addColumn('is_in_group', function ($row) { return $row->character_id === $row->first_party_id || $row->character_id === $row->second_party_id; }) ->rawColumns(['ref_type', 'first_party_id', 'second_party_id']) ->make(true); }
php
public function getJournalContent(int $first_party_id, int $second_party_id) { $journal = $this->characterWalletJournalInteractions($first_party_id, $second_party_id); return DataTables::of($journal) ->editColumn('ref_type', function ($row) { return view('web::partials.journaltranstype', compact('row')); }) ->editColumn('first_party_id', function ($row) { $character_id = $row->character_id; if (optional($row->first_party)->category === 'character') { $character = CharacterInfo::find($row->first_party_id) ?: $row->first_party_id; return view('web::partials.character', compact('character', 'character_id')); } if (optional($row->first_party)->category === 'corporation'){ $corporation = CorporationInfo::find($row->first_party_id) ?: $row->first_party_id; return view('web::partials.corporation', compact('corporation', 'character_id')); } return view('web::partials.unknown', [ 'unknown_id' => $row->first_party_id, 'character_id' => $character_id, ]); }) ->editColumn('second_party_id', function ($row) { $character_id = $row->character_id; if (optional($row->second_party)->category === 'character') { $character = CharacterInfo::find($row->second_party_id) ?: $row->second_party_id; return view('web::partials.character', compact('character', 'character_id')); } if (optional($row->second_party)->category === 'corporation') { $corporation = CorporationInfo::find($row->second_party_id) ?: $row->second_party_id; return view('web::partials.corporation', compact('corporation', 'character_id')); } return view('web::partials.unknown', [ 'unknown_id' => $row->second_party_id, 'character_id' => $character_id, ]); }) ->editColumn('amount', function ($row) { return number($row->amount); }) ->editColumn('balance', function ($row) { return number($row->balance); }) ->addColumn('is_in_group', function ($row) { return $row->character_id === $row->first_party_id || $row->character_id === $row->second_party_id; }) ->rawColumns(['ref_type', 'first_party_id', 'second_party_id']) ->make(true); }
[ "public", "function", "getJournalContent", "(", "int", "$", "first_party_id", ",", "int", "$", "second_party_id", ")", "{", "$", "journal", "=", "$", "this", "->", "characterWalletJournalInteractions", "(", "$", "first_party_id", ",", "$", "second_party_id", ")", ...
@param int $first_party_id @param int $second_party_id @return mixed @throws \Exception
[ "@param", "int", "$first_party_id", "@param", "int", "$second_party_id" ]
train
https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Http/Controllers/Character/IntelController.php#L357-L427
eveseat/web
src/Http/Controllers/Character/IntelController.php
IntelController.getTransactionContent
public function getTransactionContent(int $character_id, int $client_id) { $transactions = $this->characterWalletTransactionInteraction($character_id, $client_id); return DataTables::of($transactions) ->editColumn('is_buy', function ($row) { return view('web::partials.transactionbuysell', compact('row')); }) ->editColumn('unit_price', function ($row) { return number($row->unit_price); }) ->addColumn('item_view', function ($row) { return view('web::partials.transactiontype', compact('row')); }) ->addColumn('total', function ($row) { return number($row->unit_price * $row->quantity); }) ->addColumn('client_view', function ($row) { $character_id = $row->character_id; $character = CharacterInfo::find($row->client_id) ?: $row->client_id; return view('web::partials.character', compact('character', 'character_id')); }) ->rawColumns(['is_buy', 'client_view', 'item_view']) ->make(true); }
php
public function getTransactionContent(int $character_id, int $client_id) { $transactions = $this->characterWalletTransactionInteraction($character_id, $client_id); return DataTables::of($transactions) ->editColumn('is_buy', function ($row) { return view('web::partials.transactionbuysell', compact('row')); }) ->editColumn('unit_price', function ($row) { return number($row->unit_price); }) ->addColumn('item_view', function ($row) { return view('web::partials.transactiontype', compact('row')); }) ->addColumn('total', function ($row) { return number($row->unit_price * $row->quantity); }) ->addColumn('client_view', function ($row) { $character_id = $row->character_id; $character = CharacterInfo::find($row->client_id) ?: $row->client_id; return view('web::partials.character', compact('character', 'character_id')); }) ->rawColumns(['is_buy', 'client_view', 'item_view']) ->make(true); }
[ "public", "function", "getTransactionContent", "(", "int", "$", "character_id", ",", "int", "$", "client_id", ")", "{", "$", "transactions", "=", "$", "this", "->", "characterWalletTransactionInteraction", "(", "$", "character_id", ",", "$", "client_id", ")", ";...
@param int $character_id @param int $client_id @return mixed @throws \Exception
[ "@param", "int", "$character_id", "@param", "int", "$client_id" ]
train
https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Http/Controllers/Character/IntelController.php#L436-L467
eveseat/web
src/Http/Controllers/Character/IntelController.php
IntelController.getTopMailContent
public function getTopMailContent(int $character_id, int $from) { $mail = $this->getMailContent($character_id, $from); return DataTables::of($mail) ->editColumn('from', function ($row) { $character_id = $row->character_id; $character = CharacterInfo::find($row->from) ?: $row->from; return view('web::partials.character', compact('character', 'character_id')); }) ->editColumn('subject', function ($row) { return view('web::character.partials.mailtitle', compact('row')); }) ->editColumn('tocounts', function ($row) { return view('web::character.partials.mailtocounts', compact('row')); }) ->addColumn('read', function ($row) { return view('web::character.partials.topmailread', compact('row')); }) ->rawColumns(['from', 'subject', 'tocounts', 'read']) ->make(true); }
php
public function getTopMailContent(int $character_id, int $from) { $mail = $this->getMailContent($character_id, $from); return DataTables::of($mail) ->editColumn('from', function ($row) { $character_id = $row->character_id; $character = CharacterInfo::find($row->from) ?: $row->from; return view('web::partials.character', compact('character', 'character_id')); }) ->editColumn('subject', function ($row) { return view('web::character.partials.mailtitle', compact('row')); }) ->editColumn('tocounts', function ($row) { return view('web::character.partials.mailtocounts', compact('row')); }) ->addColumn('read', function ($row) { return view('web::character.partials.topmailread', compact('row')); }) ->rawColumns(['from', 'subject', 'tocounts', 'read']) ->make(true); }
[ "public", "function", "getTopMailContent", "(", "int", "$", "character_id", ",", "int", "$", "from", ")", "{", "$", "mail", "=", "$", "this", "->", "getMailContent", "(", "$", "character_id", ",", "$", "from", ")", ";", "return", "DataTables", "::", "of"...
@param int $character_id @param int $from @return mixed @throws \Exception
[ "@param", "int", "$character_id", "@param", "int", "$from" ]
train
https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Http/Controllers/Character/IntelController.php#L476-L505
eveseat/web
src/Http/Controllers/Character/IntelController.php
IntelController.getUniverseNameResolved
private function getUniverseNameResolved(int $character_id, int $first_party_id, int $second_party_id = null) : Collection { // f.e. market escrow -> self referential payment. if($first_party_id === $second_party_id) return collect([ 'character_id' => $character_id, 'corporation_id' => CharacterInfo::find($character_id)->corporation_id, 'alliance_id' => CharacterInfo::find($character_id)->alliance_id, ]); return collect([UniverseName::find($first_party_id), UniverseName::find($second_party_id)]) ->filter() ->filter(function ($universe_name) use ($character_id) { return $universe_name->entity_id !== $character_id; }) ->pipe(function ($collection) use ($character_id, $first_party_id,$second_party_id) { if ($collection->isNotEmpty()){ return $collection->flatten()->map(function ($item) { if($item->category === 'character') return collect([ 'character_id' => $item->entity_id, 'corporation_id' => optional(CharacterAffiliation::find($item->entity_id))->corporation_id, 'alliance_id' => optional(CharacterAffiliation::find($item->entity_id))->alliance_id, ])->filter(); if($item->category === 'corporation') return collect([ 'corporation_id' => $item->entity_id, 'alliance_id' => optional(CharacterAffiliation::where('corporation_id', $item->entity_id)->get()->first())->alliance_id, ])->filter(); if($item->category === 'alliance') return collect(['alliance_id' => $item->entity_id]); return collect(['other_resolved_id' => $item->entity_id]); })->filter(); } return $collection->push(collect(['unknown_id' => $character_id !== $first_party_id ? $first_party_id : $second_party_id, 'character_id' => $character_id])); }) ->flatMap(function ($value) { return $value; }); }
php
private function getUniverseNameResolved(int $character_id, int $first_party_id, int $second_party_id = null) : Collection { // f.e. market escrow -> self referential payment. if($first_party_id === $second_party_id) return collect([ 'character_id' => $character_id, 'corporation_id' => CharacterInfo::find($character_id)->corporation_id, 'alliance_id' => CharacterInfo::find($character_id)->alliance_id, ]); return collect([UniverseName::find($first_party_id), UniverseName::find($second_party_id)]) ->filter() ->filter(function ($universe_name) use ($character_id) { return $universe_name->entity_id !== $character_id; }) ->pipe(function ($collection) use ($character_id, $first_party_id,$second_party_id) { if ($collection->isNotEmpty()){ return $collection->flatten()->map(function ($item) { if($item->category === 'character') return collect([ 'character_id' => $item->entity_id, 'corporation_id' => optional(CharacterAffiliation::find($item->entity_id))->corporation_id, 'alliance_id' => optional(CharacterAffiliation::find($item->entity_id))->alliance_id, ])->filter(); if($item->category === 'corporation') return collect([ 'corporation_id' => $item->entity_id, 'alliance_id' => optional(CharacterAffiliation::where('corporation_id', $item->entity_id)->get()->first())->alliance_id, ])->filter(); if($item->category === 'alliance') return collect(['alliance_id' => $item->entity_id]); return collect(['other_resolved_id' => $item->entity_id]); })->filter(); } return $collection->push(collect(['unknown_id' => $character_id !== $first_party_id ? $first_party_id : $second_party_id, 'character_id' => $character_id])); }) ->flatMap(function ($value) { return $value; }); }
[ "private", "function", "getUniverseNameResolved", "(", "int", "$", "character_id", ",", "int", "$", "first_party_id", ",", "int", "$", "second_party_id", "=", "null", ")", ":", "Collection", "{", "// f.e. market escrow -> self referential payment.", "if", "(", "$", ...
@param int $character_id @param int $first_party_id @param int|null $second_party_id @return \Illuminate\Support\Collection
[ "@param", "int", "$character_id", "@param", "int", "$first_party_id", "@param", "int|null", "$second_party_id" ]
train
https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Http/Controllers/Character/IntelController.php#L514-L562
eveseat/web
src/Http/Controllers/Character/IntelController.php
IntelController.getIntelView
private function getIntelView(string $type, int $character_id, int $first_other_id, int $second_other_id = null) : string { $universe_name = $this->getUniverseNameResolved($character_id, $first_other_id, $second_other_id); if($type === 'character') return $this->getCharacterIntelView($universe_name, $character_id); if($type === 'corporation') return $this->getCorporationIntelView($universe_name, $character_id); if($type === 'alliance') return $this->getAllianceIntelView($universe_name, $character_id); return ''; }
php
private function getIntelView(string $type, int $character_id, int $first_other_id, int $second_other_id = null) : string { $universe_name = $this->getUniverseNameResolved($character_id, $first_other_id, $second_other_id); if($type === 'character') return $this->getCharacterIntelView($universe_name, $character_id); if($type === 'corporation') return $this->getCorporationIntelView($universe_name, $character_id); if($type === 'alliance') return $this->getAllianceIntelView($universe_name, $character_id); return ''; }
[ "private", "function", "getIntelView", "(", "string", "$", "type", ",", "int", "$", "character_id", ",", "int", "$", "first_other_id", ",", "int", "$", "second_other_id", "=", "null", ")", ":", "string", "{", "$", "universe_name", "=", "$", "this", "->", ...
@param string $type @param int $character_id @param int $first_other_id @param int|null $second_other_id @return string
[ "@param", "string", "$type", "@param", "int", "$character_id", "@param", "int", "$first_other_id", "@param", "int|null", "$second_other_id" ]
train
https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Http/Controllers/Character/IntelController.php#L572-L587
eveseat/web
src/Http/Controllers/Character/IntelController.php
IntelController.getCharacterIntelView
private function getCharacterIntelView(Collection $universe_name, int $character_id) : string { if ($universe_name->has('unknown_id')) return $this->getUnknownIntelView($universe_name); if (! $universe_name->has('character_id')) return ''; $character = CharacterInfo::find($universe_name['character_id']) ?: $universe_name['character_id']; return view('web::partials.character', compact('character', 'character_id')); }
php
private function getCharacterIntelView(Collection $universe_name, int $character_id) : string { if ($universe_name->has('unknown_id')) return $this->getUnknownIntelView($universe_name); if (! $universe_name->has('character_id')) return ''; $character = CharacterInfo::find($universe_name['character_id']) ?: $universe_name['character_id']; return view('web::partials.character', compact('character', 'character_id')); }
[ "private", "function", "getCharacterIntelView", "(", "Collection", "$", "universe_name", ",", "int", "$", "character_id", ")", ":", "string", "{", "if", "(", "$", "universe_name", "->", "has", "(", "'unknown_id'", ")", ")", "return", "$", "this", "->", "getU...
@param \Illuminate\Support\Collection $universe_name @param int $character_id @return string
[ "@param", "\\", "Illuminate", "\\", "Support", "\\", "Collection", "$universe_name" ]
train
https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Http/Controllers/Character/IntelController.php#L596-L607
eveseat/web
src/Http/Controllers/Character/IntelController.php
IntelController.getCorporationIntelView
private function getCorporationIntelView(Collection $universe_name, int $character_id) : string { if ($universe_name->has('unknown_id')) return $this->getUnknownIntelView($universe_name); if (! $universe_name->has('corporation_id')) return ''; $corporation = CorporationInfo::find($universe_name['corporation_id']) ?: $universe_name['corporation_id']; return view('web::partials.corporation', compact('corporation', 'character_id')); }
php
private function getCorporationIntelView(Collection $universe_name, int $character_id) : string { if ($universe_name->has('unknown_id')) return $this->getUnknownIntelView($universe_name); if (! $universe_name->has('corporation_id')) return ''; $corporation = CorporationInfo::find($universe_name['corporation_id']) ?: $universe_name['corporation_id']; return view('web::partials.corporation', compact('corporation', 'character_id')); }
[ "private", "function", "getCorporationIntelView", "(", "Collection", "$", "universe_name", ",", "int", "$", "character_id", ")", ":", "string", "{", "if", "(", "$", "universe_name", "->", "has", "(", "'unknown_id'", ")", ")", "return", "$", "this", "->", "ge...
@param \Illuminate\Support\Collection $universe_name @param int $character_id @return string
[ "@param", "\\", "Illuminate", "\\", "Support", "\\", "Collection", "$universe_name" ]
train
https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Http/Controllers/Character/IntelController.php#L616-L627
eveseat/web
src/Http/Controllers/Character/IntelController.php
IntelController.getAllianceIntelView
private function getAllianceIntelView(Collection $universe_name, int $character_id) : string { if ($universe_name->has('unknown_id')) return $this->getUnknownIntelView($universe_name); if (! $universe_name->has('alliance_id')) return ''; $alliance = $universe_name['alliance_id']; return view('web::partials.alliance', compact('alliance', 'character_id')); }
php
private function getAllianceIntelView(Collection $universe_name, int $character_id) : string { if ($universe_name->has('unknown_id')) return $this->getUnknownIntelView($universe_name); if (! $universe_name->has('alliance_id')) return ''; $alliance = $universe_name['alliance_id']; return view('web::partials.alliance', compact('alliance', 'character_id')); }
[ "private", "function", "getAllianceIntelView", "(", "Collection", "$", "universe_name", ",", "int", "$", "character_id", ")", ":", "string", "{", "if", "(", "$", "universe_name", "->", "has", "(", "'unknown_id'", ")", ")", "return", "$", "this", "->", "getUn...
@param \Illuminate\Support\Collection $universe_name @param int $character_id @return string
[ "@param", "\\", "Illuminate", "\\", "Support", "\\", "Collection", "$universe_name" ]
train
https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Http/Controllers/Character/IntelController.php#L636-L647
eveseat/web
src/Http/Controllers/Corporation/StarbaseController.php
StarbaseController.getStarbases
public function getStarbases(int $corporation_id) { // The basic strategy here is that we will first try and get // as much information as possible about the starbases. // After that we will take the list of starbases and // attempt to determine the fuel usage as well as // the tower name as per the assets list. $sheet = CorporationInfo::find($corporation_id); $starbases = $this->getCorporationStarbases($corporation_id); return view('web::corporation.starbases', compact('sheet', 'starbases')); }
php
public function getStarbases(int $corporation_id) { // The basic strategy here is that we will first try and get // as much information as possible about the starbases. // After that we will take the list of starbases and // attempt to determine the fuel usage as well as // the tower name as per the assets list. $sheet = CorporationInfo::find($corporation_id); $starbases = $this->getCorporationStarbases($corporation_id); return view('web::corporation.starbases', compact('sheet', 'starbases')); }
[ "public", "function", "getStarbases", "(", "int", "$", "corporation_id", ")", "{", "// The basic strategy here is that we will first try and get", "// as much information as possible about the starbases.", "// After that we will take the list of starbases and", "// attempt to determine the f...
@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/StarbaseController.php#L47-L59
eveseat/web
src/Http/Controllers/Corporation/StarbaseController.php
StarbaseController.postStarbaseModules
public function postStarbaseModules(StarbaseModule $request, int $corporation_id) { $starbase = $this->getCorporationStarbases($corporation_id, $request->starbase_id)->first(); $starbase_modules = $this->getStarbaseModules($corporation_id, $request->starbase_id); return view('web::corporation.starbase.ajax.modules-tab', compact('starbase', 'starbase_modules')); }
php
public function postStarbaseModules(StarbaseModule $request, int $corporation_id) { $starbase = $this->getCorporationStarbases($corporation_id, $request->starbase_id)->first(); $starbase_modules = $this->getStarbaseModules($corporation_id, $request->starbase_id); return view('web::corporation.starbase.ajax.modules-tab', compact('starbase', 'starbase_modules')); }
[ "public", "function", "postStarbaseModules", "(", "StarbaseModule", "$", "request", ",", "int", "$", "corporation_id", ")", "{", "$", "starbase", "=", "$", "this", "->", "getCorporationStarbases", "(", "$", "corporation_id", ",", "$", "request", "->", "starbase_...
@param \Seat\Web\Http\Validation\StarbaseModule $request @param $corporation_id @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
[ "@param", "\\", "Seat", "\\", "Web", "\\", "Http", "\\", "Validation", "\\", "StarbaseModule", "$request", "@param", "$corporation_id" ]
train
https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Http/Controllers/Corporation/StarbaseController.php#L67-L76
eveseat/web
src/Http/Controllers/Character/CharacterController.php
CharacterController.getCharactersData
public function getCharactersData(Request $request) { $characters = ($request->filtered === 'true') ? auth()->user()->group->users ->filter(function ($user) { return $user->name !== 'admin' && $user->id !== 1; }) ->map(function ($user) { return $user->character; }) : $this->getAllCharactersWithAffiliations(false); return DataTables::of($characters) ->addColumn('name_view', function ($row) { $character = $row; return view('web::partials.character', compact('character')); }) ->editColumn('corporation_id', function ($row) { $corporation = $row->corporation_id; return view('web::partials.corporation', compact('corporation')); }) ->editColumn('alliance_id', function ($row) { $alliance = $row->alliance_id; if (empty($alliance)) return ''; return view('web::partials.alliance', compact('alliance')); }) ->editColumn('actions', function ($row) { return view('web::character.partials.delete', compact('row')) ->render(); }) ->rawColumns(['name_view', 'corporation_id', 'alliance_id', 'actions']) ->make(true); }
php
public function getCharactersData(Request $request) { $characters = ($request->filtered === 'true') ? auth()->user()->group->users ->filter(function ($user) { return $user->name !== 'admin' && $user->id !== 1; }) ->map(function ($user) { return $user->character; }) : $this->getAllCharactersWithAffiliations(false); return DataTables::of($characters) ->addColumn('name_view', function ($row) { $character = $row; return view('web::partials.character', compact('character')); }) ->editColumn('corporation_id', function ($row) { $corporation = $row->corporation_id; return view('web::partials.corporation', compact('corporation')); }) ->editColumn('alliance_id', function ($row) { $alliance = $row->alliance_id; if (empty($alliance)) return ''; return view('web::partials.alliance', compact('alliance')); }) ->editColumn('actions', function ($row) { return view('web::character.partials.delete', compact('row')) ->render(); }) ->rawColumns(['name_view', 'corporation_id', 'alliance_id', 'actions']) ->make(true); }
[ "public", "function", "getCharactersData", "(", "Request", "$", "request", ")", "{", "$", "characters", "=", "(", "$", "request", "->", "filtered", "===", "'true'", ")", "?", "auth", "(", ")", "->", "user", "(", ")", "->", "group", "->", "users", "->",...
@param \Symfony\Component\HttpFoundation\Request $request @return mixed @throws \Exception
[ "@param", "\\", "Symfony", "\\", "Component", "\\", "HttpFoundation", "\\", "Request", "$request" ]
train
https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Http/Controllers/Character/CharacterController.php#L55-L98
eveseat/web
src/Http/Controllers/Character/CharacterController.php
CharacterController.deleteCharacter
public function deleteCharacter(int $character_id) { CharacterInfo::find($character_id)->delete(); return redirect()->back()->with( 'success', 'Character deleted!' ); }
php
public function deleteCharacter(int $character_id) { CharacterInfo::find($character_id)->delete(); return redirect()->back()->with( 'success', 'Character deleted!' ); }
[ "public", "function", "deleteCharacter", "(", "int", "$", "character_id", ")", "{", "CharacterInfo", "::", "find", "(", "$", "character_id", ")", "->", "delete", "(", ")", ";", "return", "redirect", "(", ")", "->", "back", "(", ")", "->", "with", "(", ...
@param int $character_id @return \Illuminate\Http\RedirectResponse
[ "@param", "int", "$character_id" ]
train
https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Http/Controllers/Character/CharacterController.php#L105-L113
eveseat/web
src/Http/Controllers/Character/SkillsController.php
SkillsController.getSkills
public function getSkills(int $character_id) { $skills = $this->getCharacterSkillsInformation($character_id); $skill_groups = $this->getEveSkillsGroups(); return view('web::character.skills', compact('skills', 'skill_groups')); }
php
public function getSkills(int $character_id) { $skills = $this->getCharacterSkillsInformation($character_id); $skill_groups = $this->getEveSkillsGroups(); return view('web::character.skills', compact('skills', 'skill_groups')); }
[ "public", "function", "getSkills", "(", "int", "$", "character_id", ")", "{", "$", "skills", "=", "$", "this", "->", "getCharacterSkillsInformation", "(", "$", "character_id", ")", ";", "$", "skill_groups", "=", "$", "this", "->", "getEveSkillsGroups", "(", ...
@param $character_id @return \Illuminate\View\View
[ "@param", "$character_id" ]
train
https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Http/Controllers/Character/SkillsController.php#L44-L52
eveseat/web
src/Http/Controllers/Character/SkillsController.php
SkillsController.getCharacterSkillsLevelChartData
public function getCharacterSkillsLevelChartData(int $character_id) { if ($character_id == 1) { return response()->json([]); } $data = $this->getCharacterSkillsAmountPerLevel($character_id); return response()->json([ 'labels' => [ 'Level 0', 'Level 1', 'Level 2', 'Level 3', 'Level 4', 'Level 5', ], 'datasets' => [ [ 'data' => $data, 'backgroundColor' => [ '#00c0ef', '#39cccc', '#00a65a', '#605ca8', '#001f3f', '#3c8dbc', ], ], ], ]); }
php
public function getCharacterSkillsLevelChartData(int $character_id) { if ($character_id == 1) { return response()->json([]); } $data = $this->getCharacterSkillsAmountPerLevel($character_id); return response()->json([ 'labels' => [ 'Level 0', 'Level 1', 'Level 2', 'Level 3', 'Level 4', 'Level 5', ], 'datasets' => [ [ 'data' => $data, 'backgroundColor' => [ '#00c0ef', '#39cccc', '#00a65a', '#605ca8', '#001f3f', '#3c8dbc', ], ], ], ]); }
[ "public", "function", "getCharacterSkillsLevelChartData", "(", "int", "$", "character_id", ")", "{", "if", "(", "$", "character_id", "==", "1", ")", "{", "return", "response", "(", ")", "->", "json", "(", "[", "]", ")", ";", "}", "$", "data", "=", "$",...
@param $character_id @return \Illuminate\Http\JsonResponse
[ "@param", "$character_id" ]
train
https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Http/Controllers/Character/SkillsController.php#L59-L86
eveseat/web
src/Http/Controllers/Character/SkillsController.php
SkillsController.getCharacterSkillsCoverageChartData
public function getCharacterSkillsCoverageChartData($character_id) { if ($character_id == 1) { return response()->json([]); } $data = $this->getCharacterSkillCoverage($character_id); $character = CharacterInfo::where('character_id', $character_id)->first(); return response()->json([ 'labels' => $data->map(function ($item) { return $item->marketGroupName; })->toArray(), // skills category 'datasets' => [ [ 'label' => $character->name, 'data' => $data->map(function ($item) { return round($item->characterAmount / $item->gameAmount * 100, 2); // character / in game rate })->toArray(), 'fill' => true, 'backgroundColor' => 'rgba(60,141,188,0.3)', 'borderColor' => '#3c8dbc', 'pointBackgroundColor' => '#3c8dbc', 'pointBorderColor' => '#fff', ], ], ]); }
php
public function getCharacterSkillsCoverageChartData($character_id) { if ($character_id == 1) { return response()->json([]); } $data = $this->getCharacterSkillCoverage($character_id); $character = CharacterInfo::where('character_id', $character_id)->first(); return response()->json([ 'labels' => $data->map(function ($item) { return $item->marketGroupName; })->toArray(), // skills category 'datasets' => [ [ 'label' => $character->name, 'data' => $data->map(function ($item) { return round($item->characterAmount / $item->gameAmount * 100, 2); // character / in game rate })->toArray(), 'fill' => true, 'backgroundColor' => 'rgba(60,141,188,0.3)', 'borderColor' => '#3c8dbc', 'pointBackgroundColor' => '#3c8dbc', 'pointBorderColor' => '#fff', ], ], ]); }
[ "public", "function", "getCharacterSkillsCoverageChartData", "(", "$", "character_id", ")", "{", "if", "(", "$", "character_id", "==", "1", ")", "{", "return", "response", "(", ")", "->", "json", "(", "[", "]", ")", ";", "}", "$", "data", "=", "$", "th...
@param $character_id @return \Illuminate\Http\JsonResponse
[ "@param", "$character_id" ]
train
https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Http/Controllers/Character/SkillsController.php#L93-L124
eveseat/web
src/Http/Controllers/Configuration/SsoController.php
SsoController.postUpdateScopes
public function postUpdateScopes(SsoScopes $request) { setting(['sso_scopes', $request->input('scopes')], true); return redirect()->back()->with('success', trans('web::seat.updated')); }
php
public function postUpdateScopes(SsoScopes $request) { setting(['sso_scopes', $request->input('scopes')], true); return redirect()->back()->with('success', trans('web::seat.updated')); }
[ "public", "function", "postUpdateScopes", "(", "SsoScopes", "$", "request", ")", "{", "setting", "(", "[", "'sso_scopes'", ",", "$", "request", "->", "input", "(", "'scopes'", ")", "]", ",", "true", ")", ";", "return", "redirect", "(", ")", "->", "back",...
@param \Seat\Web\Http\Validation\SsoScopes $request @return \Illuminate\Http\RedirectResponse @throws \Seat\Services\Exceptions\SettingException
[ "@param", "\\", "Seat", "\\", "Web", "\\", "Http", "\\", "Validation", "\\", "SsoScopes", "$request" ]
train
https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Http/Controllers/Configuration/SsoController.php#L49-L55
eveseat/web
src/Http/Composers/CharacterLayout.php
CharacterLayout.compose
public function compose(View $view) { $character_info = CharacterInfo::find($this->request->character_id); if (! is_null($character_info)) $view->with('character_name', $character_info->name); $user = User::find($this->request->character_id); if (! isset($user->refresh_token)){ $deleted_at = $user->refresh_token()->withTrashed()->first()->deleted_at; redirect()->back()->with('warning', trans('web::seat.deleted_refresh_token', ['time' => human_diff($deleted_at)])); } }
php
public function compose(View $view) { $character_info = CharacterInfo::find($this->request->character_id); if (! is_null($character_info)) $view->with('character_name', $character_info->name); $user = User::find($this->request->character_id); if (! isset($user->refresh_token)){ $deleted_at = $user->refresh_token()->withTrashed()->first()->deleted_at; redirect()->back()->with('warning', trans('web::seat.deleted_refresh_token', ['time' => human_diff($deleted_at)])); } }
[ "public", "function", "compose", "(", "View", "$", "view", ")", "{", "$", "character_info", "=", "CharacterInfo", "::", "find", "(", "$", "this", "->", "request", "->", "character_id", ")", ";", "if", "(", "!", "is_null", "(", "$", "character_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/CharacterLayout.php#L49-L62
eveseat/web
src/Http/Controllers/Auth/SsoController.php
SsoController.handleProviderCallback
public function handleProviderCallback(Socialite $social) { $eve_data = $social->driver('eveonline')->user(); // Avoid self attachment if (auth()->check() && auth()->user()->id == $eve_data->character_id) return redirect()->route('home') ->with('error', 'You cannot add yourself. Did you forget to change character in Eve Online SSO form ?'); // Get or create the User bound to this login. $user = $this->findOrCreateUser($eve_data); // Update the refresh token for this character. $this->updateRefreshToken($eve_data); if (! $this->loginUser($user)) return redirect()->route('auth.login') ->with('error', 'Login failed. Please contact your administrator.'); // ensure the user got a valid group - spawn it otherwise if (is_null($user->group)) { Group::forceCreate([ 'id' => $user->group_id, ]); // force laravel to update model relationship information $user->load('group'); } // Set the main characterID based on the response. $this->updateMainCharacterId($user); return redirect()->intended(); }
php
public function handleProviderCallback(Socialite $social) { $eve_data = $social->driver('eveonline')->user(); // Avoid self attachment if (auth()->check() && auth()->user()->id == $eve_data->character_id) return redirect()->route('home') ->with('error', 'You cannot add yourself. Did you forget to change character in Eve Online SSO form ?'); // Get or create the User bound to this login. $user = $this->findOrCreateUser($eve_data); // Update the refresh token for this character. $this->updateRefreshToken($eve_data); if (! $this->loginUser($user)) return redirect()->route('auth.login') ->with('error', 'Login failed. Please contact your administrator.'); // ensure the user got a valid group - spawn it otherwise if (is_null($user->group)) { Group::forceCreate([ 'id' => $user->group_id, ]); // force laravel to update model relationship information $user->load('group'); } // Set the main characterID based on the response. $this->updateMainCharacterId($user); return redirect()->intended(); }
[ "public", "function", "handleProviderCallback", "(", "Socialite", "$", "social", ")", "{", "$", "eve_data", "=", "$", "social", "->", "driver", "(", "'eveonline'", ")", "->", "user", "(", ")", ";", "// Avoid self attachment", "if", "(", "auth", "(", ")", "...
Obtain the user information from Eve Online. @param \Laravel\Socialite\Contracts\Factory $social @return \Seat\Web\Http\Controllers\Auth\Response @throws \Seat\Services\Exceptions\SettingException
[ "Obtain", "the", "user", "information", "from", "Eve", "Online", "." ]
train
https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Http/Controllers/Auth/SsoController.php#L62-L96
eveseat/web
src/Http/Controllers/Auth/SsoController.php
SsoController.findOrCreateUser
private function findOrCreateUser(SocialiteUser $eve_user): User { // Check if this user already exists in the database. if ($existing = User::find($eve_user->character_id)) { // If the character_owner_hash has changed, it might be that // this character was transferred. We will still allow the login, // but the group memberships the character had will be removed. if ($existing->character_owner_hash !== $eve_user->character_owner_hash) { // Update the group_id for this user based on the current // session status. If there is a user already logged in, // simply associate the user with a new group id. If not, // a new group is generated and given to this user. $existing->group_id = auth()->check() ? auth()->user()->group->id : Group::create()->id; // Update the new character_owner_hash $existing->character_owner_hash = $eve_user->character_owner_hash; $existing->save(); } // Detect if the current session is already logged in. If // it is, update the group_id for the new login to the same // as the current session, thereby associating the characters. if (auth()->check()) { // Log the association update event('security.log', [ 'Updating ' . $existing->name . ' to be part of ' . auth()->user()->name, 'authentication', ]); // Re-associate the group membership for the newly logged in user. $existing->group_id = auth()->user()->group->id; $existing->save(); // Remove any orphan groups we could create during the attachment process Group::doesntHave('users')->delete(); } return $existing; } // Log the new account creation event('security.log', [ 'Creating new account for ' . $eve_user->name, 'authentication', ]); // Detect if the current session is already logged in. If // it is, update the group_id for the new login to the same // as the current session, thereby associating the characters. if (auth()->check()) { // Log the association update event('security.log', [ 'Updating ' . $eve_user->name . ' to be part of ' . auth()->user()->name, 'authentication', ]); } return User::forceCreate([ // Only because I don't want to set id as fillable 'id' => $eve_user->character_id, 'group_id' => auth()->check() ? auth()->user()->group->id : Group::create()->id, 'name' => $eve_user->name, 'active' => true, 'character_owner_hash' => $eve_user->character_owner_hash, ]); }
php
private function findOrCreateUser(SocialiteUser $eve_user): User { // Check if this user already exists in the database. if ($existing = User::find($eve_user->character_id)) { // If the character_owner_hash has changed, it might be that // this character was transferred. We will still allow the login, // but the group memberships the character had will be removed. if ($existing->character_owner_hash !== $eve_user->character_owner_hash) { // Update the group_id for this user based on the current // session status. If there is a user already logged in, // simply associate the user with a new group id. If not, // a new group is generated and given to this user. $existing->group_id = auth()->check() ? auth()->user()->group->id : Group::create()->id; // Update the new character_owner_hash $existing->character_owner_hash = $eve_user->character_owner_hash; $existing->save(); } // Detect if the current session is already logged in. If // it is, update the group_id for the new login to the same // as the current session, thereby associating the characters. if (auth()->check()) { // Log the association update event('security.log', [ 'Updating ' . $existing->name . ' to be part of ' . auth()->user()->name, 'authentication', ]); // Re-associate the group membership for the newly logged in user. $existing->group_id = auth()->user()->group->id; $existing->save(); // Remove any orphan groups we could create during the attachment process Group::doesntHave('users')->delete(); } return $existing; } // Log the new account creation event('security.log', [ 'Creating new account for ' . $eve_user->name, 'authentication', ]); // Detect if the current session is already logged in. If // it is, update the group_id for the new login to the same // as the current session, thereby associating the characters. if (auth()->check()) { // Log the association update event('security.log', [ 'Updating ' . $eve_user->name . ' to be part of ' . auth()->user()->name, 'authentication', ]); } return User::forceCreate([ // Only because I don't want to set id as fillable 'id' => $eve_user->character_id, 'group_id' => auth()->check() ? auth()->user()->group->id : Group::create()->id, 'name' => $eve_user->name, 'active' => true, 'character_owner_hash' => $eve_user->character_owner_hash, ]); }
[ "private", "function", "findOrCreateUser", "(", "SocialiteUser", "$", "eve_user", ")", ":", "User", "{", "// Check if this user already exists in the database.", "if", "(", "$", "existing", "=", "User", "::", "find", "(", "$", "eve_user", "->", "character_id", ")", ...
Check if a user exists in the database, else, create and return the User object. Group memberships are also managed here, ensuring that characters are automatically 'linked' via a group. If an existsing, logged in session is detected, the new login will be associated with that sessions group. Otherwise, a new group for this user will be created. @param \Laravel\Socialite\Two\User $eve_user @return \Seat\Web\Models\User
[ "Check", "if", "a", "user", "exists", "in", "the", "database", "else", "create", "and", "return", "the", "User", "object", "." ]
train
https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Http/Controllers/Auth/SsoController.php#L112-L183
eveseat/web
src/Http/Controllers/Auth/SsoController.php
SsoController.loginUser
public function loginUser(User $user): bool { // If this account is disabled, refuse to login if (! $user->active) { event('security.log', [ 'Login for ' . $user->name . ' refused due to a disabled account', 'authentication', ]); return false; } auth()->login($user, true); return true; }
php
public function loginUser(User $user): bool { // If this account is disabled, refuse to login if (! $user->active) { event('security.log', [ 'Login for ' . $user->name . ' refused due to a disabled account', 'authentication', ]); return false; } auth()->login($user, true); return true; }
[ "public", "function", "loginUser", "(", "User", "$", "user", ")", ":", "bool", "{", "// If this account is disabled, refuse to login", "if", "(", "!", "$", "user", "->", "active", ")", "{", "event", "(", "'security.log'", ",", "[", "'Login for '", ".", "$", ...
Login the user, ensuring that a group is attached. If no group is attached, ensure that the user at least has *a* group attached to it. This method returns a boolean as a status flag for the login routine. If a false is returned, it might mean that that account is not allowed to sign in. @param \Seat\Web\Models\User $user @return bool
[ "Login", "the", "user", "ensuring", "that", "a", "group", "is", "attached", "." ]
train
https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Http/Controllers/Auth/SsoController.php#L218-L234
eveseat/web
src/Http/Controllers/Corporation/TrackingController.php
TrackingController.getMemberTracking
public function getMemberTracking(int $corporation_id) { $selected_status = collect(request('selected_refresh_token_status')); $tracking = $this->getCorporationMemberTracking($corporation_id); if($selected_status->contains('valid_token')) $tracking->has('user.refresh_token'); if($selected_status->contains('invalid_token')) $tracking->doesntHave('user.refresh_token'); if($selected_status->contains('missing_users')) $tracking->doesntHave('user'); return DataTables::of($tracking) ->editColumn('character_id', function ($row) { $character_id = $row->character_id; $character = CharacterInfo::find($row->character_id) ?: $row->character_id; return view('web::partials.character', compact('character', 'character_id')); }) ->addColumn('location', function ($row) { return view('web::corporation.partials.location', compact('row')); }) ->addColumn('refresh_token', function ($row) { $refresh_token = false; if(! is_null(optional($row->user)->refresh_token)) $refresh_token = true; return view('web::corporation.partials.refresh-token', compact('refresh_token')); }) ->addColumn('main_character', function ($row) { $character_id = $row->character_id; if(is_null($row->user)) return ''; $main_character_id = $character_id; if (! is_null($row->user->group) && ! is_null(optional($row->user->group)->main_character_id)) $main_character_id = $row->user->group->main_character_id; $character = CharacterInfo::find($main_character_id) ?: $main_character_id; return view('web::partials.character', compact('character', 'character_id')); }) ->filterColumn('name_filter', 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('character_id', array_merge($resolved_ids->toArray(), $character_info_ids->toArray())); }) ->filterColumn('location_filter', function ($query, $keyword) { $system_ids = collect(); if(strlen($keyword) > 1) $system_ids = MapDenormalize::where('itemName', 'like', '%' . $keyword . '%')->select('itemID')->get()->map(function ($system) { return $system->itemID; }); $station_ids = StaStation::where('stationName', 'like', '%' . $keyword . '%')->get()->map(function ($station) { return $station->stationID; }); $structure_ids = UniverseStructure::where('name', 'like', '%' . $keyword . '%')->get()->map(function ($structure) { return $structure->structure_id; }); $query->whereIn('location_id', array_merge($system_ids->toArray(), $station_ids->toArray(), $structure_ids->toArray())); }) ->rawColumns(['character_id', 'main_character', 'refresh_token', 'location']) ->make(true); }
php
public function getMemberTracking(int $corporation_id) { $selected_status = collect(request('selected_refresh_token_status')); $tracking = $this->getCorporationMemberTracking($corporation_id); if($selected_status->contains('valid_token')) $tracking->has('user.refresh_token'); if($selected_status->contains('invalid_token')) $tracking->doesntHave('user.refresh_token'); if($selected_status->contains('missing_users')) $tracking->doesntHave('user'); return DataTables::of($tracking) ->editColumn('character_id', function ($row) { $character_id = $row->character_id; $character = CharacterInfo::find($row->character_id) ?: $row->character_id; return view('web::partials.character', compact('character', 'character_id')); }) ->addColumn('location', function ($row) { return view('web::corporation.partials.location', compact('row')); }) ->addColumn('refresh_token', function ($row) { $refresh_token = false; if(! is_null(optional($row->user)->refresh_token)) $refresh_token = true; return view('web::corporation.partials.refresh-token', compact('refresh_token')); }) ->addColumn('main_character', function ($row) { $character_id = $row->character_id; if(is_null($row->user)) return ''; $main_character_id = $character_id; if (! is_null($row->user->group) && ! is_null(optional($row->user->group)->main_character_id)) $main_character_id = $row->user->group->main_character_id; $character = CharacterInfo::find($main_character_id) ?: $main_character_id; return view('web::partials.character', compact('character', 'character_id')); }) ->filterColumn('name_filter', 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('character_id', array_merge($resolved_ids->toArray(), $character_info_ids->toArray())); }) ->filterColumn('location_filter', function ($query, $keyword) { $system_ids = collect(); if(strlen($keyword) > 1) $system_ids = MapDenormalize::where('itemName', 'like', '%' . $keyword . '%')->select('itemID')->get()->map(function ($system) { return $system->itemID; }); $station_ids = StaStation::where('stationName', 'like', '%' . $keyword . '%')->get()->map(function ($station) { return $station->stationID; }); $structure_ids = UniverseStructure::where('name', 'like', '%' . $keyword . '%')->get()->map(function ($structure) { return $structure->structure_id; }); $query->whereIn('location_id', array_merge($system_ids->toArray(), $station_ids->toArray(), $structure_ids->toArray())); }) ->rawColumns(['character_id', 'main_character', 'refresh_token', 'location']) ->make(true); }
[ "public", "function", "getMemberTracking", "(", "int", "$", "corporation_id", ")", "{", "$", "selected_status", "=", "collect", "(", "request", "(", "'selected_refresh_token_status'", ")", ")", ";", "$", "tracking", "=", "$", "this", "->", "getCorporationMemberTra...
@param int $corporation_id @return mixed @throws \Exception
[ "@param", "int", "$corporation_id" ]
train
https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Http/Controllers/Corporation/TrackingController.php#L55-L130
eveseat/web
src/Http/Controllers/Corporation/ContractsController.php
ContractsController.getContractsData
public function getContractsData(int $corporation_id) { $contracts = $this->getCorporationContracts($corporation_id, false); return DataTables::of($contracts) ->editColumn('issuer_id', function ($row) { return view('web::partials.contractissuer', compact('row')) ->render(); }) ->editColumn('type', function ($row) { return view('web::partials.contracttype', compact('row')) ->render(); }) ->editColumn('status', function ($row) { return ucfirst($row->status); }) ->editColumn('price', function ($row) { return number($row->price); }) ->editColumn('reward', function ($row) { return number($row->reward); }) ->addColumn('contents', function ($row) { return view('web::partials.contractcontentsbutton', compact('row')); }) ->filterColumn('issuer_id', function ($query, $keyword) { $query->whereIn('a.issuer_id', $this->getIdsForNames($keyword)->toArray()); }) ->filterColumn('assignee_id', function ($query, $keyword) { $query->whereIn('a.assignee_id', $this->getIdsForNames($keyword)->toArray()); }) ->filterColumn('acceptor_id', function ($query, $keyword) { $query->whereIn('a.acceptor_id', $this->getIdsForNames($keyword)->toArray()); }) ->rawColumns(['issuer_id', 'type', 'contents']) ->make(true); }
php
public function getContractsData(int $corporation_id) { $contracts = $this->getCorporationContracts($corporation_id, false); return DataTables::of($contracts) ->editColumn('issuer_id', function ($row) { return view('web::partials.contractissuer', compact('row')) ->render(); }) ->editColumn('type', function ($row) { return view('web::partials.contracttype', compact('row')) ->render(); }) ->editColumn('status', function ($row) { return ucfirst($row->status); }) ->editColumn('price', function ($row) { return number($row->price); }) ->editColumn('reward', function ($row) { return number($row->reward); }) ->addColumn('contents', function ($row) { return view('web::partials.contractcontentsbutton', compact('row')); }) ->filterColumn('issuer_id', function ($query, $keyword) { $query->whereIn('a.issuer_id', $this->getIdsForNames($keyword)->toArray()); }) ->filterColumn('assignee_id', function ($query, $keyword) { $query->whereIn('a.assignee_id', $this->getIdsForNames($keyword)->toArray()); }) ->filterColumn('acceptor_id', function ($query, $keyword) { $query->whereIn('a.acceptor_id', $this->getIdsForNames($keyword)->toArray()); }) ->rawColumns(['issuer_id', 'type', 'contents']) ->make(true); }
[ "public", "function", "getContractsData", "(", "int", "$", "corporation_id", ")", "{", "$", "contracts", "=", "$", "this", "->", "getCorporationContracts", "(", "$", "corporation_id", ",", "false", ")", ";", "return", "DataTables", "::", "of", "(", "$", "con...
@param int $corporation_id @return mixed @throws \Exception
[ "@param", "int", "$corporation_id" ]
train
https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Http/Controllers/Corporation/ContractsController.php#L55-L102
eveseat/web
src/Http/Controllers/Corporation/ContractsController.php
ContractsController.getContractsItemsData
public function getContractsItemsData(int $corporation_id, int $contract_id) { $assets = $this->getCorporationContractsItems($corporation_id, $contract_id); return view('web::corporation.contractitems', compact('assets')); }
php
public function getContractsItemsData(int $corporation_id, int $contract_id) { $assets = $this->getCorporationContractsItems($corporation_id, $contract_id); return view('web::corporation.contractitems', compact('assets')); }
[ "public", "function", "getContractsItemsData", "(", "int", "$", "corporation_id", ",", "int", "$", "contract_id", ")", "{", "$", "assets", "=", "$", "this", "->", "getCorporationContractsItems", "(", "$", "corporation_id", ",", "$", "contract_id", ")", ";", "r...
@param int $corporation_id @param int $contract_id @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
[ "@param", "int", "$corporation_id", "@param", "int", "$contract_id" ]
train
https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Http/Controllers/Corporation/ContractsController.php#L110-L116
eveseat/web
src/Http/Controllers/Support/SearchController.php
SearchController.getSearchCharactersData
public function getSearchCharactersData(Request $request) { $characters = $this->doSearchCharacters(); return DataTables::of($characters) ->editColumn('name', function ($row) { $character = CharacterInfo::find($row->character_id); return view('web::partials.character', compact('character')); }) ->editColumn('corporation_id', function ($row) { $corporation = CorporationInfo::find($row->corporation_id); return view('web::partials.corporation', compact('corporation')); }) ->rawColumns(['name', 'corporation_id']) ->make(true); }
php
public function getSearchCharactersData(Request $request) { $characters = $this->doSearchCharacters(); return DataTables::of($characters) ->editColumn('name', function ($row) { $character = CharacterInfo::find($row->character_id); return view('web::partials.character', compact('character')); }) ->editColumn('corporation_id', function ($row) { $corporation = CorporationInfo::find($row->corporation_id); return view('web::partials.corporation', compact('corporation')); }) ->rawColumns(['name', 'corporation_id']) ->make(true); }
[ "public", "function", "getSearchCharactersData", "(", "Request", "$", "request", ")", "{", "$", "characters", "=", "$", "this", "->", "doSearchCharacters", "(", ")", ";", "return", "DataTables", "::", "of", "(", "$", "characters", ")", "->", "editColumn", "(...
@param \Illuminate\Http\Request $request @return mixed @throws \Exception
[ "@param", "\\", "Illuminate", "\\", "Http", "\\", "Request", "$request" ]
train
https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Http/Controllers/Support/SearchController.php#L62-L83
eveseat/web
src/Http/Controllers/Support/SearchController.php
SearchController.getSearchCorporationsData
public function getSearchCorporationsData(Request $request) { $corporations = $this->doSearchCorporations(); return DataTables::of($corporations) ->editColumn('name', function ($row) { $corporation = CorporationInfo::find($row->corporation_id) ?: $row->corporation_id; return view('web::partials.corporation', compact('corporation')); }) ->editColumn('ceo_id', function ($row) { $character = CharacterInfo::find($row->ceo_id) ?: $row->ceo_id; return view('web::partials.character', compact('character')); }) ->editColumn('alliance_id', function ($row) { $alliance = $row->alliance_id; if (empty($alliance)) return ''; return view('web::partials.alliance', compact('alliance')); }) ->rawColumns(['name', 'ceo_id', 'alliance_id']) ->make(true); }
php
public function getSearchCorporationsData(Request $request) { $corporations = $this->doSearchCorporations(); return DataTables::of($corporations) ->editColumn('name', function ($row) { $corporation = CorporationInfo::find($row->corporation_id) ?: $row->corporation_id; return view('web::partials.corporation', compact('corporation')); }) ->editColumn('ceo_id', function ($row) { $character = CharacterInfo::find($row->ceo_id) ?: $row->ceo_id; return view('web::partials.character', compact('character')); }) ->editColumn('alliance_id', function ($row) { $alliance = $row->alliance_id; if (empty($alliance)) return ''; return view('web::partials.alliance', compact('alliance')); }) ->rawColumns(['name', 'ceo_id', 'alliance_id']) ->make(true); }
[ "public", "function", "getSearchCorporationsData", "(", "Request", "$", "request", ")", "{", "$", "corporations", "=", "$", "this", "->", "doSearchCorporations", "(", ")", ";", "return", "DataTables", "::", "of", "(", "$", "corporations", ")", "->", "editColum...
@param \Illuminate\Http\Request $request @return mixed @throws \Exception
[ "@param", "\\", "Illuminate", "\\", "Http", "\\", "Request", "$request" ]
train
https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Http/Controllers/Support/SearchController.php#L91-L120
eveseat/web
src/Http/Controllers/Support/SearchController.php
SearchController.getSearchMailData
public function getSearchMailData(Request $request) { $mail = $this->doSearchCharacterMail(); return DataTables::of($mail) ->editColumn('from', function ($row) { $character = CharacterInfo::find($row->from) ?: $row->from; return view('web::partials.character', compact('character')); }) ->editColumn('subject', function ($row) { return view('web::character.partials.mailtitle', compact('row')); }) ->addColumn('body_clean', function (MailHeader $row) { return strip_tags(str_limit(clean_ccp_html($row->body->body), 30, '...')); }) ->editColumn('tocounts', function ($row) { return view('web::character.partials.mailtocounts', compact('row')); }) ->addColumn('read', function ($row) { return view('web::character.partials.mailread', compact('row')); }) ->addColumn('recipients', function ($row) { $recipients = $row->recipients->map(function ($recipient) { return $recipient->recipient_id; }); return view('web::search.partials.mailrecipient', compact('recipients')); }) ->filterColumn('from', 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('from', array_merge($resolved_ids->toArray(), $character_info_ids->toArray())); }) ->filterColumn('recipients', 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('from', array_merge($resolved_ids->toArray(), $character_info_ids->toArray(), $corporation_info_ids->toArray())); }) ->rawColumns(['from', 'subject', 'tocounts', 'read', 'recipients']) ->make(true); }
php
public function getSearchMailData(Request $request) { $mail = $this->doSearchCharacterMail(); return DataTables::of($mail) ->editColumn('from', function ($row) { $character = CharacterInfo::find($row->from) ?: $row->from; return view('web::partials.character', compact('character')); }) ->editColumn('subject', function ($row) { return view('web::character.partials.mailtitle', compact('row')); }) ->addColumn('body_clean', function (MailHeader $row) { return strip_tags(str_limit(clean_ccp_html($row->body->body), 30, '...')); }) ->editColumn('tocounts', function ($row) { return view('web::character.partials.mailtocounts', compact('row')); }) ->addColumn('read', function ($row) { return view('web::character.partials.mailread', compact('row')); }) ->addColumn('recipients', function ($row) { $recipients = $row->recipients->map(function ($recipient) { return $recipient->recipient_id; }); return view('web::search.partials.mailrecipient', compact('recipients')); }) ->filterColumn('from', 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('from', array_merge($resolved_ids->toArray(), $character_info_ids->toArray())); }) ->filterColumn('recipients', 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('from', array_merge($resolved_ids->toArray(), $character_info_ids->toArray(), $corporation_info_ids->toArray())); }) ->rawColumns(['from', 'subject', 'tocounts', 'read', 'recipients']) ->make(true); }
[ "public", "function", "getSearchMailData", "(", "Request", "$", "request", ")", "{", "$", "mail", "=", "$", "this", "->", "doSearchCharacterMail", "(", ")", ";", "return", "DataTables", "::", "of", "(", "$", "mail", ")", "->", "editColumn", "(", "'from'", ...
@param \Illuminate\Http\Request $request @return mixed @throws \Exception
[ "@param", "\\", "Illuminate", "\\", "Http", "\\", "Request", "$request" ]
train
https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Http/Controllers/Support/SearchController.php#L128-L177
eveseat/web
src/Http/Controllers/Support/SearchController.php
SearchController.getSearchCharacterAssetsData
public function getSearchCharacterAssetsData(Request $request) { $assets = $this->doSearchCharacterAssets(); return DataTables::of($assets) ->editColumn('characterName', function ($row) { $character = CharacterInfo::find($row->character_id) ?: $row->character_id; return view('web::partials.character', compact('character')); }) ->editColumn('typeName', function ($row) { return view('web::search.partials.typename', compact('row')); }) ->rawColumns(['characterName', 'typeName']) ->make(true); }
php
public function getSearchCharacterAssetsData(Request $request) { $assets = $this->doSearchCharacterAssets(); return DataTables::of($assets) ->editColumn('characterName', function ($row) { $character = CharacterInfo::find($row->character_id) ?: $row->character_id; return view('web::partials.character', compact('character')); }) ->editColumn('typeName', function ($row) { return view('web::search.partials.typename', compact('row')); }) ->rawColumns(['characterName', 'typeName']) ->make(true); }
[ "public", "function", "getSearchCharacterAssetsData", "(", "Request", "$", "request", ")", "{", "$", "assets", "=", "$", "this", "->", "doSearchCharacterAssets", "(", ")", ";", "return", "DataTables", "::", "of", "(", "$", "assets", ")", "->", "editColumn", ...
@param \Illuminate\Http\Request $request @return mixed @throws \Exception
[ "@param", "\\", "Illuminate", "\\", "Http", "\\", "Request", "$request" ]
train
https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Http/Controllers/Support/SearchController.php#L185-L204
eveseat/web
src/Http/Controllers/Support/SearchController.php
SearchController.getSearchCharacterSkillsData
public function getSearchCharacterSkillsData(Request $request) { $skills = $this->doSearchCharacterSkills(); return DataTables::of($skills) ->editColumn('character_name', function ($row) { $character = CharacterInfo::find($row->character_id) ?: $row->character_id; return view('web::partials.character', compact('character')); }) ->editColumn('corporation_id', function ($row) { $corporation = CorporationInfo::find($row->corporation_id) ?: $row->corporation_id; return view('web::partials.corporation', compact('corporation')); }) ->editColumn('typeName', function ($row) { return view('web::search.partials.typename', compact('row')); }) ->rawColumns(['character_name', 'corporation_id', 'typeName']) ->make(true); }
php
public function getSearchCharacterSkillsData(Request $request) { $skills = $this->doSearchCharacterSkills(); return DataTables::of($skills) ->editColumn('character_name', function ($row) { $character = CharacterInfo::find($row->character_id) ?: $row->character_id; return view('web::partials.character', compact('character')); }) ->editColumn('corporation_id', function ($row) { $corporation = CorporationInfo::find($row->corporation_id) ?: $row->corporation_id; return view('web::partials.corporation', compact('corporation')); }) ->editColumn('typeName', function ($row) { return view('web::search.partials.typename', compact('row')); }) ->rawColumns(['character_name', 'corporation_id', 'typeName']) ->make(true); }
[ "public", "function", "getSearchCharacterSkillsData", "(", "Request", "$", "request", ")", "{", "$", "skills", "=", "$", "this", "->", "doSearchCharacterSkills", "(", ")", ";", "return", "DataTables", "::", "of", "(", "$", "skills", ")", "->", "editColumn", ...
@param \Illuminate\Http\Request $request @return mixed @throws \Exception
[ "@param", "\\", "Illuminate", "\\", "Http", "\\", "Request", "$request" ]
train
https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Http/Controllers/Support/SearchController.php#L212-L237
eveseat/web
src/Http/Controllers/Corporation/MiningLedgerController.php
MiningLedgerController.getLedger
public function getLedger(int $corporation_id, int $year = null, int $month = null): View { if (is_null($year)) $year = date('Y'); if (is_null($month)) $month = date('m'); $ledgers = $this->getCorporationLedgers($corporation_id); $entries = $this->getCorporationLedger($corporation_id, $year, $month); return view('web::corporation.mining.ledger', compact('ledgers', 'entries')); }
php
public function getLedger(int $corporation_id, int $year = null, int $month = null): View { if (is_null($year)) $year = date('Y'); if (is_null($month)) $month = date('m'); $ledgers = $this->getCorporationLedgers($corporation_id); $entries = $this->getCorporationLedger($corporation_id, $year, $month); return view('web::corporation.mining.ledger', compact('ledgers', 'entries')); }
[ "public", "function", "getLedger", "(", "int", "$", "corporation_id", ",", "int", "$", "year", "=", "null", ",", "int", "$", "month", "=", "null", ")", ":", "View", "{", "if", "(", "is_null", "(", "$", "year", ")", ")", "$", "year", "=", "date", ...
@param int $corporation_id @param int|null $year @param int|null $month @return \Illuminate\View\View
[ "@param", "int", "$corporation_id", "@param", "int|null", "$year", "@param", "int|null", "$month" ]
train
https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Http/Controllers/Corporation/MiningLedgerController.php#L46-L60
eveseat/web
src/Http/Controllers/Corporation/MiningLedgerController.php
MiningLedgerController.getTracking
public function getTracking(int $corporation_id): View { $members = CorporationMemberTracking::where('corporation_id', $corporation_id)->get(); return view('mining-ledger::corporation.views.tracking', compact('members')); }
php
public function getTracking(int $corporation_id): View { $members = CorporationMemberTracking::where('corporation_id', $corporation_id)->get(); return view('mining-ledger::corporation.views.tracking', compact('members')); }
[ "public", "function", "getTracking", "(", "int", "$", "corporation_id", ")", ":", "View", "{", "$", "members", "=", "CorporationMemberTracking", "::", "where", "(", "'corporation_id'", ",", "$", "corporation_id", ")", "->", "get", "(", ")", ";", "return", "v...
@param int $corporation_id @return \Illuminate\View\View
[ "@param", "int", "$corporation_id" ]
train
https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Http/Controllers/Corporation/MiningLedgerController.php#L67-L73
eveseat/web
src/Http/Composers/User.php
User.compose
public function compose(View $view) { $view->with('user', Auth::user()); $view->with('user_characters', $this->getUserGroupCharacters(auth()->user()->group)); }
php
public function compose(View $view) { $view->with('user', Auth::user()); $view->with('user_characters', $this->getUserGroupCharacters(auth()->user()->group)); }
[ "public", "function", "compose", "(", "View", "$", "view", ")", "{", "$", "view", "->", "with", "(", "'user'", ",", "Auth", "::", "user", "(", ")", ")", ";", "$", "view", "->", "with", "(", "'user_characters'", ",", "$", "this", "->", "getUserGroupCh...
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/User.php#L44-L49
eveseat/web
src/Events/Login.php
Login.handle
public static function handle(LoginEvent $event) { // Create a log entry for this login. $event->user->last_login_source = Request::getClientIp(); $event->user->last_login = new DateTime(); $event->user->save(); $event->user->login_history()->save(new UserLoginHistory([ 'source' => Request::getClientIp(), 'user_agent' => Request::header('User-Agent'), 'action' => 'login', ])); $message = 'User logged in from ' . Request::getClientIp(); event('security.log', [$message, 'authentication']); if ($event->user->refresh_token()->exists()) { // Update Character information (new CharacterTokenShouldUpdate($event->user->refresh_token, 'high'))->fire(); // Update Corporation information (new CorporationTokenShouldUpdate($event->user->refresh_token, 'high'))->fire(); } }
php
public static function handle(LoginEvent $event) { // Create a log entry for this login. $event->user->last_login_source = Request::getClientIp(); $event->user->last_login = new DateTime(); $event->user->save(); $event->user->login_history()->save(new UserLoginHistory([ 'source' => Request::getClientIp(), 'user_agent' => Request::header('User-Agent'), 'action' => 'login', ])); $message = 'User logged in from ' . Request::getClientIp(); event('security.log', [$message, 'authentication']); if ($event->user->refresh_token()->exists()) { // Update Character information (new CharacterTokenShouldUpdate($event->user->refresh_token, 'high'))->fire(); // Update Corporation information (new CorporationTokenShouldUpdate($event->user->refresh_token, 'high'))->fire(); } }
[ "public", "static", "function", "handle", "(", "LoginEvent", "$", "event", ")", "{", "// Create a log entry for this login.", "$", "event", "->", "user", "->", "last_login_source", "=", "Request", "::", "getClientIp", "(", ")", ";", "$", "event", "->", "user", ...
Update the last login values and write a new login history item. @param \Illuminate\Auth\Events\Login $event
[ "Update", "the", "last", "login", "values", "and", "write", "a", "new", "login", "history", "item", "." ]
train
https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Events/Login.php#L45-L70
eveseat/web
src/Http/Controllers/Character/ContractsController.php
ContractsController.getContractsData
public function getContractsData(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) { return $user->name !== 'admin' && $user->id !== 1; }) ->pluck('id'); if (request('all_linked_characters') === 'true') $character_ids = $user_group; $contracts = $this->getCharacterContracts($character_ids); return DataTables::of($contracts) ->editColumn('issuer_id', function ($row) { $character_id = $row->character_id; if ($row->for_corporation){ $corporation = CorporationInfo::find($row->issuer_corporation_id) ?: $row->issuer_corporation_id; $character = CharacterInfo::find($row->issuer_id) ?: $row->issuer_id; return view('web::partials.corporation', compact('corporation', 'character_id')) . '<br/>(' . view('web::partials.character', compact('character', 'character_id')) . ')'; } $character = CharacterInfo::find($row->issuer_id) ?: $row->issuer_id; return view('web::partials.character', compact('character', 'character_id')); }) ->editColumn('assignee_id', function ($row) { if ($row->assignee_id === 0) return trans('web::seat.public'); $character_id = $row->character_id; $character = CharacterInfo::find($row->assignee_id) ?: null; if (! is_null($character)) return view('web::partials.character', compact('character', 'character_id')); $corporation = CorporationInfo::find($row->assignee_id) ?: null; if (! is_null($corporation)) return view('web::partials.corporation', compact('corporation', 'character_id')); return view('web::partials.unknown', [ 'unknown_id' => $row->assignee_id, 'character_id' => $row->character_id, ]); }) ->editColumn('acceptor_id', function ($row) { if ($row->acceptor_id === 0) return ''; $character_id = $row->character_id; $character = CharacterInfo::find($row->acceptor_id) ?: null; if (! is_null($character)) return view('web::partials.character', compact('character', 'character_id')); $corporation = CorporationInfo::find($row->acceptor_id) ?: null; if (! is_null($corporation)) return view('web::partials.corporation', compact('corporation', 'character_id')); return view('web::partials.unknown', [ 'unknown_id' => $row->acceptor_id, 'character_id' => $row->character_id, ]); }) ->editColumn('type', function ($row) { return view('web::partials.contracttype', compact('row')) ->render(); }) ->editColumn('price', function ($row) { return number($row->price); }) ->editColumn('reward', function ($row) { return number($row->reward); }) ->editColumn('collateral', function ($row) { return number($row->collateral); }) ->addColumn('contents', function ($row) { return view('web::partials.contractcontentsbutton', compact('row')); }) ->addColumn('is_in_group', function ($row) use ($user_group) { if (in_array($row->issuer_id, $user_group->toArray()) && in_array($row->acceptor_id, $user_group->toArray())) return true; if (in_array($row->issuer_id, $user_group->toArray()) && in_array($row->assignee_id, $user_group->toArray())) return true; return false; }) ->filterColumn('issuer_id', function ($query, $keyword) { $query->whereIn('a.issuer_id', $this->getIdsForNames($keyword)->toArray()); }) ->filterColumn('assignee_id', function ($query, $keyword) { $query->whereIn('a.assignee_id', $this->getIdsForNames($keyword)->toArray()); }) ->filterColumn('acceptor_id', function ($query, $keyword) { $query->whereIn('a.acceptor_id', $this->getIdsForNames($keyword)->toArray()); }) ->rawColumns(['issuer_id', 'type', 'contents', 'assignee_id', 'acceptor_id']) ->make(true); }
php
public function getContractsData(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) { return $user->name !== 'admin' && $user->id !== 1; }) ->pluck('id'); if (request('all_linked_characters') === 'true') $character_ids = $user_group; $contracts = $this->getCharacterContracts($character_ids); return DataTables::of($contracts) ->editColumn('issuer_id', function ($row) { $character_id = $row->character_id; if ($row->for_corporation){ $corporation = CorporationInfo::find($row->issuer_corporation_id) ?: $row->issuer_corporation_id; $character = CharacterInfo::find($row->issuer_id) ?: $row->issuer_id; return view('web::partials.corporation', compact('corporation', 'character_id')) . '<br/>(' . view('web::partials.character', compact('character', 'character_id')) . ')'; } $character = CharacterInfo::find($row->issuer_id) ?: $row->issuer_id; return view('web::partials.character', compact('character', 'character_id')); }) ->editColumn('assignee_id', function ($row) { if ($row->assignee_id === 0) return trans('web::seat.public'); $character_id = $row->character_id; $character = CharacterInfo::find($row->assignee_id) ?: null; if (! is_null($character)) return view('web::partials.character', compact('character', 'character_id')); $corporation = CorporationInfo::find($row->assignee_id) ?: null; if (! is_null($corporation)) return view('web::partials.corporation', compact('corporation', 'character_id')); return view('web::partials.unknown', [ 'unknown_id' => $row->assignee_id, 'character_id' => $row->character_id, ]); }) ->editColumn('acceptor_id', function ($row) { if ($row->acceptor_id === 0) return ''; $character_id = $row->character_id; $character = CharacterInfo::find($row->acceptor_id) ?: null; if (! is_null($character)) return view('web::partials.character', compact('character', 'character_id')); $corporation = CorporationInfo::find($row->acceptor_id) ?: null; if (! is_null($corporation)) return view('web::partials.corporation', compact('corporation', 'character_id')); return view('web::partials.unknown', [ 'unknown_id' => $row->acceptor_id, 'character_id' => $row->character_id, ]); }) ->editColumn('type', function ($row) { return view('web::partials.contracttype', compact('row')) ->render(); }) ->editColumn('price', function ($row) { return number($row->price); }) ->editColumn('reward', function ($row) { return number($row->reward); }) ->editColumn('collateral', function ($row) { return number($row->collateral); }) ->addColumn('contents', function ($row) { return view('web::partials.contractcontentsbutton', compact('row')); }) ->addColumn('is_in_group', function ($row) use ($user_group) { if (in_array($row->issuer_id, $user_group->toArray()) && in_array($row->acceptor_id, $user_group->toArray())) return true; if (in_array($row->issuer_id, $user_group->toArray()) && in_array($row->assignee_id, $user_group->toArray())) return true; return false; }) ->filterColumn('issuer_id', function ($query, $keyword) { $query->whereIn('a.issuer_id', $this->getIdsForNames($keyword)->toArray()); }) ->filterColumn('assignee_id', function ($query, $keyword) { $query->whereIn('a.assignee_id', $this->getIdsForNames($keyword)->toArray()); }) ->filterColumn('acceptor_id', function ($query, $keyword) { $query->whereIn('a.acceptor_id', $this->getIdsForNames($keyword)->toArray()); }) ->rawColumns(['issuer_id', 'type', 'contents', 'assignee_id', 'acceptor_id']) ->make(true); }
[ "public", "function", "getContractsData", "(", "int", "$", "character_id", ")", "{", "if", "(", "!", "request", "(", ")", "->", "ajax", "(", ")", ")", "return", "view", "(", "'web::character.contacts'", ")", ";", "if", "(", "!", "request", "(", ")", "-...
@param int $character_id @return mixed @throws \Exception
[ "@param", "int", "$character_id" ]
train
https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Http/Controllers/Character/ContractsController.php#L59-L191
eveseat/web
src/Http/Controllers/Character/ContractsController.php
ContractsController.getContractsItemsData
public function getContractsItemsData(int $character_id, int $contract_id) { $assets = $this->getCharacterContractsItems($character_id, $contract_id); return view('web::character.contractitems', compact('assets')); }
php
public function getContractsItemsData(int $character_id, int $contract_id) { $assets = $this->getCharacterContractsItems($character_id, $contract_id); return view('web::character.contractitems', compact('assets')); }
[ "public", "function", "getContractsItemsData", "(", "int", "$", "character_id", ",", "int", "$", "contract_id", ")", "{", "$", "assets", "=", "$", "this", "->", "getCharacterContractsItems", "(", "$", "character_id", ",", "$", "contract_id", ")", ";", "return"...
@param int $character_id @param int $contract_id @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
[ "@param", "int", "$character_id", "@param", "int", "$contract_id" ]
train
https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Http/Controllers/Character/ContractsController.php#L199-L205
eveseat/web
src/Http/Composers/Sidebar.php
Sidebar.compose
public function compose(View $view) { // Grab the menu and sort it. $menu = config('package.sidebar'); ksort($menu); // Return the sidebar with the loaded packages menus $view->with('menu', collect($menu)->map(function ($menu_data, $package_name) { return $this->load_plugin_menu($package_name, $menu_data); })->filter(function ($entry) { // Clean out empty entries that may appear as a result of // permissions not being granted. if (! is_null($entry)) return $entry; })); }
php
public function compose(View $view) { // Grab the menu and sort it. $menu = config('package.sidebar'); ksort($menu); // Return the sidebar with the loaded packages menus $view->with('menu', collect($menu)->map(function ($menu_data, $package_name) { return $this->load_plugin_menu($package_name, $menu_data); })->filter(function ($entry) { // Clean out empty entries that may appear as a result of // permissions not being granted. if (! is_null($entry)) return $entry; })); }
[ "public", "function", "compose", "(", "View", "$", "view", ")", "{", "// Grab the menu and sort it.", "$", "menu", "=", "config", "(", "'package.sidebar'", ")", ";", "ksort", "(", "$", "menu", ")", ";", "// Return the sidebar with the loaded packages menus", "$", ...
Bind data to the view. @param View $view
[ "Bind", "data", "to", "the", "view", "." ]
train
https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Http/Composers/Sidebar.php#L51-L70
eveseat/web
src/Http/Middleware/Bouncer/CorporationBouncer.php
CorporationBouncer.handle
public function handle(Request $request, Closure $next, $permission = null) { // Check on the clipboard if this permission // should be granted. if (auth()->user()->has('corporation.' . $permission)) return $next($request); $message = 'Request to ' . $request->path() . ' was ' . 'denied by the corporationbouncer. The permission required is ' . 'corporation.' . $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, $permission = null) { // Check on the clipboard if this permission // should be granted. if (auth()->user()->has('corporation.' . $permission)) return $next($request); $message = 'Request to ' . $request->path() . ' was ' . 'denied by the corporationbouncer. The permission required is ' . 'corporation.' . $permission . '.'; event('security.log', [$message, 'authorization']); // Redirect away from the original request return redirect()->route('auth.unauthorized'); }
[ "public", "function", "handle", "(", "Request", "$", "request", ",", "Closure", "$", "next", ",", "$", "permission", "=", "null", ")", "{", "// Check on the clipboard if this permission", "// should be granted.", "if", "(", "auth", "(", ")", "->", "user", "(", ...
Handle an incoming request. This filter checks if a specific permission exists as well as ensures that an affiliation to a corporation exists. @param \Illuminate\Http\Request $request @param \Closure $next @param null $permission @return \Illuminate\Http\RedirectResponse
[ "Handle", "an", "incoming", "request", "." ]
train
https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Http/Middleware/Bouncer/CorporationBouncer.php#L47-L64
eveseat/web
src/Http/Controllers/Character/KillmailController.php
KillmailController.getKillmailsData
public function getKillmailsData(int $character_id) { 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) { return $user->name !== 'admin' && $user->id !== 1; }) ->pluck('id'); if (request('all_linked_characters') === 'true') $character_ids = $user_group; $killmails = $this->getCharacterKillmails($character_ids); 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')) ->render(); }) ->addColumn('place', function ($row) { if (is_null($row->killmail_detail)) return ''; $place = $row->killmail_detail->solar_system; return view('web::partials.killmailsystem', compact('place')) ->render(); }) ->addColumn('zkb', function ($row) { return view('web::partials.killmailzkb', compact('row')) ->render(); }) ->rawColumns(['victim', 'ship', 'place', 'zkb']) ->make(true); }
php
public function getKillmailsData(int $character_id) { 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) { return $user->name !== 'admin' && $user->id !== 1; }) ->pluck('id'); if (request('all_linked_characters') === 'true') $character_ids = $user_group; $killmails = $this->getCharacterKillmails($character_ids); 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')) ->render(); }) ->addColumn('place', function ($row) { if (is_null($row->killmail_detail)) return ''; $place = $row->killmail_detail->solar_system; return view('web::partials.killmailsystem', compact('place')) ->render(); }) ->addColumn('zkb', function ($row) { return view('web::partials.killmailzkb', compact('row')) ->render(); }) ->rawColumns(['victim', 'ship', 'place', 'zkb']) ->make(true); }
[ "public", "function", "getKillmailsData", "(", "int", "$", "character_id", ")", "{", "if", "(", "!", "request", "(", ")", "->", "has", "(", "'all_linked_characters'", ")", ")", "return", "response", "(", "'required url parameter is missing!'", ",", "400", ")", ...
@param int $character_id @return mixed @throws \Exception
[ "@param", "int", "$character_id" ]
train
https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Http/Controllers/Character/KillmailController.php#L58-L129
eveseat/web
src/Http/Controllers/Configuration/UserController.php
UserController.editUser
public function editUser($user_id) { $user = $this->getFullUser($user_id); // get all groups except the one containing admin as admin account is special account // and the one to which the current user is already attached. $groups = $this->getAllGroups()->filter(function ($group, $key) use ($user_id) { return $group->users->where('name', 'admin')->isEmpty() && $group->users->where('id', $user_id)->isEmpty(); }); $login_history = $user->login_history()->orderBy('created_at', 'desc')->take(15) ->get(); return view('web::configuration.users.edit', compact('user', 'groups', 'login_history')); }
php
public function editUser($user_id) { $user = $this->getFullUser($user_id); // get all groups except the one containing admin as admin account is special account // and the one to which the current user is already attached. $groups = $this->getAllGroups()->filter(function ($group, $key) use ($user_id) { return $group->users->where('name', 'admin')->isEmpty() && $group->users->where('id', $user_id)->isEmpty(); }); $login_history = $user->login_history()->orderBy('created_at', 'desc')->take(15) ->get(); return view('web::configuration.users.edit', compact('user', 'groups', 'login_history')); }
[ "public", "function", "editUser", "(", "$", "user_id", ")", "{", "$", "user", "=", "$", "this", "->", "getFullUser", "(", "$", "user_id", ")", ";", "// get all groups except the one containing admin as admin account is special account", "// and the one to which the current ...
@param $user_id @return \Illuminate\View\View
[ "@param", "$user_id" ]
train
https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Http/Controllers/Configuration/UserController.php#L141-L158
eveseat/web
src/Http/Controllers/Configuration/UserController.php
UserController.updateUser
public function updateUser(EditUser $request) { // retrieve the group to which the edited user is attached. $group_id = User::find($request->input('user_id'))->group_id; // determine if the new e-mail address is already in use. $email_exists = UserSetting::where('name', 'email_address') ->where('value', sprintf('"%s"', $request->input('email'))) ->where('group_id', '<>', $group_id) ->count() > 0; if ($email_exists) return redirect()->back() ->with('error', trans('email_in_use', ['mail' => $request->input('email')])); try { setting(['email_address', $request->input('email'), $group_id], false); } catch (Exception $e) { return redirect()->back() ->with('error', $e->getMessage()); } return redirect()->back() ->with('success', trans('web::seat.user_updated')); }
php
public function updateUser(EditUser $request) { // retrieve the group to which the edited user is attached. $group_id = User::find($request->input('user_id'))->group_id; // determine if the new e-mail address is already in use. $email_exists = UserSetting::where('name', 'email_address') ->where('value', sprintf('"%s"', $request->input('email'))) ->where('group_id', '<>', $group_id) ->count() > 0; if ($email_exists) return redirect()->back() ->with('error', trans('email_in_use', ['mail' => $request->input('email')])); try { setting(['email_address', $request->input('email'), $group_id], false); } catch (Exception $e) { return redirect()->back() ->with('error', $e->getMessage()); } return redirect()->back() ->with('success', trans('web::seat.user_updated')); }
[ "public", "function", "updateUser", "(", "EditUser", "$", "request", ")", "{", "// retrieve the group to which the edited user is attached.", "$", "group_id", "=", "User", "::", "find", "(", "$", "request", "->", "input", "(", "'user_id'", ")", ")", "->", "group_i...
@param \Seat\Web\Http\Validation\EditUser $request @return mixed
[ "@param", "\\", "Seat", "\\", "Web", "\\", "Http", "\\", "Validation", "\\", "EditUser", "$request" ]
train
https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Http/Controllers/Configuration/UserController.php#L165-L190
eveseat/web
src/Http/Controllers/Configuration/UserController.php
UserController.postReassignuser
public function postReassignuser(ReassignUser $request) { $user = $this->getUser($request->input('user_id')); $current_group = $user->group; $user->fill([ 'group_id' => $request->input('group_id'), ]); $user->save(); // Ensure the old group is not an orphan now. if (! is_null($current_group) && $current_group->users->isEmpty()) $current_group->delete(); return redirect()->back() ->with('success', trans('web::seat.user_updated')); }
php
public function postReassignuser(ReassignUser $request) { $user = $this->getUser($request->input('user_id')); $current_group = $user->group; $user->fill([ 'group_id' => $request->input('group_id'), ]); $user->save(); // Ensure the old group is not an orphan now. if (! is_null($current_group) && $current_group->users->isEmpty()) $current_group->delete(); return redirect()->back() ->with('success', trans('web::seat.user_updated')); }
[ "public", "function", "postReassignuser", "(", "ReassignUser", "$", "request", ")", "{", "$", "user", "=", "$", "this", "->", "getUser", "(", "$", "request", "->", "input", "(", "'user_id'", ")", ")", ";", "$", "current_group", "=", "$", "user", "->", ...
@param \Seat\Web\Http\Validation\ReassignUser $request @return \Illuminate\Http\RedirectResponse
[ "@param", "\\", "Seat", "\\", "Web", "\\", "Http", "\\", "Validation", "\\", "ReassignUser", "$request" ]
train
https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Http/Controllers/Configuration/UserController.php#L197-L214
eveseat/web
src/Http/Controllers/Configuration/UserController.php
UserController.deleteUser
public function deleteUser(Request $request, $user_id) { if ($request->user()->id == $user_id) return redirect()->back() ->with('warning', trans('web::seat.self_delete_warning')); $user = $this->getUser($user_id); $group = $user->group; // Delete the user. $user->delete(); // Ensure the orphan group is cleaned up. if ($group->users->isEmpty()) $group->delete(); return redirect()->back() ->with('success', trans('web::seat.user_deleted')); }
php
public function deleteUser(Request $request, $user_id) { if ($request->user()->id == $user_id) return redirect()->back() ->with('warning', trans('web::seat.self_delete_warning')); $user = $this->getUser($user_id); $group = $user->group; // Delete the user. $user->delete(); // Ensure the orphan group is cleaned up. if ($group->users->isEmpty()) $group->delete(); return redirect()->back() ->with('success', trans('web::seat.user_deleted')); }
[ "public", "function", "deleteUser", "(", "Request", "$", "request", ",", "$", "user_id", ")", "{", "if", "(", "$", "request", "->", "user", "(", ")", "->", "id", "==", "$", "user_id", ")", "return", "redirect", "(", ")", "->", "back", "(", ")", "->...
@param \Illuminate\Http\Request $request @param $user_id @return mixed
[ "@param", "\\", "Illuminate", "\\", "Http", "\\", "Request", "$request", "@param", "$user_id" ]
train
https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Http/Controllers/Configuration/UserController.php#L236-L254
eveseat/web
src/Http/Controllers/Configuration/UserController.php
UserController.impersonate
public function impersonate($user_id) { // Store the original user in the session session(['impersonation_origin' => auth()->user()]); // Get the user $user = $this->getUser($user_id); // Log the impersonation event. event('security.log', [ 'Impersonating ' . $user->name, 'authentication', ]); // ensure the user got a valid group - spawn it otherwise if (is_null($user->group)) { Group::forceCreate([ 'id' => $user->group_id, ]); // force laravel to update model relationship information $user->load('group'); // assign the main_character setting(['main_character_id', $user->id, $user->group_id]); } // Login as the new user. auth()->login($user); return redirect()->route('home') ->with('success', trans('web::seat.impersonating', ['user' => $user->name])); }
php
public function impersonate($user_id) { // Store the original user in the session session(['impersonation_origin' => auth()->user()]); // Get the user $user = $this->getUser($user_id); // Log the impersonation event. event('security.log', [ 'Impersonating ' . $user->name, 'authentication', ]); // ensure the user got a valid group - spawn it otherwise if (is_null($user->group)) { Group::forceCreate([ 'id' => $user->group_id, ]); // force laravel to update model relationship information $user->load('group'); // assign the main_character setting(['main_character_id', $user->id, $user->group_id]); } // Login as the new user. auth()->login($user); return redirect()->route('home') ->with('success', trans('web::seat.impersonating', ['user' => $user->name])); }
[ "public", "function", "impersonate", "(", "$", "user_id", ")", "{", "// Store the original user in the session", "session", "(", "[", "'impersonation_origin'", "=>", "auth", "(", ")", "->", "user", "(", ")", "]", ")", ";", "// Get the user", "$", "user", "=", ...
@param $user_id @return mixed
[ "@param", "$user_id" ]
train
https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Http/Controllers/Configuration/UserController.php#L261-L294
eveseat/web
src/Http/Controllers/Character/IndustryController.php
IndustryController.getIndustryData
public function getIndustryData(int $character_id) { $jobs = $this->getCharacterIndustry($character_id, false); return DataTables::of($jobs) ->editColumn('installerName', 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(['installerName', 'facilityName', 'blueprintTypeName', 'productTypeName']) ->make(true); }
php
public function getIndustryData(int $character_id) { $jobs = $this->getCharacterIndustry($character_id, false); return DataTables::of($jobs) ->editColumn('installerName', 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(['installerName', 'facilityName', 'blueprintTypeName', 'productTypeName']) ->make(true); }
[ "public", "function", "getIndustryData", "(", "int", "$", "character_id", ")", "{", "$", "jobs", "=", "$", "this", "->", "getCharacterIndustry", "(", "$", "character_id", ",", "false", ")", ";", "return", "DataTables", "::", "of", "(", "$", "jobs", ")", ...
@param int $character_id @return mixed
[ "@param", "int", "$character_id" ]
train
https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/Http/Controllers/Character/IndustryController.php#L53-L82
eveseat/web
src/WebServiceProvider.php
WebServiceProvider.boot
public function boot(Router $router) { // Include the Routes $this->add_routes(); // Publish the JS & CSS, and Database migrations $this->add_publications(); // Inform Laravel how to load migrations $this->add_migrations(); // Add the views for the 'web' namespace $this->add_views(); // Add the view composers $this->add_view_composers(); // Include our translations $this->add_translations(); // Add middleware $this->add_middleware($router); // Add event listeners $this->add_events(); // Add Validators $this->add_custom_validators(); // Configure the queue dashboard $this->configure_horizon(); // Configure API $this->configure_api(); }
php
public function boot(Router $router) { // Include the Routes $this->add_routes(); // Publish the JS & CSS, and Database migrations $this->add_publications(); // Inform Laravel how to load migrations $this->add_migrations(); // Add the views for the 'web' namespace $this->add_views(); // Add the view composers $this->add_view_composers(); // Include our translations $this->add_translations(); // Add middleware $this->add_middleware($router); // Add event listeners $this->add_events(); // Add Validators $this->add_custom_validators(); // Configure the queue dashboard $this->configure_horizon(); // Configure API $this->configure_api(); }
[ "public", "function", "boot", "(", "Router", "$", "router", ")", "{", "// Include the Routes", "$", "this", "->", "add_routes", "(", ")", ";", "// Publish the JS & CSS, and Database migrations", "$", "this", "->", "add_publications", "(", ")", ";", "// Inform Larave...
Bootstrap the application services. @param \Illuminate\Routing\Router $router
[ "Bootstrap", "the", "application", "services", "." ]
train
https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/WebServiceProvider.php#L78-L113
eveseat/web
src/WebServiceProvider.php
WebServiceProvider.add_view_composers
public function add_view_composers() { // User information view composer $this->app['view']->composer([ 'web::includes.header', 'web::includes.sidebar', ], User::class); // ESI Status view composer $this->app['view']->composer([ 'web::includes.footer', ], Esi::class); // Sidebar menu view composer $this->app['view']->composer( 'web::includes.sidebar', Sidebar::class); // Character info composer $this->app['view']->composer([ 'web::character.includes.summary', 'web::character.includes.menu', 'web::character.intel.includes.menu', 'web::character.wallet.includes.menu', ], CharacterSummary::class); // Character menu composer $this->app['view']->composer([ 'web::character.includes.menu', ], CharacterMenu::class); // Character layout breadcrumb $this->app['view']->composer([ 'web::character.layouts.view', ], CharacterLayout::class); // Corporation info composer $this->app['view']->composer([ 'web::corporation.includes.summary', 'web::corporation.includes.menu', 'web::corporation.security.includes.menu', 'web::corporation.ledger.includes.menu', 'web::corporation.wallet.includes.menu', ], CorporationSummary::class); // Corporation menu composer $this->app['view']->composer([ 'web::corporation.includes.menu', ], CorporationMenu::class); // Corporation layout breadcrumb $this->app['view']->composer([ 'web::corporation.layouts.view', ], CorporationLayout::class); }
php
public function add_view_composers() { // User information view composer $this->app['view']->composer([ 'web::includes.header', 'web::includes.sidebar', ], User::class); // ESI Status view composer $this->app['view']->composer([ 'web::includes.footer', ], Esi::class); // Sidebar menu view composer $this->app['view']->composer( 'web::includes.sidebar', Sidebar::class); // Character info composer $this->app['view']->composer([ 'web::character.includes.summary', 'web::character.includes.menu', 'web::character.intel.includes.menu', 'web::character.wallet.includes.menu', ], CharacterSummary::class); // Character menu composer $this->app['view']->composer([ 'web::character.includes.menu', ], CharacterMenu::class); // Character layout breadcrumb $this->app['view']->composer([ 'web::character.layouts.view', ], CharacterLayout::class); // Corporation info composer $this->app['view']->composer([ 'web::corporation.includes.summary', 'web::corporation.includes.menu', 'web::corporation.security.includes.menu', 'web::corporation.ledger.includes.menu', 'web::corporation.wallet.includes.menu', ], CorporationSummary::class); // Corporation menu composer $this->app['view']->composer([ 'web::corporation.includes.menu', ], CorporationMenu::class); // Corporation layout breadcrumb $this->app['view']->composer([ 'web::corporation.layouts.view', ], CorporationLayout::class); }
[ "public", "function", "add_view_composers", "(", ")", "{", "// User information view composer", "$", "this", "->", "app", "[", "'view'", "]", "->", "composer", "(", "[", "'web::includes.header'", ",", "'web::includes.sidebar'", ",", "]", ",", "User", "::", "class"...
Add the view composers. This allows us to make data available in views without repeating any of the code.
[ "Add", "the", "view", "composers", ".", "This", "allows", "us", "to", "make", "data", "available", "in", "views", "without", "repeating", "any", "of", "the", "code", "." ]
train
https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/WebServiceProvider.php#L155-L210
eveseat/web
src/WebServiceProvider.php
WebServiceProvider.add_middleware
public function add_middleware($router) { // Authenticate checks that the session is // simply authenticated $router->aliasMiddleware('auth', Authenticate::class); // Ensure that all of the SeAT required modules is installed. $router->aliasMiddleware('requirements', Requirements::class); // Localization support $router->aliasMiddleware('locale', Locale::class); // Registration Middleware checks of the app is // allowing new user registration to occur. $router->aliasMiddleware('registration.status', RegistrationAllowed::class); // The Bouncer is responsible for checking hes // AccessChecker and ensuring that every request // that comes in is authorized $router->aliasMiddleware('bouncer', Bouncer::class); $router->aliasMiddleware('characterbouncer', CharacterBouncer::class); $router->aliasMiddleware('corporationbouncer', CorporationBouncer::class); $router->aliasMiddleware('keybouncer', KeyBouncer::class); }
php
public function add_middleware($router) { // Authenticate checks that the session is // simply authenticated $router->aliasMiddleware('auth', Authenticate::class); // Ensure that all of the SeAT required modules is installed. $router->aliasMiddleware('requirements', Requirements::class); // Localization support $router->aliasMiddleware('locale', Locale::class); // Registration Middleware checks of the app is // allowing new user registration to occur. $router->aliasMiddleware('registration.status', RegistrationAllowed::class); // The Bouncer is responsible for checking hes // AccessChecker and ensuring that every request // that comes in is authorized $router->aliasMiddleware('bouncer', Bouncer::class); $router->aliasMiddleware('characterbouncer', CharacterBouncer::class); $router->aliasMiddleware('corporationbouncer', CorporationBouncer::class); $router->aliasMiddleware('keybouncer', KeyBouncer::class); }
[ "public", "function", "add_middleware", "(", "$", "router", ")", "{", "// Authenticate checks that the session is", "// simply authenticated", "$", "router", "->", "aliasMiddleware", "(", "'auth'", ",", "Authenticate", "::", "class", ")", ";", "// Ensure that all of the S...
Include the middleware needed. @param $router
[ "Include", "the", "middleware", "needed", "." ]
train
https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/WebServiceProvider.php#L226-L251
eveseat/web
src/WebServiceProvider.php
WebServiceProvider.add_events
public function add_events() { // Internal Authentication Events $this->app->events->listen(LoginEvent::class, Login::class); $this->app->events->listen(LogoutEvent::class, Logout::class); $this->app->events->listen(Attempting::class, Attempt::class); // Custom Events $this->app->events->listen('security.log', SecLog::class); }
php
public function add_events() { // Internal Authentication Events $this->app->events->listen(LoginEvent::class, Login::class); $this->app->events->listen(LogoutEvent::class, Logout::class); $this->app->events->listen(Attempting::class, Attempt::class); // Custom Events $this->app->events->listen('security.log', SecLog::class); }
[ "public", "function", "add_events", "(", ")", "{", "// Internal Authentication Events", "$", "this", "->", "app", "->", "events", "->", "listen", "(", "LoginEvent", "::", "class", ",", "Login", "::", "class", ")", ";", "$", "this", "->", "app", "->", "even...
Register the custom events that may fire for this package.
[ "Register", "the", "custom", "events", "that", "may", "fire", "for", "this", "package", "." ]
train
https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/WebServiceProvider.php#L257-L267
eveseat/web
src/WebServiceProvider.php
WebServiceProvider.configure_horizon
public function configure_horizon() { // Require the queue_manager role to view the dashboard Horizon::auth(function ($request) { if (is_null($request->user())) return false; return $request->user()->has('queue_manager', false); }); // attempt to parse the QUEUE_BALANCING variable into a boolean $balancing_mode = filter_var(env(self::QUEUE_BALANCING_MODE, false), FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE); // in case the variable cannot be parsed into a boolean, assign the environment value itself if (is_null($balancing_mode)) $balancing_mode = env(self::QUEUE_BALANCING_MODE, false); // Configure the workers for SeAT. $horizon_environments = [ 'local' => [ 'seat-workers' => [ 'connection' => 'redis', 'queue' => ['high', 'medium', 'low', 'default'], 'balance' => $balancing_mode, 'processes' => (int) env(self::QUEUE_BALANCING_WORKERS, 4), 'tries' => 1, 'timeout' => 900, // 15 minutes ], ], ]; // Set the environment configuration. config(['horizon.environments' => $horizon_environments]); }
php
public function configure_horizon() { // Require the queue_manager role to view the dashboard Horizon::auth(function ($request) { if (is_null($request->user())) return false; return $request->user()->has('queue_manager', false); }); // attempt to parse the QUEUE_BALANCING variable into a boolean $balancing_mode = filter_var(env(self::QUEUE_BALANCING_MODE, false), FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE); // in case the variable cannot be parsed into a boolean, assign the environment value itself if (is_null($balancing_mode)) $balancing_mode = env(self::QUEUE_BALANCING_MODE, false); // Configure the workers for SeAT. $horizon_environments = [ 'local' => [ 'seat-workers' => [ 'connection' => 'redis', 'queue' => ['high', 'medium', 'low', 'default'], 'balance' => $balancing_mode, 'processes' => (int) env(self::QUEUE_BALANCING_WORKERS, 4), 'tries' => 1, 'timeout' => 900, // 15 minutes ], ], ]; // Set the environment configuration. config(['horizon.environments' => $horizon_environments]); }
[ "public", "function", "configure_horizon", "(", ")", "{", "// Require the queue_manager role to view the dashboard", "Horizon", "::", "auth", "(", "function", "(", "$", "request", ")", "{", "if", "(", "is_null", "(", "$", "request", "->", "user", "(", ")", ")", ...
Configure Horizon. This includes the access rules for the dashboard, as well as the number of workers to use for the job processor.
[ "Configure", "Horizon", "." ]
train
https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/WebServiceProvider.php#L284-L318
eveseat/web
src/WebServiceProvider.php
WebServiceProvider.register
public function register() { // Merge the config with anything in the main app // Web package configurations $this->mergeConfigFrom( __DIR__ . '/Config/web.config.php', 'web.config'); $this->mergeConfigFrom( __DIR__ . '/Config/web.permissions.php', 'web.permissions'); $this->mergeConfigFrom( __DIR__ . '/Config/web.locale.php', 'web.locale'); // Menu Configurations $this->mergeConfigFrom( __DIR__ . '/Config/package.sidebar.php', 'package.sidebar'); $this->mergeConfigFrom( __DIR__ . '/Config/package.character.menu.php', 'package.character.menu'); $this->mergeConfigFrom( __DIR__ . '/Config/package.corporation.menu.php', 'package.corporation.menu'); // Helper configurations $this->mergeConfigFrom(__DIR__ . '/Config/web.jobnames.php', 'web.jobnames'); // Register any extra services. $this->register_services(); }
php
public function register() { // Merge the config with anything in the main app // Web package configurations $this->mergeConfigFrom( __DIR__ . '/Config/web.config.php', 'web.config'); $this->mergeConfigFrom( __DIR__ . '/Config/web.permissions.php', 'web.permissions'); $this->mergeConfigFrom( __DIR__ . '/Config/web.locale.php', 'web.locale'); // Menu Configurations $this->mergeConfigFrom( __DIR__ . '/Config/package.sidebar.php', 'package.sidebar'); $this->mergeConfigFrom( __DIR__ . '/Config/package.character.menu.php', 'package.character.menu'); $this->mergeConfigFrom( __DIR__ . '/Config/package.corporation.menu.php', 'package.corporation.menu'); // Helper configurations $this->mergeConfigFrom(__DIR__ . '/Config/web.jobnames.php', 'web.jobnames'); // Register any extra services. $this->register_services(); }
[ "public", "function", "register", "(", ")", "{", "// Merge the config with anything in the main app", "// Web package configurations", "$", "this", "->", "mergeConfigFrom", "(", "__DIR__", ".", "'/Config/web.config.php'", ",", "'web.config'", ")", ";", "$", "this", "->", ...
Register the application services. @return void
[ "Register", "the", "application", "services", "." ]
train
https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/WebServiceProvider.php#L325-L351
eveseat/web
src/WebServiceProvider.php
WebServiceProvider.register_services
public function register_services() { // Register the Socialite Factory. // From: Laravel\Socialite\SocialiteServiceProvider $this->app->singleton('Laravel\Socialite\Contracts\Factory', function ($app) { return new SocialiteManager($app); }); // Slap in the Eveonline Socialite Provider $eveonline = $this->app->make('Laravel\Socialite\Contracts\Factory'); $eveonline->extend('eveonline', function ($app) use ($eveonline) { $config = $app['config']['services.eveonline']; return $eveonline->buildProvider(EveOnlineProvider::class, $config); } ); // Register the datatables package! Thanks // https://laracasts.com/discuss/channels/laravel/register-service-provider-and-facade-within-service-provider $this->app->register('Yajra\DataTables\DataTablesServiceProvider'); $loader = AliasLoader::getInstance(); $loader->alias('DataTables', 'Yajra\DataTables\Facades\DataTables'); }
php
public function register_services() { // Register the Socialite Factory. // From: Laravel\Socialite\SocialiteServiceProvider $this->app->singleton('Laravel\Socialite\Contracts\Factory', function ($app) { return new SocialiteManager($app); }); // Slap in the Eveonline Socialite Provider $eveonline = $this->app->make('Laravel\Socialite\Contracts\Factory'); $eveonline->extend('eveonline', function ($app) use ($eveonline) { $config = $app['config']['services.eveonline']; return $eveonline->buildProvider(EveOnlineProvider::class, $config); } ); // Register the datatables package! Thanks // https://laracasts.com/discuss/channels/laravel/register-service-provider-and-facade-within-service-provider $this->app->register('Yajra\DataTables\DataTablesServiceProvider'); $loader = AliasLoader::getInstance(); $loader->alias('DataTables', 'Yajra\DataTables\Facades\DataTables'); }
[ "public", "function", "register_services", "(", ")", "{", "// Register the Socialite Factory.", "// From: Laravel\\Socialite\\SocialiteServiceProvider", "$", "this", "->", "app", "->", "singleton", "(", "'Laravel\\Socialite\\Contracts\\Factory'", ",", "function", "(", "$", "a...
Register external services used in this package. Currently this consists of: - PragmaRX\Google2FA - Laravel\Socialite - Yajra\Datatables
[ "Register", "external", "services", "used", "in", "this", "package", "." ]
train
https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/WebServiceProvider.php#L361-L387
eveseat/web
src/WebServiceProvider.php
WebServiceProvider.configure_api
private function configure_api() { // ensure current annotations setting is an array of path or transform into it $current_annotations = config('l5-swagger.paths.annotations'); if (! is_array($current_annotations)) $current_annotations = [$current_annotations]; // merge paths together and update config config([ 'l5-swagger.paths.annotations' => array_unique(array_merge($current_annotations, [ __DIR__ . '/Models', ])), ]); }
php
private function configure_api() { // ensure current annotations setting is an array of path or transform into it $current_annotations = config('l5-swagger.paths.annotations'); if (! is_array($current_annotations)) $current_annotations = [$current_annotations]; // merge paths together and update config config([ 'l5-swagger.paths.annotations' => array_unique(array_merge($current_annotations, [ __DIR__ . '/Models', ])), ]); }
[ "private", "function", "configure_api", "(", ")", "{", "// ensure current annotations setting is an array of path or transform into it", "$", "current_annotations", "=", "config", "(", "'l5-swagger.paths.annotations'", ")", ";", "if", "(", "!", "is_array", "(", "$", "curren...
Update Laravel 5 Swagger annotation path.
[ "Update", "Laravel", "5", "Swagger", "annotation", "path", "." ]
train
https://github.com/eveseat/web/blob/397300911d4dc60a8a2e4cb06c9fd511f1b1558d/src/WebServiceProvider.php#L402-L416