本文整理汇总了PHP中Illuminate\Database\DatabaseManager::table方法的典型用法代码示例。如果您正苦于以下问题:PHP DatabaseManager::table方法的具体用法?PHP DatabaseManager::table怎么用?PHP DatabaseManager::table使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Database\DatabaseManager
的用法示例。
在下文中一共展示了DatabaseManager::table方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handle
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$series = $this->argument('series');
$data = json_decode($this->filesystem->get(base_path('resources/assets/json/' . $series . '_full.json')));
$series = $this->series->create((array) $data);
$this->db->table('cards')->whereNull('series_id')->update(['series_id' => $series->id]);
}
示例2: delete
public function delete()
{
$data = $this->request->get('data');
$id_string = $data['id_string'];
$this->db->table("widgets")->where("id_string", $id_string)->delete();
$this->db->table("sidebar_widget")->where("id_string", $id_string)->delete();
}
示例3: get
/**
* Return information about a scope
*
* @param string $scope
* @param string $grantType
* @param string $clientId
* @return ScopeEntity
*/
public function get($scope, $grantType = null, $clientId = null)
{
$result = $this->db->table('oauth_scopes')->where('id', $scope)->get();
if (count($result) === 0) {
return;
}
return (new ScopeEntity($this->server))->hydrate(['id' => $result->id, 'description' => $result->description]);
}
示例4: add
/**
* Add participants to a conversation
*
* @param $partecipants
* @param bool $multiPartecipants
* @return \Illuminate\Database\Eloquent\Model|static
*/
public function add($partecipants, $multiPartecipants = false)
{
if (!$multiPartecipants) {
$insert = $this->convJoined->create($partecipants);
} else {
$insert = $this->db->table('conversation_joined')->insert($partecipants);
}
return $insert;
}
示例5: validate
/**
* {@inheritdoc}
*/
public function validate()
{
$check = $this->database->table('captcha')->where('imagehash', '=', $this->request->get('imagehash'))->where('imagestring', '=', $this->request->get('imagestring'));
if ($check->count() != 1) {
$this->database->table('captcha')->where('imagehash', '=', $this->request->get('imagehash'))->delete();
return false;
}
return true;
}
示例6: delete
/**
* Deletes an option from the database.
*
* @param string $key option name
*
* @return bool TRUE on success, FALSE on failure
*
* @throws NonExistentOptionException
*/
public function delete($key)
{
$result = $this->db->table($this->optionsTable)->where(['option_key' => $key])->delete();
if (0 === $result && !$this->has($key)) {
throw new NonExistentOptionException('The option key: "' . $key . '" doesn\'t exists');
}
return FALSE !== $result;
}
示例7: isUserInConversation
public function isUserInConversation($conv_id, $user_id)
{
$res = $this->db->table($this->tablePrefix . 'conv_users')->select('conv_id', 'user_id')->where('user_id', $user_id)->where('conv_id', $conv_id)->first();
if (is_null($res)) {
return false;
}
return true;
}
示例8: foreach
/**
* @param DatabaseManager $databaseManager
*/
function __construct(DatabaseManager $databaseManager)
{
$db_versions = $databaseManager->table('versions')->get();
$versions = [];
foreach ($db_versions as $ver) {
$versions[$ver->version] = $ver->version;
}
$this->versions = $versions;
}
示例9: captcha
/**
* @param string $imagehash
*/
public function captcha($imagehash)
{
$baseQuery = $this->database->table('captcha')->where('imagehash', '=', $imagehash)->where('used', '=', false);
// Something is wrong here...
if ($baseQuery->count() != 1) {
exit;
}
$imagestring = $baseQuery->pluck('imagestring');
// Mark as used
$baseQuery->update(['used' => true]);
// $imagestring = 'Debug';
if ($this->getGdVersion() >= 2) {
$im = imagecreatetruecolor($this->img_width, $this->img_height);
} else {
$im = imagecreate($this->img_width, $this->img_height);
}
// Couldn't create the image :(
if ($im === false) {
throw new \RuntimeException("Couldn't create an image using GD");
}
// Fill the background with white
$bg_color = imagecolorallocate($im, 255, 255, 255);
imagefill($im, 0, 0, $bg_color);
// Now draw random circles, squares or lines
$to_draw = mt_rand(0, 2);
if ($to_draw == 1) {
$this->drawCircles($im);
} elseif ($to_draw == 2) {
$this->drawSquares($im);
} else {
$this->drawLines($im);
}
// Dots are always added
$this->drawDots($im);
// Now write the image string to the image
$this->drawString($im, $imagestring);
// Draw a nice border around the image
$border_color = imagecolorallocate($im, 0, 0, 0);
imagerectangle($im, 0, 0, $this->img_width - 1, $this->img_height - 1, $border_color);
// And now output the image
header('Content-type: image/png');
imagepng($im);
imagedestroy($im);
}
示例10: queryUsersByIdentifier
/**
* @param string $identifier
*
* @return \Illuminate\Database\Query\Builder
*/
public function queryUsersByIdentifier($identifier)
{
$first = $this->getEntities()->first();
$query = $this->database->table($first->table)->selectRaw($this->database->raw("'{$first->type}' AS type, id, `{$first->identifier}` AS identifier"))->where($first->identifier, '=', $identifier);
foreach ($this->getEntities()->slice(1) as $entity) {
$subQuery = $this->database->table($entity->table)->selectRaw($this->database->raw("'{$entity->type}' AS type, id, `{$entity->identifier}` AS identifier"))->where($entity->identifier, '=', $identifier);
$query = $query->union($subQuery);
}
return $query;
}
示例11: getShowPost
public function getShowPost($permalink = "")
{
if (!$permalink) {
exit('Not found.');
}
$post = $this->db->table('cms.cms_posts', ['permalink', $permalink])->first();
if (!$post) {
exit('404 not found');
}
return $this->theme->baseDashboard("Front::view.single", ['post' => $post]);
}
示例12: setCache
/**
* Set cache
*
* @return array
*/
protected function setCache()
{
// Check if cache has expired
if ($this->cache->expired() === false) {
return;
}
// Instantiate values
$values = array();
// Get values from database
foreach ($this->database->table($this->config['table'])->get() as $setting) {
$values[$setting->key] = json_decode($setting->value, true);
}
// Cache values
$this->cache->set($values);
}
示例13: postLogin
/**
* Handle a login request to the application.
*
* @param Request|\Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function postLogin(Request $request)
{
$this->validate($request, ['login' => 'required', 'password' => 'required']);
$login = $request->input('login');
$field = filter_var($login, FILTER_VALIDATE_EMAIL) ? 'email' : 'username';
$request->merge([$field => $login]);
$credentials = $request->only($field, 'password');
try {
if ($this->requiresPasswordReset($credentials)) {
$this->resetPassword($credentials['password']);
}
if (Auth::attempt($credentials, $request->has('remember'))) {
if (!Auth::user()->enabled) {
Auth::logout();
return redirect('/auth/login')->withErrors("Your account has been disabled. Please contact us at <a href='mailto:support@aidstream.org'>support@aidstream.org</a> ");
}
$user = Auth::user();
Session::put('role_id', $user->role_id);
Session::put('org_id', $user->org_id);
Session::put('admin_id', $user->id);
$settings = Settings::where('organization_id', $user->org_id)->first();
$settings_check = isset($settings);
$version = $settings_check ? $settings->version : config('app.default_version');
Session::put('current_version', $version);
$versions_db = $this->database->table('versions')->get();
$versions = [];
foreach ($versions_db as $ver) {
$versions[] = $ver->version;
}
$versionKey = array_search($version, $versions);
$next_version = end($versions) == $version ? null : $versions[$versionKey + 1];
Session::put('next_version', $next_version);
$version = 'V' . str_replace('.', '', $version);
Session::put('version', $version);
$redirectPath = $user->role_id == 1 || $user->role_id == 2 ? config('app.admin_dashboard') : config('app.super_admin_dashboard');
$intendedUrl = Session::get('url.intended');
!(($user->role_id == 3 || $user->role_id == 4) && strpos($intendedUrl, '/admin') === false) ?: ($intendedUrl = url('/'));
!($intendedUrl == url('/')) ?: Session::set('url.intended', $redirectPath);
return redirect()->intended($redirectPath);
}
return redirect($this->loginPath())->withInput($request->only($field, 'remember'))->withErrors([$field => $this->getFailedLoginMessage()]);
} catch (\Exception $exception) {
return redirect()->back()->withErrors($exception->getMessage());
}
}
示例14: getPermissionForRole
/**
* Check whether a specific Role has the specified permission
*
* @param Role $role The role to check
* @param string $permission The permission to check
* @param string|null $content If the permission is related to some content (eg forum) this string specifies the
* type of text
* @param int|null $contentID If $content is set this specifies the ID of the content to check
*
* @return PermissionChecker::NEVER|NO|YES
*/
public function getPermissionForRole(Role $role, $permission, $content = null, $contentID = null)
{
// Permissions associated with user/groups are saved without content
// (all permissions are associated with groups anyways)
if ($content == 'user' || $content == 'usergroup') {
$content = null;
$contentID = null;
}
if ($this->hasCache($role, $permission, $content, $contentID)) {
return $this->getCache($role, $permission, $content, $contentID);
}
// Get the value if we have one otherwise the devault value
$permissionValues = $this->db->table('permissions')->where('permission_name', '=', $permission)->where('content_name', '=', $content)->leftJoin('permission_role', function ($join) use($role, $content, $contentID) {
$join->on('permission_id', '=', 'id')->where('role_id', '=', $role->id);
if ($content != null && $contentID != null) {
$join->where('content_id', '=', $contentID);
}
})->first(['value', 'default_value']);
// If the permission doesn't exist return "Never" to break all loops but don't cache it as it may be added later
if ($permissionValues == null) {
return static::NEVER;
}
// We have a content value so we can save that as permission
if ($permissionValues->value !== null) {
$this->putCache($role, $permission, $content, $contentID, $permissionValues->value);
return $permissionValues->value;
}
// We have a content permission without a specific value
// Now we need to check whether this role has a content permission (#122)
// Unfortunately Laravel doesn't have a subwhere for joins so we can't add it to the query above
if ($content != null && $contentID != null) {
$contentValues = $this->db->table('permissions')->where('permission_name', '=', $permission)->where('content_name', '=', $content)->leftJoin('permission_role', function ($join) use($role, $content, $contentID) {
$join->on('permission_id', '=', 'id')->where('role_id', '=', $role->id)->where('content_id', '=', 0);
})->first(['value']);
if ($contentValues != null && $contentValues->value !== null) {
$this->putCache($role, $permission, $content, $contentID, $contentValues->value);
return $contentValues->value;
}
}
$this->putCache($role, $permission, $content, $contentID, $permissionValues->default_value);
return $permissionValues->default_value;
}
示例15: index
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index(DatabaseManager $db, Request $request)
{
$users = User::select('u_id', 'u_name', 'e-mail', 'location', 'skype', 'int_phone', 'desks.id as desk', 'departmants.job', 'departmants.dep', 'departmants.users as dep_users', 'rights.users as rights')->leftJoin('desks', 'users_id', '=', 'u_id')->leftJoin('rights', 'user_id', '=', 'u_id')->join('departmants', 'departmants.id', '=', 'departmant_id')->where('departmant_id', '!=', 21)->get()->keyBy('u_id')->toArray();
$host = getenv('COMPUTERNAME');
if (!in_array($host, ['SOFWKS0188', 'SOFWKS0159', 'SOFWKS0140'])) {
$host = explode('.', gethostbyaddr($request->server->get('REMOTE_ADDR')));
$host = $host[0];
}
$res = $db->table('computers')->select('user_id')->where('name', '=', $host)->first();
if ($res) {
$users[$res->user_id]['current'] = true;
$users[$res->user_id]['edit'] = $this->checkUser($users[$res->user_id]);
}
// Apply data restrictions
if (empty($res) || !$users[$res->user_id]['edit']) {
$users = $this->filterRestrictedData($users);
}
$users = array_merge($users, $this->getSpecialUsers());
return response()->json($users);
}