本文整理汇总了PHP中Option::find方法的典型用法代码示例。如果您正苦于以下问题:PHP Option::find方法的具体用法?PHP Option::find怎么用?PHP Option::find使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Option
的用法示例。
在下文中一共展示了Option::find方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getObjects
static function getObjects($option_ids)
{
$options = array();
foreach ($option_ids as $option_id) {
array_push($options, Option::find($option_id));
}
return $options;
}
示例2: getOptionValue
/**
* Get all autoload options from database.
* @param String $optionName - the key of the option
* @return the value of the option
*/
private function getOptionValue($optionName)
{
if (empty(self::$options)) {
$resultSet = Option::find("is_autoload = 1");
foreach ($resultSet as $rowSet) {
$optionKey = $rowSet->getOptionKey();
$optionValue = $rowSet->getOptionValue();
self::$options[$optionKey] = $optionValue;
}
}
if (!array_key_exists($optionName, self::$options)) {
return NULL;
}
return self::$options[$optionName];
}
示例3: post
public function post()
{
//receive chose-options from contestant
$answers_contestant = array_values(Input::all());
$result = 0;
for ($i = 0; $i < count($answers_contestant); $i++) {
$option = Option::find($answers_contestant[$i]);
//if the option is right, result++
if ($option->is_right == '1') {
$result += 1;
}
}
//save result from this contestant
$contestant = Auth::user();
$contestant->result = $result;
$contestant->save();
//show result on 'result'-page
return Redirect::to('result');
}
示例4: postQuestionChange
public function postQuestionChange()
{
//message-notification
$messages = array();
//handle navigation
$admin_navigation = new AdminNavigation();
if ($admin_navigation->isNavigate()) {
return $admin_navigation->goToN();
}
//handle chapter-text change
//redirect after changed
if (Input::has('chapter_change')) {
$chapter = Chapter::find(Input::get('chapter_change'));
$chapter->text = Input::get('chapter_text');
$chapter->save();
$messages['chapter_change_text'] = 'chapter-' . $chapter->id . ':saved';
$this->messageController->send($messages, $this::MESSAGE_KEY);
return Redirect::back();
}
//handle delete-question
//redirect after deleted, no need to modify other inputs
if (Input::has('delete_question')) {
$question = Question::find(Input::get('delete_question'));
$store_question_id = $question->id;
$question->delete();
$messages['delete_question'] = 'question-' . $store_question_id . ':deleted';
$this->messageController->send($messages, $this::MESSAGE_KEY);
return Redirect::back();
}
//handle change on a question (both this one, and it's options)
//redirect after all-changes saved
if (Input::has('question_change')) {
$question = Question::find(Input::get('question_change'));
//question-change, change question-text
if (Input::has('question_text')) {
$question->text = Input::get('question_text');
$question->save();
$messages['question_change_text'] = 'question-' . $question->id . ':saved';
}
//question-change, change question-chapter_id
if (Input::has('chapter_id')) {
$question->chapter_id = Input::get('chapter_id');
$question->save();
$new_chapter = $question->getChapter;
$messages['question_change_chapter_id'] = 'question-' . $question->id . ':now belongs to chapter-' . $new_chapter->id;
}
//options-change
if (Input::has('options')) {
$options = Input::get('options');
//save options-change
$i = -1;
foreach ($options as $option_id => $option_text) {
$option = Option::find($option_id);
$option->text = $option_text;
//reset all option-is_right = 0
//is_right set again with input-is_right checked
$option->is_right = 0;
$option->save();
$messages['options_change[' . ++$i . ']'] = 'option-' . $option->id . ':saved';
}
//modify option-is_right
if (Input::has('is_right')) {
$option = Option::find(Input::get('is_right'));
//this option set is_right = 1
$option->is_right = 1;
$option->save();
$messages['options_change_is_right'] = 'option-' . $option->id . '-is_right:saved';
}
}
//send message-notification
$this->messageController->send($messages, $this::MESSAGE_KEY);
return Redirect::back();
}
//new-question
//redirect after create new-one
if (Input::has('new_question')) {
//save new question
$question = new Question();
//delete + auto_increment >>> modify question-id not continuous
//manually change question-id
$last_question = Question::all()->last();
$question->id = $last_question->id + 1;
$question->text = Input::get('question_text');
$question->chapter_id = Input::get('chapter_id');
$question->save();
$question_id = $question->id;
$messages['new_question'] = 'question-' . $question->id . ':saved';
//save new options
$options_text = Input::get('options');
$created_options = array();
for ($i = 0; $i < 4; $i++) {
$option = new Option();
$option->text = $options_text[$i];
$option->question_id = $question_id;
$option->is_right = 0;
$option->save();
//store in array new-option in $created_options, to add is_right on which
$created_options[$i] = $option;
$messages['option[' . $i . ']'] = 'option-' . $option->id . ':saved';
}
//.........这里部分代码省略.........
示例5: function
$app->post('/add_restaurant_options', function () use($app) {
$restaurant = Restaurant::find($_POST['restaurant_id']);
$option = Option::find($_POST['option_id']);
$restaurant->addOption($option);
return $app['twig']->render('restaurant.html.twig', array('restaurant' => $restaurant, 'restaurant_options' => $restaurant->getOptions(), 'all_options' => Option::getAll()));
});
$app->post('/add_option_restaurants', function () use($app) {
$option = Option::find($_POST['option_id']);
$restaurant = Restaurant::find($_POST['restaurant_id']);
$option->addRestaurant($restaurant);
return $app['twig']->render('option.html.twig', array('option' => $option, 'option_restaurants' => $option->getRestaurants(), 'all_restaurants' => Restaurant::getAll()));
});
$app->get('/restaurants/{id}', function ($id) use($app) {
$restaurant = Restaurant::find($id);
return $app['twig']->render('restaurant.html.twig', array('restaurant' => $restaurant, 'restaurant_options' => $restaurant->getOptions(), 'all_options' => Option::getAll()));
});
$app->get('/options/{id}', function ($id) use($app) {
$option = Option::find($id);
return $app['twig']->render('option.html.twig', array('option' => $option, 'option_restaurants' => $option->getRestaurants(), 'all_restaurants' => Restaurant::getAll()));
});
$app->post('/restaurants/{id}/delete', function ($id) use($app) {
$restaurant = Restaurant::find($id);
$restaurant->delete();
return $app['twig']->render('admin.html.twig', array('restaurants' => Restaurant::getAll(), 'options' => Option::getAll()));
});
$app->post('/options/{id}/delete', function ($id) use($app) {
$option = Option::find($id);
$option->delete();
return $app['twig']->render('admin.html.twig', array('options' => Option::getAll(), 'restaurants' => Restaurant::getAll()));
});
return $app;
示例6: function
*/
Route::filter('before', function () {
// Do stuff before every request to your application...
});
Route::filter('after', function ($response) {
// Do stuff after every request to your application...
});
Route::filter('csrf', function () {
if (Request::forged()) {
return Response::error('500');
}
});
Route::filter('auth', function () {
if (Auth::guest()) {
return Redirect::to('login');
}
});
Route::filter('postnotification', function () {
$u = Option::find('1');
if ($u->activate_pn == "1") {
if ($u->basic_name != '' && (!isset($_SERVER['PHP_AUTH_USER']) || $_SERVER['PHP_AUTH_USER'] != $u->basic_name)) {
return Response::error('401');
} else {
if ($u->basic_pass != '' && (!isset($_SERVER['PHP_AUTH_PW']) || $_SERVER['PHP_AUTH_PW'] != $u->basic_pass)) {
return Response::error('401');
}
}
} else {
return Response::error('403');
}
});
示例7: delete_tag
public function delete_tag()
{
$id = Request::segment(4);
$tag = Option::find($id);
Option::where('id', $id)->delete();
$message = "Successfully deleted the product tag";
$type = "success";
return Redirect::to('/admin/tags')->with('type', $type)->with('message', $message);
}
示例8: has_opt
/**
*
*/
public function has_opt($i_key)
{
return Option::find(get_called_class(), $this->id, $i_key);
}
示例9: testCustomPrimaryKey
function testCustomPrimaryKey()
{
$option = User::find(1)->option();
$option->name = 'testtest';
$option->save();
$this->assertEquals(Option::find(1)->name, 'testtest');
}
示例10: test_find
function test_find()
{
//arrange
$name = "Peanut-free";
$test_allergy = new Option($name);
$test_allergy->save();
$name2 = "Gluten-free";
$test_allergy2 = new Option($name2);
$test_allergy2->save();
//act
$result = Option::find($test_allergy2->getId());
//assert
$this->assertEquals($test_allergy2, $result);
}