コード例 #1
0
ファイル: SpeciesTableSeeder.php プロジェクト: sjmrt/blog.dev
 public function run()
 {
     $species1 = new Species();
     $species1->species = 'dog';
     $species1->save();
     $species2 = new Species();
     $species2->species = 'cat';
     $species2->save();
 }
コード例 #2
0
ファイル: Species.php プロジェクト: jessesiu/GigaDBV3
 public static function getListCommonNames()
 {
     $models = Species::model()->findAll(array('limit' => 10));
     $list = array();
     foreach ($models as $key => $model) {
         $list[$model->id] = $model->common_name;
     }
     return $list;
 }
コード例 #3
0
ファイル: Project.php プロジェクト: jessesiu/GigaDBV3
 public static function getListProjects()
 {
     $models = Species::model()->findAll();
     $list = array();
     foreach ($models as $key => $model) {
         $list[$model->id] = $model->common_name;
     }
     return $list;
 }
コード例 #4
0
ファイル: fakePets.php プロジェクト: ZJScapstone/capstone.dev
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     echo "\n| This command will fake a whole lot of pet data! It will create\n";
     echo "| as many pet records as you specify, and then associate five\n";
     echo "| random pictures in /public/img/uploads with each new pet\n\n";
     echo "How many pets would you like to fake?\n> ";
     $n = intval($this->ask(''));
     echo "working...";
     //get size, user, and species ids
     $species_ids = [];
     $size_ids = [];
     $user_ids = [];
     Species::all()->each(function ($species) use(&$species_ids) {
         $species_ids[] = $species->id;
     });
     Size::all()->each(function ($size) use(&$size_ids) {
         $size_ids[] = $size->id;
     });
     User::all()->each(function ($user) use(&$user_ids) {
         $user_ids[] = $user->id;
     });
     $names = ['fido', 'fluffy', 'muffins', 'whiskers', 'benji', 'kitty'];
     $colors = ['white', 'brown', 'black', 'calico', 'grey'];
     $descriptions = ['Use lap as chair. I am the best pooping rainbow while flying in a toasted bread costume in space lick yarn hanging out of own butt and stare at wall turn and meow stare at wall some more meow again continue staring . Stare at ceiling light eat grass, throw it back up, yet make meme, make cute face. Eat and than sleep on your face climb leg, so has closed eyes but still sees you. Hunt by meowing loudly at 5am next to human slave food dispenser drink water out of the faucet hide at bottom of staircase to trip human chew iPad power cord poop in litter box, scratch the walls yet fall over dead (not really but gets sypathy). Poop in the plant pot lick plastic bags. Sniff other cat\'s butt and hang jaw half open thereafter intently sniff hand get video posted to internet for chasing red dot attack feet, yet immediately regret falling into bathtub but run in circles. I am the best knock over christmas tree hunt anything that moves. Eat a plant, kill a hand. Sweet beast thug cat . Meow all night having their mate disturbing sleeping humans flop over, so ears back wide eyed. Please stop looking at your phone and pet me behind the couch claw drapes, eat from dog\'s food asdflkjaertvlkjasntvkjn (sits on keyboard). Pee in the shoe human is washing you why halp oh the horror flee scratch hiss bite.', 'Poop in litter box, scratch the walls refuse to drink water except out of someone\'s glass or leave dead animals as gifts, and put toy mouse in food bowl run out of litter box at full speed . Run in circles intently stare at the same spot. Lounge in doorway. Walk on car leaving trail of paw prints on hood and windshield cat snacks. Refuse to drink water except out of someone\'s glass pelt around the house and up and down stairs chasing phantoms eat prawns daintily with a claw then lick paws clean wash down prawns with a lap of carnation milk then retire to the warmest spot on the couch to claw at the fabric before taking a catnap, so if it smells like fish eat as much as you wish or the dog smells bad. Leave hair everywhere meowzer! so chew iPad power cord, and poop on grasses yet sleep on dog bed, force dog to sleep on floor. Stare at wall turn and meow stare at wall some more meow again continue staring touch water with paw then recoil in horror spread kitty litter all over house but all of a sudden cat goes crazy chase laser instantly break out into full speed gallop across the house for no reason. Cat is love, cat is life. Sweet beast destroy the blinds pee in human\'s bed until he cleans the litter box, stare at wall turn and meow stare at wall some more meow again continue staring yet brown cats with pink ears and curl into a furry donut. Jump around on couch, meow constantly until given food, sit in box. Hide from vacuum cleaner human give me attention meow but has closed eyes but still sees you. Bathe private parts with tongue then lick owner\'s face lick butt love to play with owner\'s hair tie but poop in the plant pot for inspect anything brought into the house find something else more interesting. Mark territory mark territory stare out the window, but leave hair everywhere claws in your leg and get video posted to internet for chasing red dot. When in doubt, wash spot something, big eyes, big eyes, crouch, shake butt, prepare to pounce but hunt by meowing loudly at 5am next to human slave food dispenser. Meow for food, then when human fills food dish, take a few bites of food and continue meowing jump launch to pounce upon little yarn mouse, bare fangs at toy run hide in litter box until treats are fed hack up furballs. Eat and than sleep on your face pelt around the house and up and down stairs chasing phantoms but touch water with paw then recoil in horror meow chase mice. I like big cats and i can not lie meowing non stop for food, tuxedo cats always looking dapper or hack up furballs asdflkjaertvlkjasntvkjn (sits on keyboard). Mark territory attack the dog then pretend like nothing happened shake treat bag, rub face on everything, for damn that dog . Get video posted to internet for chasing red dot sniff other cat\'s butt and hang jaw half open thereafter unwrap toilet paper i like big cats and i can not lie yet present belly, scratch hand when stroked, so poop on grasses chew foot. Meow paw at beetle and eat it before it gets away, eat from dog\'s food sun bathe, but scratch leg; meow for can opener to feed me but spit up on light gray carpet instead of adjacent linoleum and the dog smells bad. Leave hair everywhere kitty power! , human is washing you why halp oh the horror flee scratch hiss bite hide from vacuum cleaner meow all night having their mate disturbing sleeping humans. Mark territory spread kitty litter all over house play riveting piece on synthesizer keyboard thug cat . Hopped up on catnip purr while eating but scream at teh bath, make meme, make cute face or lick plastic bags yet spit up on light gray carpet instead of adjacent linoleum. Hide head under blanket so no one can see.', 'Eat from dog\'s food. Paw at beetle and eat it before it gets away play time, yet meow chase ball of string has closed eyes but still sees you hide when guests come over, and have secret plans. White cat sleeps on a black shirt stretch destroy couch as revenge. Leave hair everywhere put toy mouse in food bowl run out of litter box at full speed but asdflkjaertvlkjasntvkjn (sits on keyboard) ears back wide eyed yet my left donut is missing, as is my right asdflkjaertvlkjasntvkjn (sits on keyboard), or stare at ceiling. Vommit food and eat it again sun bathe intently sniff hand, fall over dead (not really but gets sypathy) paw at beetle and eat it before it gets away, for meow under the bed.'];
     $status = ['lost', 'found', 'adoptable'];
     $age = ['baby', 'young', 'adult', 'senior'];
     $gender = ['male', 'female', 'unknown'];
     $a_num = ['342335', '234567', '234412', '123123', '123345', '345345'];
     $breeds = ['doberman', 'short hair', 'long hair', 'husky'];
     $images = explode("\n", trim(`ls public/img/uploads`));
     for ($i = 0; $i < $n; $i++) {
         if ($i % 10 == 0) {
             echo '.';
         }
         $pet = new Pet();
         $pet->name = $names[array_rand($names)];
         $pet->species_id = $species_ids[array_rand($species_ids)];
         $pet->status = $status[array_rand($status)];
         $pet->color = $colors[array_rand($colors)];
         $pet->age = $age[array_rand($age)];
         $pet->description = $descriptions[array_rand($descriptions)];
         $pet->gender = $gender[array_rand($gender)];
         $pet->a_num = $a_num[array_rand($a_num)];
         $pet->breed = $breeds[array_rand($breeds)];
         $pet->size_id = $size_ids[array_rand($size_ids)];
         $pet->user_id = $user_ids[array_rand($user_ids)];
         $pet->save();
         for ($j = 0; $j < 5; $j++) {
             $img = new Image();
             $img->pet_id = $pet->id;
             $img->img_path = '/img/uploads/' . $images[array_rand($images)];
             $img->save();
         }
     }
     echo "\n";
     $this->info('pets created!');
 }
コード例 #5
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $species = Species::find($id);
     if ($species) {
         try {
             // Delete breed, if not possible, catch error.
             $species->delete();
         } catch (Exception $e) {
             // If breed to be deleted is in use, send nice error back to admin.
             return Redirect::back()->with('message', FlashMessage::DisplayAlert('Species can NOT be deleted because it\'s in use.', 'alert'));
         }
         return Redirect::back()->with('message', FlashMessage::DisplayAlert('Species Deleted Successfully!', 'success'));
     }
     return Redirect::back()->with('message', FlashMessage::DisplayAlert('Record Not Found.', 'alert'));
 }
コード例 #6
0
ファイル: petFaker.php プロジェクト: ZJScapstone/capstone.dev
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     echo "\n--- Lets create some pet postings! ---\n\n";
     echo "| This will create a new pet record with the prompted information,\n";
     echo "| a random status, age, and color, and user, species, and breed\n";
     echo "| ids that belong to the first record of each in the database.\n\n";
     echo "| This command will also get a list of the files in /img/uploads\n";
     echo "| and select one at random from the list to create a new image\n";
     echo "| object and record to tie to the pet object we just created.\n\n";
     echo "name \n> ";
     $name = $this->ask('');
     echo "color\n> ";
     $color = $this->ask('');
     echo "description\n> ";
     $description = $this->ask('');
     $species = ['cat', 'dog', 'other'];
     $species = $species[array_rand($species)];
     $status = ['lost', 'found', 'adoptable'];
     $status = $status[array_rand($status)];
     $age = ['baby', 'young', 'adult', 'senior'];
     $age = $age[array_rand($age)];
     $gender = ['male', 'female', 'unknown'];
     $gender = $gender[array_rand($gender)];
     $a_num = ['342335', '234567', '234412', '123123', '123345', '345345'];
     $a_num = $a_num[array_rand($a_num)];
     $pet = new Pet();
     $pet->name = $name;
     $pet->species_id = Species::first()->id;
     $pet->status = $status;
     $pet->color = $color;
     $pet->age = $age;
     $pet->description = $description;
     $pet->gender = $gender;
     $pet->a_num = $a_num;
     $pet->breed_id = Breed::first()->id;
     $pet->user_id = User::first()->id;
     $pet->save();
     $images = explode("\n", trim(`ls public/img/uploads`));
     $petImg = $images[array_rand($images)];
     $img = new Image();
     $img->pet_id = $pet->id;
     $img->img_path = "/img/uploads/{$petImg}";
     $img->save();
     $this->info('pet created!');
 }
コード例 #7
0
ファイル: SearchRecord.php プロジェクト: jessesiu/GigaDBV3
 private function convertUnit($key, $query, $array)
 {
     if ($key == "dataset_type") {
         $types = Type::getListTypes();
         return $this->convertResult($query, $types);
     }
     if ($key == "publisher") {
         $publishers = Publisher::getListPublishers();
         return $this->convertResult($query, $publishers);
     }
     if ($key == "common_name") {
         $common_names = Species::getListCommonNames();
         return $this->convertResult($query, $common_names);
     }
     if ($key == "project") {
         $projects = Project::getListProjects();
         return $this->convertResult($query, $projects);
     }
     if ($key == "external_link_type") {
         $external_link_types = ExternalLinkType::getListTypes();
         return $this->convertResult($query, $external_link_types);
     }
     if ($key == "size_from") {
         return $query . " " . $this->convertSizeUnit($array['size_from_unit']);
     }
     if ($key == "size_to") {
         return $query . " " . $this->convertSizeUnit($array['size_to_unit']);
     }
     if (is_array($query)) {
         return implode(",", $query);
     } else {
         return $query;
     }
 }
コード例 #8
0
ファイル: app.php プロジェクト: ashlinaronin/cuddle_corner
<?php

require_once __DIR__ . "/../vendor/autoload.php";
require_once __DIR__ . "/../src/Species.php";
//require_once __DIR__."/../src/Category.php";
$app = new Silex\Application();
$server = 'mysql:host=localhost;dbname=cuddle_corner';
$username = '******';
$password = '******';
$DB = new PDO($server, $username, $password);
$app->register(new Silex\Provider\TwigServiceProvider(), array('twig.path' => __DIR__ . "/../views"));
$app->get("/", function () use($app) {
    return $app['twig']->render('index.html.twig', array('species' => Species::getAll()));
});
return $app;
コード例 #9
0
ファイル: data.php プロジェクト: jamiezyx/MorpheusPets
 /**
  * Get all species
  *
  * @return array
  */
 public function getAllSpecies()
 {
     $ret = [];
     // Species variables
     $id = null;
     $species = null;
     $type = null;
     $stats = null;
     $this->getAllSpeciesStatement->execute();
     $this->getAllSpeciesStatement->bind_result($id, $species, $type, $stats);
     while ($this->getAllSpeciesStatement->fetch()) {
         $newSpecies = new Species($species, $type, $stats);
         $newSpecies->setId($id);
         array_push($ret, $newSpecies);
     }
     return $ret;
 }
コード例 #10
0
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer the ID of the model to be loaded
  */
 public function loadModel($id)
 {
     $model = Species::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
コード例 #11
0
 function test_find()
 {
     //Arrange
     $name = "naked mole rat";
     $fur = 0;
     $wings = 0;
     $legs = 4;
     $test_species = new Species($name, $fur, $wings, $legs);
     $test_species->save();
     //Act
     $result = Species::find("naked mole rat");
     //Assert
     $this->assertEquals($test_species, $result);
 }
コード例 #12
0
ファイル: data.php プロジェクト: sharris2/MorpheusPets
 /**
  * Get all active pets owned by a user
  *
  * @param int $id
  *
  * @return array
  */
 public function getActivePetsForUser($id)
 {
     $ret = [];
     // Pet variables
     $res_id = null;
     $owner_id = null;
     $species_id = null;
     $name = null;
     $experience = null;
     $brawn = null;
     $guts = null;
     $essence = null;
     $speed = null;
     $focus = null;
     $grit = null;
     $active = null;
     // User variables
     $username = null;
     $email_address = null;
     $description = null;
     // Species variables
     $species = null;
     $type = null;
     $stats = null;
     $this->getActivePetsForUserStatement->bind_param("i", $id);
     $this->getActivePetsForUserStatement->execute();
     $this->getActivePetsForUserStatement->bind_result($res_id, $owner_id, $species_id, $name, $experience, $brawn, $guts, $essence, $speed, $focus, $grit, $active, $username, $description, $species, $type, $stats);
     while ($this->getActivePetsForUserStatement->fetch()) {
         $newUser = new User($username, $email_address, $description);
         $newUser->setId($owner_id);
         $newSpecies = new Species($species, $type, $stats);
         $newSpecies->setId($species_id);
         $newPet = new Pet($newUser, $newSpecies, $name);
         $newPet->setId($res_id);
         $newPet->setExperience($experience);
         $newPet->setBrawn($brawn);
         $newPet->setGuts($guts);
         $newPet->setEssence($essence);
         $newPet->setSpeed($speed);
         $newPet->setFocus($focus);
         $newPet->setGrit($grit);
         $newPet->setActive(boolval($active));
         array_push($ret, $newPet);
     }
     return $ret;
 }
コード例 #13
0
ファイル: _form1.php プロジェクト: jessesiu/GigaDBV3
	<p class="note">Fields with <span class="required">*</span> are required.</p>

	<?php 
echo $form->errorSummary($model);
?>

	<div class="control-group">
		<?php 
echo $form->labelEx($model, 'species_id', array('class' => 'control-label'));
?>

				<div class="controls">
                                    
        <?php 
echo CHtml::activeDropDownList($model, 'species_id', CHtml::listData(Species::model()->findAll(), 'id', 'common_name'));
?>
		<?php 
echo $form->error($model, 'species_id');
?>
                </div>
	</div>

	<div class="control-group">
		<?php 
echo $form->labelEx($model, 's_attrs', array('class' => 'control-label'));
?>
				<div class="controls">
		<?php 
echo $form->textArea($model, 's_attrs', array('rows' => 6, 'cols' => 50));
?>
コード例 #14
0
 public function actionAddSample()
 {
     if (isset($_POST['dataset_id']) && isset($_POST['sample_name']) && isset($_POST['species'])) {
         $transaction = Yii::app()->db->beginTransaction();
         try {
             if ($_POST['sample_name'] == "") {
                 Util::returnJSON(array("success" => false, "message" => Yii::t("app", 'Cannot add sample, please input "Sample ID" value.')));
             }
             if ($_POST['species'] == "") {
                 Util::returnJSON(array("success" => false, "message" => Yii::t("app", 'Cannot add sample, please input "valid  species" value.')));
             }
             $array = explode(":", $_POST['species']);
             $tax_id = $array[0];
             $species = Species::model()->findByAttributes(array('tax_id' => $tax_id));
             if (!$species) {
                 Util::returnJSON(array("success" => false, "message" => Yii::t("app", 'Cannot add sample, please input "valid  species" value.')));
             }
             #create new sample
             $sample = new Sample();
             $sample->species_id = $species->id;
             $sample->name = $_POST['sample_name'];
             $sample->submitted_id = Yii::app()->user->id;
             $sample->submission_date = date('Y-m-d H:i:s');
             $user = User::model()->findByPk(Yii::app()->user->id);
             if ($user) {
                 $sample->contact_author_name = $user->first_name . " " . $user->last_name;
                 $sample->contact_author_email = $user->email;
             }
             if ($sample->save()) {
                 #create dataset sample
                 $ds = new DatasetSample();
                 $ds->dataset_id = $_POST['dataset_id'];
                 $ds->sample_id = $sample->id;
                 if ($ds->save()) {
                     $transaction->commit();
                     Util::returnJSON(array("success" => true));
                 }
             }
             Util::returnJSON(array("success" => false, "message" => Yii::t("app", "Save Error.")));
         } catch (Exception $e) {
             $message = $e->getMessage();
             Yii::log(print_r($message, true), 'error');
             $transaction->rollback();
             Util::returnJSON(array("success" => false, "message" => Yii::t("app", 'Cannot add sample, please input "valid  species" value.')));
         }
     }
 }
コード例 #15
0
ファイル: routes.php プロジェクト: 2dan-devs/animalshelter
    Auth::logout();
    return Redirect::to('adminlogin')->with('message', FlashMessage::DisplayAlert('Logged out successfully', 'success'));
});
/* ------------------------  End User Routes --------------------------------- */
/* --------------------------- ADMIN PREFIXED ROUTES ---------------------------- */
Route::group(['before' => 'auth', 'prefix' => '/admin'], function () {
    // Display dashboard view in /app/views/admin/dashboard.blade.php
    Route::get('dashboard', function () {
        return View::make('admin.dashboard')->with('title', 'Dashboard');
    });
    // Routes: index, create, store, show, edit, update, destroy.
    Route::resource('dashboard/animal', 'AnimalController');
    // Route to create, view, and destroy statuses, species, and breeds.
    Route::get('dashboard/attributes', function () {
        // Get all species from database species table.
        $species = Species::all();
        // Get all Cat breeds from database breeds table.
        $breeds = Breed::all();
        // Get all data from status table on database.
        $statuses = Status::all();
        return View::make('admin.animal.attributes', ['species' => $species, 'breeds' => $breeds, 'statuses' => $statuses])->with('title', 'Status / Species / Breeds');
    });
    // Resouce to create, edit, update, and delete shelter events.
    Route::resource('dashboard/events', 'EventsController');
    // Resouce to create and destroy statuses
    Route::resource('dashboard/status', 'StatusController');
    // Resouce to create and destroy statuses
    Route::resource('dashboard/species', 'SpeciesController');
    // Resouce to create and destroy statuses
    Route::resource('dashboard/breed', 'BreedController');
    // Resouce to view and update About Us information.
コード例 #16
0
 /**
  * Updates a particular model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id the ID of the model to be updated
  */
 public function actionUpdate($id)
 {
     $model = $this->loadModel($id);
     //$old_code= $model->code;
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Sample'])) {
         $model->attributes = $_POST['Sample'];
         if (strpos($_POST['Sample']['species_id'], ":") !== false) {
             $array = explode(":", $_POST['Sample']['species_id']);
             //                var_dump($array);
             $tax_id = $array[0];
             if (is_numeric($tax_id)) {
                 $species = Species::model()->findByAttributes(array('tax_id' => $tax_id));
                 $model->species_id = $species->id;
                 // save sample attributes
                 $model->attributesList = $_POST['Sample']['attributesList'];
                 $this->updateSampleAttributes($model);
                 if ($model->save()) {
                     // $dataset_id= DatasetSample::model()->findByAttributes(array('sample_id'=>$model->id))->dataset_id;
                     //     $files= File::model()->findAllByAttributes(array('code'=>$old_code,'dataset_id'=>$dataset_id));
                     //     foreach($files as $file)
                     //     {
                     //         $file->code=$model->code;
                     //         $file->save();
                     //         //echo $model->code;
                     //     }
                     $this->redirect(array('view', 'id' => $model->id));
                 }
             } else {
                 $model->addError("error", 'The species id should be numeric');
             }
         } else {
             $model->addError("error", 'The input format is wrong, should be id:common_name');
         }
     }
     $specie = Species::model()->findByPk($model->species_id);
     $this->render('update', array('model' => $model, 'specie' => $specie));
 }
コード例 #17
0
ファイル: Sample.php プロジェクト: jessesiu/GigaDBV3
 public static function getCommonList($ids)
 {
     $crit = new CDbCriteria();
     $crit->join = "join sample on sample.species_id = t.id";
     $crit->addInCondition("sample.id", $ids);
     return Species::model()->findAll($crit);
 }