public function listDieta(Request $req, $dietaList)
 {
     $dietaList = NULL;
     if (is_numeric($dietaList_id)) {
         $dietaList = Collection::find($dietaList_id);
         $dietaList->update($req->all());
     }
     return view('co.edu.javeriana.dieta_list', ['dietas' => $dietaList]);
 }
Example #2
0
 public function testFindsIndexOfAnElement()
 {
     $list = new Collection(\Cassandra::TYPE_VARINT);
     $list->add(new Varint('1'), new Varint('2'), new Varint('3'), new Varint('4'), new Varint('5'), new Varint('6'), new Varint('7'), new Varint('8'));
     $this->assertEquals(0, $list->find(new Varint('1')));
     $this->assertEquals(1, $list->find(new Varint('2')));
     $this->assertEquals(2, $list->find(new Varint('3')));
     $this->assertEquals(3, $list->find(new Varint('4')));
     $this->assertEquals(4, $list->find(new Varint('5')));
     $this->assertEquals(5, $list->find(new Varint('6')));
     $this->assertEquals(6, $list->find(new Varint('7')));
     $this->assertEquals(7, $list->find(new Varint('8')));
 }
Example #3
0
 public function testWhereText()
 {
     $dbVersion = $this->collection->getDatabase()->getClient()->getDbVersion();
     if (version_compare($dbVersion, '2.6', '<=')) {
         return;
     }
     $this->collection->ensureFulltextIndex(array('subject', 'body'), array('subject' => 2, 'body' => 1));
     $this->collection->batchInsert(array(array('subject' => 'big brown dog', 'body' => 'walking on street'), array('subject' => 'little pony', 'body' => 'flying among rainbows')));
     $documents = $this->collection->find()->whereText('pony')->findAll();
     $this->assertEquals(1, count($documents));
     $document = current($documents);
     $this->assertEquals('little pony', $document->subject);
 }
 function test_find()
 {
     //Arrange
     $name = "Hello Kitty";
     $name2 = "Pokemon";
     $test_collection = new Collection($name);
     $test_collection->save();
     $test_collection2 = new Collection($name2);
     $test_collection2->save();
     //Act
     $result = Collection::find($test_collection2->getId());
     //Assert
     $this->assertEquals($test_collection2, $result);
 }
 function test_find()
 {
     //Arrange
     $thing = "Run the World";
     $thing2 = "20 20 Experience";
     $test_collection = new Collection($thing);
     $test_collection->save();
     $test_collection2 = new Collection($thing2);
     $test_collection2->save();
     //Act
     $id = $test_collection->getId();
     $result = Collection::find($id);
     //Assert
     $this->assertEquals($test_collection, $result);
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $collection = Collection::find($id);
     if (Auth::User()->id != $collection->user_id) {
         Flash::warning('You are not authorized to do that');
         return redirect()->route('home');
     }
     $collection->delete();
     Flash::info('Collection deleted!');
     return redirect()->route('collections.index');
 }
});
$app->post('/collections', function () use($app) {
    $collection = new Collection($_POST['name']);
    $collection->save();
    return $app['twig']->render('index.html.twig', array('collections' => Collection::getAll(), 'items' => Item::getAll()));
});
$app->get('/collection/{id}', function ($id) use($app) {
    $collection = Collection::find($id);
    return $app['twig']->render('collection.html.twig', array('collection' => $collection, 'items' => $collection->getItems()));
});
$app->post('/delete_collections', function () use($app) {
    Collection::deleteAll();
    return $app['twig']->render('index.html.twig', array('collections' => Collection::getAll(), 'items' => Item::getAll()));
});
$app->post('/collection/{id}/delete', function ($id) use($app) {
    $collection = Collection::find($id);
    $collection->delete();
    return $app['twig']->render('index.html.twig', array('collections' => Collection::getAll()));
});
$app->post('/items', function () use($app) {
    $item = new Item($_POST['name'], $_POST['collection_id']);
    $item->save();
    $collection = Collection::find($_POST['collection_id']);
    return $app['twig']->render('collection.html.twig', array('collection' => $collection, 'items' => $collection->getItems()));
});
$app->post('/collection/{id}/delete_items', function ($id) use($app) {
    $collection = Collection::find($id);
    $collection->deleteAssociatedItems();
    return $app['twig']->render('collection.html.twig', array('collection' => $collection, 'items' => []));
});
return $app;
Example #8
0
 /**
  * Get results from the database as a cursor.
  *
  * @param string $collection_name name of the collection 
  * @param array $query a MongoDB query
  * @return MongoCursor
  */
 public function getAll($collection_name, $query = [])
 {
     if (!is_array($query)) {
         throw new \Exception("\$query must be an associative array of 'field => value' pairs");
     }
     $collection = new Collection($collection_name, true, $this);
     return $collection->find($query);
 }
Example #9
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $collection = Collection::find($id);
     $collection->delete();
     return Redirect::route('collection.index');
 }
Example #10
0
*/
Route::get('/', function () {
    $t = 1;
    $inventories = Inventory::all();
    return View::make('main/index')->with('inventories', $inventories)->with('t', $t);
});
Route::get('/albums', function () {
    $albums = Collection::all();
    return View::make('main/albums')->with('albums', $albums);
});
Route::get('/album/{albums}', function ($albums) {
    $albums = Collection::find($albums);
    return View::make('main/album')->with(array('albums' => $albums));
});
Route::get('/albums/{album}/image/{image}', function ($album, $image) {
    $album = Collection::find($album);
    $image = Inventory::find($image);
    return View::make('main/image')->with(array('album' => $album, 'image' => $image));
});
Route::get('/login', function () {
    return View::make('main/login');
});
//// ADMIN ROUTES BELOW
Route::resource('inventory', 'InventoryController');
Route::get('/users/{id}/pictures', function ($id) {
    $user = User::find($id);
    return View::make('inventories/mypics')->with('images', $user->pictures);
});
Route::resource('collection', 'CollectionController');
Route::controller('users', 'UsersController');
Route::post('comment/{id}', 'CommentController@store');
Example #11
0
 public function testShouldReturnRecordAccordingToCriteria()
 {
     $record1 = new Record(array('name' => 'A'));
     $record2 = new Record(array('name' => 'B'));
     $collection = new Collection(new Factory());
     $collection->insert($record1);
     $collection->insert($record2);
     $criteria = array('name' => 'B');
     $result = $collection->find($criteria);
     $this->assertSame($record2, $result);
 }
 public function collection_index()
 {
     $page = isset($_GET['page']) ? $_GET['page'] : 1;
     $per_page = 15;
     $collections_total = Collection::findAll();
     $collections = Collection::find(array('limit' => $per_page, 'offset' => ($page - 1) * $per_page));
     $pagination = new Pagination(array('base_url' => '/' . ADMIN_DIR . '/plugin/ecommerce/collection_index', 'total_rows' => count($collections_total), 'per_page' => $per_page, 'num_links' => 8, 'cur_page' => $page));
     $this->display('ecommerce/views/collections/index', array('collections' => $collections, 'pagination' => $pagination));
 }