public function actionIndexCattie() { $criteria = new CDbCriteria(); $criteria->addCondition("cateid=2"); $model = Breed::model()->findAll($criteria); $parseRows = Breed::model()->parseCattie($model); return $parseRows; }
/** * Display a listing of the resource. * * @return Response */ public function index() { $types = Type::all(); $types->toarray(); $tips = Tip::all(); $tips->toarray(); $breeds = Breed::all(); $breeds->toarray(); // $tips = DB::table('pet_tips') // ->where('breed_id', '=', $breed_id) // ->get(); return View::make('tips.tips', compact('types', 'breeds', 'tips')); }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { $breed = Breed::find($id); if ($breed) { try { // Delete breed, if not possible, catch error. $breed->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('Breed can NOT be deleted because it\'s in use.', 'alert')); } return Redirect::back()->with('message', FlashMessage::DisplayAlert('Breed Deleted Successfully!', 'success')); } return Redirect::back()->with('message', FlashMessage::DisplayAlert('Record Not Found.', 'alert')); }
/** * 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!'); }
echo file_name_with_get(); ?> " enctype="multipart/form-data" method="post" ><fieldset class="registration-form"> Name: <br><div class="form-group"><input type="text" class="form-control" name="name" value="" required/></div> <!-- default value needed for form --> <input type="hidden" class="form-control" name="MAX_FILE_SIZE" value="10000000" /> Image: <br><div class="form-group"><input type="file" class="btn btn-default btn-file btn-md" name="file_upload" /></div> Breed: <br><div class="form-group"><select name="breed" class="form-control"></div> <option value="0">Undefined</option> <?php //we need to display all available items //do a concatenation of the pet type and the breed $sql = "SELECT `b`.`breed_wk`, `b`.`pet_type_wk`, CONCAT(`p`.`name`,' - ',`b`.`name`) AS `name`, "; $sql .= "`b`.`create_dt` FROM `breed` AS `b` INNER JOIN `pet_type` AS `p` ON `p`.`pet_type_wk` = `b`.`pet_type_wk` "; $sql .= "WHERE `b`.`breed_wk` > 0 ORDER BY `p`.`name` ASC, `b`.`name` ASC"; $to_display = Breed::find_by_sql($sql); //loop through all items foreach ($to_display as $value) { echo "<option value=\"" . $value->breed_wk . "\""; echo ">" . $value->name . "</option>"; } ?> </select></div> Color: <br><div class="form-group"><select name="color" class="form-control"> <option value="0">Undefined</option> <?php //we need to display all available records $to_display = Color::find_all(); //loop through all items foreach ($to_display as $value) { echo "<option value=\"" . $value->color_wk . "\"";
$breeds = Breed::all(); $breed_options = array_combine($breeds->lists('id'), $breeds->lists('name')); $view->with('breed_options', $breed_options); }); Route::get('/', function () { return Redirect::to("cats"); }); Route::get('about', function () { return View::make('about')->with('number_of_cats', 9000); }); Route::get('cats', function () { $cats = Cat::all(); return View::make('cats/index')->with('cats', $cats); }); Route::get('cats/breeds/{name}', function ($name) { $breed = Breed::whereName($name)->with('cats')->first(); return View::make('cats/index')->with('breed', $breed)->with('cats', $breed->cats); }); Route::get('cats/create', function () { $cat = new Cat(); return View::make('cats.edit')->with('cat', $cat)->with('method', 'post'); }); Route::post('cats', function () { $cat = Cat::create(Input::all()); return Redirect::to('cats/' . $cat->id)->with('message', 'Profil został utworzony!'); }); Route::get('cats/{id}', function ($id) { $cat = Cat::find($id); return View::make('cats.single')->with('cat', $cat); }); Route::get('cats/{cat}/edit', function (Cat $cat) {
/** * Store a newly created resource in storage. * * @return Response */ public function store() { $about = ""; $this->response['console'] = "SERVER[status]-> OK::200\n "; $this->response['console'] .= "\t" . Input::get('action') . "\n"; switch (Input::get('action')) { case 'new_admin': $this->response['console'] .= "Creating new admin...\n"; $mUser = new User(); $mUser->username = Input::get('username'); $mUser->password = Hash::make(Input::get('password')); $mUser->role = Input::get('role'); $mUser->save(); $this->response['message'] = ucfirst($mUser->username) . " was added to admins successfully"; break; case 'new_medicine_type': $this->response['console'] .= "Creating new medicine type...\n"; $mType = new Type(); $mType->type = Input::get('type'); $mType->save(); $this->response['message'] = ucfirst($mType->type) . " was added to medicine types successfully"; break; case 'new_medicine_breed': $this->response['console'] .= "Creating new medicine breed...\n"; $mBreed = new Breed(); $mBreed->breed = Input::get('breed'); $mBreed->type_id = Input::get('type'); $this->response['console'] = $mBreed->breed . " | " . $mBreed->type_id . "\n"; $mBreed->save(); $this->response['message'] = ucfirst($mBreed->breed) . " was added to medicine breeds successfully"; break; case 'new_medicines_tip': $_about = Input::get('about'); $this->response['console'] .= "Creating new medicine tip...\n"; $this->response['console'] .= "about :" + $_about + " \n"; if ($_about == "1") { $about = "Health"; } elseif ($_about == "2") { $about = "Food"; } else { $about = "Dosage"; } $mTip = new Tip(); $mTip->type_id = Input::get('type'); $mTip->breed_id = Input::get('breed'); $mTip->about = $about; $mTip->content = Input::get('content'); $this->response['console'] .= $mTip->type_id . " | " . $mTip->breed_id . " | " . $mTip->about . " | " . $mTip->content; $mTip->save(); $this->response['message'] = "New tip was successfully recorded"; break; case 'new_medicine': $this->response['console'] .= "Creating new medicine process has started\n"; $mPet = new Pet(); if (Input::hasFile('photo')) { $uploadDir = public_path() . "/img/uploads/"; $this->response['console'] .= "\tNew image process has started\n"; $fileName = sha1(Input::get('name')) . "." . Input::get('ext'); $_FILES['photo']['name'] = $fileName; $this->response['console'] .= "\ttmp_name: " . $_FILES['photo']['tmp_name'] . "\n"; $this->response['console'] .= "\tsaving to " . $uploadDir . "\n"; move_uploaded_file($_FILES["photo"]["tmp_name"], $uploadDir . $_FILES["photo"]["name"]); $mPet->image = $fileName; } $mPet->name = Input::get('name'); $mPet->breed_id = Input::get('breed'); $mPet->appearance_id = Input::get('appearance'); $mPet->type_id = Input::get('type'); $mPet->age = Input::get('age'); $mPet->price = Input::get('price'); $mPet->description = Input::get('description'); $mPet->care = Input::get('care'); $mPet->save(); $this->response['message'] = "{$mPet->name} was added to the list of medicines successfully"; } return json_encode($this->response); }
} else { $session->message($session->message . "Breed " . $new_breed->name . " cannot be added at this time.<br />"); } } redirect_head(ROOT_URL . "admin/manage_breeds.php"); } /* If Pet_Type is being added */ if (isset($_POST["add_pet_type"])) { $new_pet_type = new Pet_Type(); $new_pet_type->name = $_POST["name"]; if ($new_pet_type->save()) { // get the new pet type's wk $new_wk = $database->insert_id(); $session->message($session->message . "The new pet type {$new_pet_type->name} was successfully created!<br />"); // create an undefined breed for the new pet type $undefined_breed = new Breed(); $undefined_breed->name = "undefined"; $undefined_breed->pet_type_wk = $new_wk; if ($undefined_breed->save()) { $session->message($session->message . "New undefined breed created for new pet type.<br />"); } else { //die($database->last_error); $session->message($session->message . "Creation of undefined breed for new pet type was unsuccessful.<br />"); } redirect_head(current_url()); } else { $session->message("The new pet type was not successfully created. Please try again.<br />"); redirect_head(current_url()); } } }
Route::resource('dashboard/aboutus', 'AboutUsController'); // Resouce to view and update Contact Us information. Route::resource('dashboard/contactus', 'ContactUsController'); // Update User Information section ********************** Route::get('profile', function () { $username = Auth::user()->username; $user = User::find(Auth::user()->id); return View::make('user.profile', ['username' => $username, 'user' => $user])->withTitle('Edit User Profile'); }); Route::post('profile/update/{id}', ['uses' => 'UserController@updateProfile']); // End Update User Information section ****************** // API for jQuery to display breeds based on specie selected. Route::get('breed-based-on-specie', function () { $species_id = Input::get('species_id'); // Get breeds for specie selected. $breeds = Breed::where('species_id', '=', $species_id)->orderBy('name')->get(); // Return data as Json. return Response::json($breeds); }); }); /* --------------------------- END ADMIN ROUTES ------------------------- */ /* ----------------------- ANGULAR.JS API ROUTES ------------------------ */ Route::group(['prefix' => 'client_api'], function () { Route::get('all_animals', 'ClientApiController@AllAnimals'); Route::get('all_dogs', 'ClientApiController@AllDogs'); Route::get('all_cats', 'ClientApiController@AllCats'); Route::get('events', 'ClientApiController@AllEvents'); Route::post('subscribe', 'ClientApiController@subscribeToNewsletters'); Route::get('aboutus', 'ClientApiController@aboutUs'); Route::get('contactus', 'ClientApiController@contactUs'); Route::get('{animal}', 'ClientApiController@AnimalData');