/**
  * Store to the database the given entities as entities decendent from the given
  * document.
  * 
  * @param $document Parent document -- Must be a document entity on the database.
  * @param $entities List of entities to be created as decendents from the given document. 
  * 
  * @return multitype:string A status array containing the result status information.
  */
 public function store($document, $entities)
 {
     $nEnts = count($entities);
     if ($nEnts <= 0 && $nEnts >= 10000) {
         // We will have problems processing empty files or more than 10,000 entities
         return ['error' => 'Unable to process files with more than 10,000 lines: ' . $nEnts . 'found'];
     }
     $activity = new Activity();
     $activity->softwareAgent_id = $this->softwareComponent->_id;
     $activity->save();
     $format = $document['format'];
     $domain = $document['domain'];
     $docType = $document['documentType'] . '-sentence';
     $title = $document['title'];
     $parentId = $document['_id'];
     $project = $document['project'];
     $activityId = $activity->_id;
     if (Auth::check()) {
         $userId = Auth::user()->_id;
     } else {
         $userId = "crowdwatson";
     }
     $idBase = 'entity/' . $format . '/' . $domain . '/' . $docType . '/';
     $inc = $this->getLastDocumentInc($format, $domain, $docType);
     $fullEntities = [];
     foreach ($entities as $entitiy) {
         $fullEntity = ["_id" => $idBase . $inc, "documentType" => 'unit', "activity_id" => $activityId, "softwareAgent_id" => $this->softwareComponent->_id, "project" => $project, "user_id" => $userId, "type" => $docType, "unitParents" => [$parentId], "jobParents" => [], "children" => [], "judgements" => [], "metrics" => [], "source" => '', "format" => $format, "title" => strtolower($title), "domain" => $domain, "tags" => ['unit'], "content" => $entitiy, "hash" => md5(serialize($entitiy)), "updated_at" => new MongoDate(time()), "created_at" => new MongoDate(time())];
         $inc++;
         array_push($fullEntities, $fullEntity);
     }
     \DB::collection('entities')->insert($fullEntities);
     \MongoDB\Temp::truncate();
     return ['success' => 'Sentences created successfully'];
 }
 public function up()
 {
     $appColl = \DB::collection('applications');
     $appColl->where('users', ['$elemMatch' => ['role' => 'admin', 'scope' => ['$nin' => ['update_consumers']]]])->update(['$push' => ['users.$.scope' => 'update_consumers']]);
     $tables = [];
     foreach (\DB::collection('tables')->get() as $table) {
         $tables[(string) $table['_id']] = $table['applications'];
     }
     $bulk = new MongoDB\Driver\BulkWrite();
     $manager = new MongoDB\Driver\Manager(sprintf('mongodb://%s:%s', env('DB_HOST'), env('DB_PORT')));
     $skip = 0;
     $limit = 200;
     while ($decisions = \DB::collection('decisions')->limit($limit)->skip($skip)->get()) {
         if (!$decisions) {
             break;
         }
         foreach ($decisions as $decision) {
             $applications = [];
             if (array_key_exists('table_id', $decision)) {
                 $applications = array_key_exists((string) $decision['table_id'], $tables) ? $tables[(string) $decision['table_id']] : [];
             } elseif (array_key_exists('table', $decision)) {
                 $applications = array_key_exists((string) $decision['table']['_id'], $tables) ? $tables[(string) $decision['table']['_id']] : [];
             }
             $bulk->update(['_id' => $decision['_id']], ['$set' => ['applications' => $applications]]);
         }
         $skip += $limit;
         $manager->executeBulkWrite(env('DB_DATABASE') . '.decisions', $bulk);
     }
 }
 public function down()
 {
     $tables = \DB::collection('tables')->get();
     foreach ($tables as $table) {
         $variant = $table['variants'][0];
         \DB::collection('tables')->where('_id', strval($table['_id']))->update(['$set' => ['rules' => $variant['rules'], 'default_title' => $variant['default_title'], 'default_decision' => $variant['default_decision'], 'default_description' => $variant['default_description']], '$unset' => ['variants' => null, 'variants_probability' => null]]);
     }
     \DB::collection('decisions')->update(['$unset' => ['table.variant' => null]], ['multiple' => true]);
 }
 protected function getEntities()
 {
     $documents = DB::collection('text')->get();
     $entities = array();
     foreach ($documents as $document) {
         $entityID = $document['_id'];
         unset($document['_id']);
         array_push($entities, array($entityID => $document));
     }
     return $entities;
 }
Example #5
0
 public function run()
 {
     $config = app()->make('config');
     $user = DB::collection('users')->first();
     DB::table("oauth_clients")->delete();
     DB::table("oauth_client_endpoints")->delete();
     DB::table("oauth_clients")->insert(['id' => $config->get('secrets.client_id'), 'secret' => $config->get('secrets.client_secret'), 'name' => 'Gemini', 'user_id' => $user['_id']]);
     // DB::table("oauth_client_endpoints")->insert([
     //     'client_id' => $config->get('secrets.client_id'),
     //     'redirect_uri' => $config->get('secrets.redirect_uri')
     // ]);
 }
 /**
  * Get a count of all the days from the first day a statement was submitted to Lrs.
  *
  * @return $days number
  *
  **/
 private function statementDays()
 {
     $firstStatement = \DB::collection('statements')->where('lrs._id', $this->lrs)->orderBy("timestamp")->first();
     if ($firstStatement) {
         $firstDay = date_create(gmdate("Y-m-d", strtotime($firstStatement['statement']['timestamp'])));
         $today = date_create(gmdate("Y-m-d", time()));
         $interval = date_diff($firstDay, $today);
         $days = $interval->days + 1;
         return $days;
     } else {
         return '';
     }
 }
 public function testCache()
 {
     User::create(array('name' => 'John Doe', 'age' => 35, 'title' => 'admin'));
     User::create(array('name' => 'Jane Doe', 'age' => 33, 'title' => 'admin'));
     User::create(array('name' => 'Harry Hoe', 'age' => 13, 'title' => 'user'));
     $users = DB::collection('users')->where('age', '>', 10)->remember(10)->get();
     $this->assertEquals(3, count($users));
     $users = DB::collection('users')->where('age', '>', 10)->getCached();
     $this->assertEquals(3, count($users));
     $users = User::where('age', '>', 10)->remember(10, 'db.users')->get();
     $this->assertEquals(3, count($users));
     $users = Cache::get('db.users');
     $this->assertEquals(3, count($users));
 }
Example #8
0
 public function run()
 {
     DB::collection('users')->delete();
     /**
      * @var Collection $users
      */
     $users = factory(App\User::class, 25)->create();
     foreach ($users as $user) {
         $friends = $users->diff([$user])->random(2);
         foreach ($friends as $friend) {
             $user->friends()->save($friend);
         }
     }
 }
 public function getAllMember()
 {
     $dbs = new MemberDBS();
     $rd = DB::collection($dbs->getTable())->get();
     $result = array();
     for ($i = 0; $i < count($rd); $i++) {
         $mem = $rd[$i];
         if (array_key_exists('Order', $mem)) {
             $mem = array_except($mem, array('Order', 'updated_at'));
         }
         array_push($result, $mem);
     }
     return Response::json($result);
 }
 public function deleteAll()
 {
     $dbs = new MemberDBS();
     if (DB::collection($dbs->getTable())->delete()) {
         $productDbs = new ProductDBS();
         if (DB::collection($productDbs->getTable())->delete()) {
             return Response::json(array('message' => 'success'));
         } else {
             return Response::json(array('message' => 'error'));
         }
     } else {
         return Response::json(array('message' => 'error'));
     }
 }
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     $apps = \DB::collection('applications')->get();
     foreach ($apps as $app) {
         if ($app['users']) {
             $users = [];
             foreach ($app['users'] as $k => $user) {
                 $users[$k] = $user;
                 $users[$k]['user_id'] = new \MongoDB\BSON\ObjectID($user['user_id']);
             }
             \DB::collection('applications')->where('_id', strval($app['_id']))->update(['$set' => ['users' => $users]]);
         }
     }
 }
 public function testQueryLog()
 {
     $this->assertEquals(0, count(DB::getQueryLog()));
     DB::collection('items')->get();
     $this->assertEquals(1, count(DB::getQueryLog()));
     DB::collection('items')->insert(array('name' => 'test'));
     $this->assertEquals(2, count(DB::getQueryLog()));
     DB::collection('items')->count();
     $this->assertEquals(3, count(DB::getQueryLog()));
     DB::collection('items')->where('name', 'test')->update(array('name' => 'test'));
     $this->assertEquals(4, count(DB::getQueryLog()));
     DB::collection('items')->where('name', 'test')->delete();
     $this->assertEquals(5, count(DB::getQueryLog()));
 }
 public function up()
 {
     $apps = \DB::collection('applications')->get();
     foreach ($apps as $app) {
         if ($app['users']) {
             $users = [];
             foreach ($app['users'] as $k => $user) {
                 $users[$k] = $user;
                 if ($user['role'] == 'admin') {
                     $users[$k]['scope'] = ['create', 'read', 'update', 'delete', 'check', 'create_consumers', 'delete_consumers', 'update_users', 'add_user', 'edit_project', 'delete_project', 'delete_consumers', 'delete_users'];
                 }
             }
             \DB::collection('applications')->where('_id', strval($app['_id']))->update(['$set' => ['users' => $users]]);
         }
     }
 }
 public function up()
 {
     $user = \DB::collection('users')->where('username', 'admin')->first();
     if (!$user) {
         \DB::collection('users')->insert(['username' => 'admin', 'password' => '$2y$10$ur/AJm3FpWyCAAIEEcXQbebvMf0cUuT1dOKHC/.UNc9Z4MLe8mXJO', 'email' => '*****@*****.**']);
     }
     $user = \DB::collection('users')->where('username', 'admin')->first();
     $applicationsCollection = \DB::collection('applications');
     $application = $applicationsCollection->where('title', 'migrated')->first();
     if (!$application) {
         $applicationsCollection->insert(['title' => 'migrated', 'description' => '', 'users' => [['user_id' => (string) $user['_id'], 'role' => 'admin', 'scope' => ['create', 'read', 'update', 'delete', 'check', 'create_consumers', 'delete_consumers', 'update_users', 'add_user', 'edit_project', 'delete_project', 'delete_consumers', 'delete_users']]], 'consumers' => []]);
     }
     $application = $applicationsCollection->where('title', 'migrated')->first();
     $application_id = (string) $application['_id'];
     \DB::collection('tables')->where('applications', ['$exists' => false])->update(['$set' => ['applications' => [$application_id]]], ['multiple' => true]);
     \DB::collection('groups')->where('applications', ['$exists' => false])->update(['$set' => ['applications' => [$application_id]]], ['multiple' => true]);
 }
 public function testDeprecatedRemind()
 {
     $mailer = Mockery::mock('Illuminate\\Mail\\Mailer');
     $this->app->instance('mailer', $mailer);
     $user = User::create(array('name' => 'John Doe', 'email' => '*****@*****.**', 'password' => Hash::make('foobar')));
     $mailer->shouldReceive('send')->once();
     Password::remind(array('email' => '*****@*****.**'));
     DB::collection('password_reminders')->update(array('created_at' => new DateTime()));
     $reminder = DB::collection('password_reminders')->first();
     $this->assertTrue(is_array($reminder['created_at']));
     $credentials = array('email' => '*****@*****.**', 'password' => 'foobar', 'password_confirmation' => 'foobar', 'token' => $reminder['token']);
     $response = Password::reset($credentials, function ($user, $password) {
         $user->password = Hash::make($password);
         $user->save();
     });
     $this->assertEquals('reminders.reset', $response);
     $this->assertEquals(0, DB::collection('password_reminders')->count());
 }
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     $associated = ['create' => 'tables_create', 'read' => 'tables_view', 'update' => 'tables_update', 'delete' => 'tables_delete', 'check' => 'decisions_make', 'get_consumers' => 'consumers_get', 'create_consumers' => 'consumers_manage', 'update_consumers' => 'consumers_manage', 'update_users' => 'users_manage', 'add_user' => 'users_manage', 'edit_project' => 'project_update', 'delete_project' => 'project_delete', 'delete_consumers' => 'consumers_manage', 'delete_users' => 'users_manage'];
     $consumers_associated = ['read' => 'decisions_view', 'check' => 'decisions_make'];
     $apps = \DB::collection('applications')->get();
     foreach ($apps as $app) {
         $set = [];
         if ($app['users']) {
             $users = [];
             foreach ($app['users'] as $k => $user) {
                 $users[$k] = $user;
                 $users[$k]['scope'] = ['decisions_view'];
                 foreach ($user['scope'] as $scope) {
                     if (in_array($scope, array_keys($associated))) {
                         $users[$k]['scope'][] = $associated[$scope];
                     } else {
                         $users[$k]['scope'][] = $scope;
                     }
                 }
                 $users[$k]['scope'] = array_values(array_unique($users[$k]['scope']));
             }
             $set['users'] = $users;
         }
         if (array_key_exists('consumers', $app) && $app['consumers']) {
             $consumers = [];
             foreach ($app['consumers'] as $k => $consumer) {
                 $consumers[$k] = $consumer;
                 $consumers[$k]['scope'] = [];
                 foreach ($consumer['scope'] as $scope) {
                     if (in_array($scope, array_keys($consumers_associated))) {
                         $consumers[$k]['scope'][] = $consumers_associated[$scope];
                     } else {
                         $consumers[$k]['scope'][] = $scope;
                     }
                 }
             }
             $set['consumers'] = $consumers;
         }
         if (!empty($set)) {
             \DB::collection('applications')->where('_id', strval($app['_id']))->update(['$set' => $set]);
         }
     }
 }
 public function run()
 {
     HistoryAction::truncate();
     HistoryDayCounter::truncate();
     HistoryMegaCounter::truncate();
     HistoryYearCounter::truncate();
     RecordAction::truncate();
     ListModel::truncate();
     ListUser::truncate();
     ActionCampaign::truncate();
     EmailLayout::truncate();
     Email::truncate();
     EmailDraft::truncate();
     EmailLog::truncate();
     DB::collection('settings')->insert(array("_id" => "main", "website_name" => "Brisk Surf", "paypal_email" => "*****@*****.**", "sandbox_email" => "*****@*****.**", "sandbox" => false));
     DB::collection('settings')->insert(array("_id" => "memberships", "free" => array("commission" => 10, "credits_per_view" => 0.5, "referral_percent" => 1, "timer" => 8, "monthly_credits" => 0, "targeting" => false, "maximum_websites" => 5, "popular" => false), "premium" => array("commission" => 30, "credits_per_view" => 1, "referral_percent" => 3, "timer" => 6, "monthly_credits" => 500, "targeting" => true, "maximum_websites" => 10, "popular" => true), "platinum" => array("commission" => 50, "credits_per_view" => 1, "referral_percent" => 5, "timer" => 6, "monthly_credits" => 1000, "targeting" => true, "maximum_websites" => 50, "popular" => false)));
     DB::collection('settings')->insert(array("_id" => "faq", "list" => array("What_is_SurfDuel?" => "SurfDuel is a web service designed to provide your website with traffic. Better websites are shown more often, and therefore receive more traffic. Our system, however, still allows everyone to get a good amount of views to their site. We've created a win-win scenario for everyone.", "What_are_some_guidelines_for_submitting_my_website?" => "#LIST# \r\n#BULLET#Autoplaying videos with audio are discouraged.#ENDBULLET# \r\n#BULLET#Please try to keep your content family friendly, or filter it to be displayed to the appropriate age group.#ENDBULLET# \r\n#BULLET#For our rules, please check our Terms of Service #LINK=HELP/TOS#here.#ENDLINK# #ENDBULLET# \r\n#ENDLIST#", "What_is_the_voting_system?" => "Here is how it works: #LIST# #BULLET#If someone submits a site, then that site is shown randomly, side-by-side with another site.#ENDBULLET# #BULLET#The site that the user picks to be better gets a vote.#ENDBULLET# #BULLET#Over the course of the day, the highest voted sites are shown more and more often.#ENDBULLET# #BULLET#At midnight, the vote counter resets, and all sites are once again shown equally.#ENDBULLET# #BULLET#The top voted sites of the previous day are shown full screen to all surfers and are hailed as winners.#ENDBULLET# #ENDLIST# This way, it does not matter how many referrals you have or how much money you spent. Your site is advertised based solely on how good it is. All you have to do is keep it active.", "What_does_it_mean_to_keep_my_site_active?" => "Keeping a website active means to have it be shown while users surf. It's very important to keep your sites active, otherwise they will not be shown at all. Think of it this way: an active website means that it will be advertised, while an inactive one is useless because it's never shown. As a free or premium member, to keep your website active, you have to view a certain number of websites per day. If you don't, your website will not be active the next day. As a platinum member, you don't have to do anything to keep your site active!", "Can_I_see_my_own_website_while_surfing?" => "Yes! In SurfDuel, you do not have to deal with credit nonsense, so your site is shown more the better it is. There is no harm in you seeing your own site.", "What_are_the_benefits_of_becoming_a_premium_member?" => "Well, among other things, it's much easier to keep your site active. In fact, as a platinum member, you don't have to do anything! There are also other benefits such as increased commission rates. To view this information in more detail, please visit this page #LINK=MEMBERSHIPS#here#ENDLINK#.")));
     DB::collection('settings')->insert(array("_id" => "tos", "list" => array("Disclaimer" => "SurfDuel displays content from many other websites, so please exercise caution when entering information in them. We cannot be held accountable for any content on these websites, or misuse of any information you have provided them.", "Spam" => "We do not condone spam of any form. If you have been found spamming, harassing, or mistreating other users (or anyone else) through your submitted website or by any other means, we reserve the right to cancel your account, and prevent the creation of another.", "Website_Content" => "Harassing other members or anyone else is strictly forbidden. If you have been found harassing other members in any way, including but not limited to offensive usernames and offensive or threatening websites, your account will be terminated.", "Website_Rules" => "#LIST#\r\n#BULLET#Your site must not contain popups.#ENDBULLET#\r\n#BULLET#Your site may not close the surf frame#ENDBULLET#\r\n#BULLET#Your site may not contain prompts or alerts or anything else that must be closed before surfing can continue#ENDBULLET#\r\n#BULLET#Your site must not attempt to automatically download files#ENDBULLET#\r\n#BULLET#Your site may not contain illegal content#ENDBULLET#\r\n#BULLET#Your site may not load banned or illegal websites in iframes#ENDBULLET#\r\n#BULLET#Sites can be removed for reasons not listed above#ENDBULLET#\r\n#ENDLIST#", "Account_Rules" => "#LIST#\r\n#BULLET#You may only have ONE account per person#ENDBULLET#\r\n#BULLET#You cannot login from two different computers at the same time#ENDBULLET#\r\n#BULLET#You may not use any programs, scripts, etc that will surf for you#ENDBULLET#\r\n#ENDLIST#", "Changing_Referrals" => "Deleting your account only to re-join again in an effort to change your referrer is not allowed. Asking members to delete their account and re-join under you is strictly forbidden.", "Upgraded_Accounts" => "You are responsible for cancelling your Paypal subscription should you be upgraded and no longer wish to be.", "Surfing_Rules" => "#LIST#\r\n#BULLET#Only you may surf for your account#ENDBULLET#\r\n#BULLET#You must surf with the site being displayed visible#ENDBULLET#\r\n#BULLET#You may not use any kind of software to surf for you#ENDBULLET#\r\n#ENDLIST#", "Newsletter" => "We have the right to send you occasional emails at the email you provided, unless you opt-out. The link to do so will be provided at the bottom of every newsletter we send.", "Failure_to_Follow" => "Failure to follow these terms will result in cancellation of your account. Your credits, subscription, etc. will be lost.", "Future_Changes" => "SurfDuel may change any of these rules at any time, with or without notification.")));
 }
 function __construct()
 {
     // Try to find Cockpit Collections
     $result = \DB::collection('common_collections')->get();
     if (!$result) {
         throw new \Exception("Unable to find Cockpit 'common_collections' collection. Is Cockpit installed correctly?");
     }
     // Try to find this collection via it's slug
     $found = array_filter($result, function ($collection) {
         if ($collection['slug'] == $this->cockpitSlug) {
             $this->collection = "collections_collection{$collection['_id']}";
             $this->cockpitCollection = $collection;
             return $collection;
         }
     });
     if (!$found) {
         throw new \Exception("Unable to find Cockpit collection with slug '{$this->cockpitSlug}'");
     }
     // Off we go...
     parent::__construct();
 }
Example #19
0
 public function post_advance_scraping()
 {
     $client = new Client();
     $getdata = array('crawled_url' => Input::get('crawled_url'), 'title' => Input::get('title'), 'article' => Input::get('article'));
     $geturl = DB::collection('crawling')->where('refurl', $getdata['crawled_url'])->get();
     foreach ($geturl as $key) {
         $client = new Client();
         $url = $key->url;
         $crawler = $client->request('GET', $url);
         $status_code = $client->getResponse()->getStatus();
         if ($status_code == 200) {
             $crawler->filter($key->title)->each(function ($node) {
                 print $node->text() . "<br>";
             });
             $crawler->filter($key->article)->each(function ($node) {
                 print $node->text() . "<br>";
             });
         } else {
             echo "we F*****G LOST DUDE !";
         }
         echo "<hr>";
     }
 }
 public function up()
 {
     \DB::collection('applications')->where('users', ['$elemMatch' => ['role' => 'admin', 'scope' => ['$nin' => ['get_consumers']]]])->update(['$push' => ['users.$.scope' => 'get_consumers']], ['multiple' => true]);
 }
Example #21
0
 public function get_lihat()
 {
     $getdata = DB::collection('datadom_temp')->orderBy('no', 'asc')->simplePaginate(50);
     return View::make('test.testlihat', compact('getdata'));
 }
 public function testProjections()
 {
     DB::collection('items')->insert(array(array('name' => 'fork', 'tags' => array('sharp', 'pointy')), array('name' => 'spork', 'tags' => array('sharp', 'pointy', 'round', 'bowl')), array('name' => 'spoon', 'tags' => array('round', 'bowl'))));
     $results = DB::collection('items')->project(array('tags' => array('$slice' => 1)))->get();
     foreach ($results as $result) {
         $this->assertEquals(1, count($result['tags']));
     }
 }
Example #23
0
 public function store(&$parentEntity, $relexStructuredSentences, $inc)
 {
     // dd('test');
     $allEntities = array();
     foreach ($relexStructuredSentences as $tKey => &$relexStructuredSentence) {
         $title = $parentEntity['title'] . "_index_" . $inc;
         $hash = md5(serialize(array_except($relexStructuredSentence, ['properties'])));
         if ($dup = Entity::where('hash', $hash)->first()) {
             array_push($this->status['store']['error']['skipped_duplicates'], $tKey . " ---> " . $dup->_id);
             continue;
         }
         if (Auth::check()) {
             $user_id = Auth::user()->_id;
         } else {
             $user_id = "crowdwatson";
         }
         $entity = ["_id" => 'entity/text/medical/relex-structured-sentence/' . $inc, "title" => strtolower($title), "domain" => $parentEntity['domain'], "format" => $parentEntity['format'], "tags" => ['unit'], "documentType" => "relex-structured-sentence", "parents" => [$parentEntity['_id']], "content" => $relexStructuredSentence, "hash" => $hash, "activity_id" => $this->activity->_id, "user_id" => $user_id, "updated_at" => new MongoDate(time()), "created_at" => new MongoDate(time())];
         array_push($allEntities, $entity);
         $inc++;
         array_push($this->status['store']['success'], $tKey . " ---> URI: {$entity['_id']}");
     }
     if (count($allEntities) > 1) {
         \DB::collection('entities')->insert($allEntities);
         Temp::truncate();
     }
     return $inc;
 }
 public function testIncrement()
 {
     DB::collection('users')->insert(array(array('name' => 'John Doe', 'age' => 30, 'note' => 'adult'), array('name' => 'Jane Doe', 'age' => 10, 'note' => 'minor'), array('name' => 'Robert Roe', 'age' => null), array('name' => 'Mark Moe')));
     $user = DB::collection('users')->where('name', 'John Doe')->first();
     $this->assertEquals(30, $user['age']);
     DB::collection('users')->where('name', 'John Doe')->increment('age');
     $user = DB::collection('users')->where('name', 'John Doe')->first();
     $this->assertEquals(31, $user['age']);
     DB::collection('users')->where('name', 'John Doe')->decrement('age');
     $user = DB::collection('users')->where('name', 'John Doe')->first();
     $this->assertEquals(30, $user['age']);
     DB::collection('users')->where('name', 'John Doe')->increment('age', 5);
     $user = DB::collection('users')->where('name', 'John Doe')->first();
     $this->assertEquals(35, $user['age']);
     DB::collection('users')->where('name', 'John Doe')->decrement('age', 5);
     $user = DB::collection('users')->where('name', 'John Doe')->first();
     $this->assertEquals(30, $user['age']);
     DB::collection('users')->where('name', 'Jane Doe')->increment('age', 10, array('note' => 'adult'));
     $user = DB::collection('users')->where('name', 'Jane Doe')->first();
     $this->assertEquals(20, $user['age']);
     $this->assertEquals('adult', $user['note']);
     DB::collection('users')->where('name', 'John Doe')->decrement('age', 20, array('note' => 'minor'));
     $user = DB::collection('users')->where('name', 'John Doe')->first();
     $this->assertEquals(10, $user['age']);
     $this->assertEquals('minor', $user['note']);
     DB::collection('users')->increment('age');
     $user = DB::collection('users')->where('name', 'John Doe')->first();
     $this->assertEquals(11, $user['age']);
     $user = DB::collection('users')->where('name', 'Jane Doe')->first();
     $this->assertEquals(21, $user['age']);
     $user = DB::collection('users')->where('name', 'Robert Roe')->first();
     $this->assertEquals(null, $user['age']);
     $user = DB::collection('users')->where('name', 'Mark Moe')->first();
     $this->assertEquals(1, $user['age']);
 }
 public function down()
 {
     \DB::collection('tables')->where('fields.type', 'boolean')->update(['$set' => ['fields.type' => 'bool']], ['multiple' => true]);
     \DB::collection('tables')->where('fields.type', 'numeric')->update(['$set' => ['fields.type' => 'number']], ['multiple' => true]);
 }
 public function fire()
 {
     DB::collection('users')->update(array("views_today" => 0, "credits_today" => 0));
     Queue::push('BriskSurf\\Lists\\ListManager@processAttribute', array("views_today", "credits_today"));
 }
Example #27
0
 public static function calSmallArea(&$arrData)
 {
     $hook = DB::collection('tb_hook')->where('deleted', false)->where('name', 'Small area')->pluck('options');
     if (!empty($hook)) {
         usort($hook, function ($a, $b) {
             return $a['area_limit'] > $b['area_limit'];
         });
     } else {
         $hook = [];
     }
     foreach ($hook as $smallArea) {
         if ($arrData['area'] <= (double) $smallArea['area_limit']) {
             $arrData['sell_price'] = $arrData['unit_price'] += (double) $arrData['unit_price'] * $smallArea['up_price'] / 100;
             return true;
         }
     }
 }
 public function getAllProduct()
 {
     $productDbs = new ProductDBS();
     $rd = DB::collection($productDbs->getTable())->get();
     return Response::json($rd);
 }
Example #29
0
 public function tearDown()
 {
     User::truncate();
     DB::collection('password_reminders')->truncate();
 }
Example #30
0
 public function getAll()
 {
     $dbs = new DBconnect();
     $rd = DB::collection($dbs->getTable())->get();
     return Response::json($rd);
 }