コード例 #1
0
 public static function store()
 {
     $params = $_POST;
     $v = new Valitron\Validator($_POST);
     $v->rule('required', 'nimi')->message('{field} pitää antaa')->label('Nimi');
     $v->rule('required', 'ainekset')->message('Valitse vähintään yksi {field}')->label('Aines');
     $v->rule('lengthMin', 'nimi', 1)->message('{field} pitää olla 1-50 merkkiä pitkä')->label('Nimi');
     $v->rule('lengthMax', 'nimi', 50)->message('{field} pitää olla 1-50 merkkiä pitkä')->label('Nimi');
     $v->rule('lengthMax', 'tyyppi', 30)->message('{field} saa olla korkeintaan 30 merkkiä pitkä')->label('Tyyppi');
     $v->rule('lengthMax', 'lasi', 30)->message('{field} nimi saa olla korkeintaan 30 merkkiä pitkä')->label('Lasin');
     if (!isset($params['alkoholiton'])) {
         $params['alkoholiton'] = 0;
     }
     $params['tyovaiheet'] = " ";
     $drink = new Drink(array('nimi' => $params['nimi'], 'tyyppi' => $params['tyyppi'], 'alkoholiton' => $params['alkoholiton'], 'lasi' => $params['lasi'], 'kuvaus' => $params['kuvaus'], 'tyovaiheet' => $params['tyovaiheet']));
     if ($v->validate()) {
         $ainekset = $params['ainekset'];
         $drink->save($ainekset);
         Redirect::to('/drinks/' . $drink->drinkki_id, array('message' => 'Resepti lisätty tietokantaan'));
     } else {
         if (!isset($params['ainekset'])) {
             $ainekset = array();
         } else {
             $ainekset = $params['ainekset'];
         }
         $aineslista = Aines::all();
         View::make('drinks/addnew.html', array('errors' => $v->errors(), 'ainekset' => $ainekset, 'aineslista' => $aineslista, 'attributes' => $drink));
     }
 }
コード例 #2
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $data = Drink::find($id);
     if (Gate::denies('update', $data)) {
         return 'No eres el creador';
     } else {
         $data::destroy($id);
     }
 }
コード例 #3
0
 public static function sandbox()
 {
     // Testaa koodiasi täällä
     $viski = new Drink(array('id' => 0));
     $viskicola = Drink::find(1);
     $drinks = Drink::all();
     // Kint-luokan dump-metodi tulostaa muuttujan arvon
     Kint::dump($drinks);
     Kint::dump($viskicola);
 }
コード例 #4
0
 public static function sandbox()
 {
     // Testaa koodiasi täällä
     //echo 'Hello World!';
     //View::make('helloworld.html');
     $colada = Drink::find(1);
     $drinks = Drink::all();
     $colada = new Drink(array('nimi' => 'Juoma', 'tyyppi' => 'Shotti', 'lasi' => 'Hurrikaanilasi'));
     //$errors = $colada->validateDrink();
     // Kint-luokan dump-metodi tulostaa muuttujan arvon
     //Kint::dump($errors);
     Kint::dump($drinks);
     Kint::dump($colada);
 }
コード例 #5
0
 public static function sandbox()
 {
     $drink = Drink::find(6);
     Kint::dump($drink);
     // $attributes = array(
     //   'name' => 'daaa',
     //   'published' => 'eilen',
     //   'publisher' => 'a',
     //   'category_id' => '1',
     //   'description' => 'Boom, boom!'
     //   );
     //   $drink = new Drink($attributes);
     //   $er = $drink->errors();
     //   Kint::dump($er);
     //   $categories = Category::all();
     //   View::make('drink/new.html', array('errors' => $er, 'attributes' => $attributes, 'categories' => $categories));
 }
コード例 #6
0
ファイル: drinks.php プロジェクト: JonckheereM/Public
<?php

date_default_timezone_set('Europe/Berlin');
// set include path
ini_set("include_path", ".:../../library/");
// required classes
require_once 'spoon/spoon.php';
require_once 'publicApp/publicApp.php';
$tpl = new SpoonTemplate();
$tpl->setForceCompile(true);
$tpl->setCompileDirectory('./compiled_templates');
$tpl->assign('formaction', $_SERVER['PHP_SELF']);
SpoonSession::start();
//Content layout
if (SpoonSession::exists('id') === false) {
    SpoonHTTP::redirect('index.php');
}
$drinks = Drink::getAllDrinks();
$tpl->assign('iDrinks', $drinks);
// show the output
$tpl->assign('content', $tpl->getContent('templates/drinks.tpl'));
$tpl->display('templates/template.tpl');
コード例 #7
0
 public static function editUser($id)
 {
     $drinks = Drink::findUsersDrinks($id);
     $user = User::findOneUser($id);
     $admin = $user->getAdmin();
     View::make('user/edit_user.html', array('user' => $user, 'drinks' => $drinks, 'admin' => $admin));
 }
コード例 #8
0
ファイル: drink.php プロジェクト: Babaritech/babar2
function infoFields()
{
    $c = new Drink();
    return $c->getFields();
}
コード例 #9
0
ファイル: drink.php プロジェクト: PauliNiva/DrinkArchive
 public function validateFavoriteDoesntExist($user, $drink)
 {
     $errors = array();
     if (Drink::AlreadyFavorite($user, $drink)) {
         $errors[] = 'Drink is already a favorite of yours!';
     }
     return $errors;
 }
コード例 #10
0
 public static function showSearchResults()
 {
     $searchword = $_POST['searchword'];
     $drinks = Drink::search($searchword);
     View::make('/drink/search.html', array('drinks' => $drinks));
 }
コード例 #11
0
        $errors = Drink::Delete($_REQUEST['id']);
        if ($errors) {
            $model = Drink::Get($_REQUEST['id']);
            $view = "drink/delete.php";
        } else {
            header("Location: ?sub_action={$sub_action}&id={$_REQUEST['id']}");
            die;
        }
        break;
    case 'search_GET':
        $model = Drink::Search($_REQUEST['q']);
        $view = 'drink/index.php';
        break;
    case 'index_GET':
    default:
        $model = Drink::Get();
        $view = 'drink/index.php';
        break;
}
switch ($format) {
    case 'json':
        echo json_encode($model);
        break;
    case 'plain':
        include __DIR__ . "/../Views/{$view}";
        break;
    case 'web':
    default:
        include __DIR__ . "/../Views/shared/_Template.php";
        break;
}
コード例 #12
0
        $order = new Lunch(26, 'Mexican', 'Orange Flan');
        echo print_r($order, TRUE);
    }
    if (strtolower($_POST["meal"]) == "italian") {
        $order = new Lunch(20, 'Italian', 'Tiramisu');
        echo print_r($order, TRUE);
    }
}
if (isset($_POST["drink_order"])) {
    if (strtolower($_POST["drink_order"]) == "icecubes") {
        $order = new Drink(6, 'cola');
        $order->makeAddition('icecubes');
        echo print_r($order, TRUE);
    } else {
        if (strtolower($_POST["drink_order"]) == "lemon") {
            $order = new Drink(6, 'cola');
            $order->makeAddition('lemon');
            echo print_r($order, TRUE);
        } else {
            $order = new Drink(3, 'cola');
            echo print_r($order, TRUE);
            echo "<p>You haven't ordered icecubes or lemon</p><br>";
        }
    }
}
if (isset($_POST["answer"])) {
    if ($_POST["answer"] == "lunch") {
        echo "<p>From which cuisine you want your lunch?'Polish', 'Mexican', 'Italian?'</p><br>";
        echo "<form action='' method='post'>" . "<input type='text' name='meal'>" . "<input type='submit'></form>";
    }
    if ($_POST["answer"] == "drink") {
コード例 #13
0
ファイル: exal.php プロジェクト: spyre/emiral
<?php

function __autoload($cn)
{
    echo 'Including: ' . $cn . '<br/>';
    include 'classes/' . $cn . '.php';
}
?>
<html>
<head>
	<title>Hello</title>
</head>
<body>
	<?php 
$f = new Food();
$f->displayInfo();
$d = new Drink();
$d->displayInfo();
phpinfo();
?>
</body>
</html>
コード例 #14
0
ファイル: drinkDetail.php プロジェクト: JonckheereM/Public
date_default_timezone_set('Europe/Berlin');
// set include path
ini_set("include_path", ".:../library/");
// required classes
require_once 'spoon/spoon.php';
require_once 'publicApp/publicApp.php';
$tpl = new SpoonTemplate();
$tpl->setForceCompile(true);
$tpl->setCompileDirectory('./compiled_templates');
//Content layout
if (SpoonSession::exists('public_uid')) {
    //show logout
    $tpl->assign('oLogout', true);
}
$drink = new Drink(SpoonFilter::getGetValue('id', null, ''));
if ($drink->drink_id === null) {
    SpoonHTTP::redirect('index.php');
}
$recent = $drink->getRecent();
for ($i = 0; $i < sizeof($recent); $i++) {
    $recent[$i]['timestamp'] = SpoonDate::getTimeAgo(strtotime($recent[$i]['timestamp']));
    //check if the user has a fb account authenticated
    if (!$recent[$i]['fb_uid']) {
        //else, use standard fb icon
        $recent[$i]['fb_uid'] = 1;
    }
}
if ($recent !== null) {
    $tpl->assign('oRecent', true);
    $tpl->assign('iRecent', $recent);