Ejemplo n.º 1
0
 public function action_index()
 {
     $categories = Categorie::all();
     $view = View::make('home.index')->with('title', 'REMARKET')->with('categories', $categories);
     return $view;
 }
<?php

require_once 'lib/Twig/Autoloader.php';
require_once "model/categorie.php";
session_start();
$categories = new Categorie();
Twig_Autoloader::register();
$loader = new Twig_Loader_Filesystem('templates');
$twig = new Twig_Environment($loader, array('defaultContext' => array('media_url' => $mediaUrl, 'url_root' => $documentRoot . "/", 'session' => $_SESSION, 'cetegories_list' => $categories->all())));
Ejemplo n.º 3
0
 public function action_edit($id)
 {
     if (Auth::check() && Session::has('id')) {
         $account = Account::find(Session::get('id'));
         if (Input::has('title') && Input::has('category_id') && Input::has('price') && Input::has('date_available') && Input::has('date_unavailable')) {
             $listing = Listing::find($id);
             $location;
             if (Input::has('location_id')) {
                 $location = Location::find(Input::get('location_id'));
             }
             if (Input::has('address') || Input::has('city') || Input::has('postal_code')) {
                 $location = new Location();
                 Input::has('address') ? $location->address = strip_tags(Input::get('address')) : ($location->address = '');
                 Input::has('city') ? $location->city = Input::get('city') : ($location->city = '');
                 Input::has('postal_code') ? $location->postal_code = strip_tags(Input::get('postal_code')) : ($location->postal_code = '');
                 $location->account_id = $account->id;
                 $location->save();
                 $location = Location::where_address_and_city_and_postal_code(Input::get('address'), Input::get('city'), Input::get('postal_code'))->first();
             }
             $listing->title = strip_tags(Input::get('title'));
             $listing->description = Input::has('description') ? strip_tags(Input::get('description')) : '';
             $listing->category_id = Input::get('category_id');
             $listing->price = Input::get('price');
             $date_available = Input::get('date_available');
             $date_unavailable = Input::get('date_unavailable');
             $listing->date_available = $date_available . "-00-00-00";
             $listing->date_unavailable = $date_unavailable . "-00-00-00";
             $listing->location_id = $location->id;
             $listing->timestamp();
             $listing->save();
             // var_dump($_POST);
             // var_dump($listing);
             return Redirect::to("/account/");
         }
         $account = Account::find(Session::get('id'));
         $listing = Listing::find($id);
         $location = Location::find($listing->location_id);
         $locations = $account->locations()->get();
         $categories = Categorie::all();
         $price = $listing->price;
         if ($location->account_id == $account->id) {
             // var_dump($categories);
             $view = View::make('listing.edit.index')->with('title', 'Edit Listing')->with('listing', $listing)->with('location', $location)->with('locations', $locations)->with('account', $account)->with('categories', $categories);
             return $view;
         } else {
             return Response::error('403');
         }
     } else {
         return Redirect::to('/');
     }
 }
function index()
{
    global $twig;
    $categories = new Categorie();
    echo $twig->render('categorie_list.html', array('categories' => $categories->all()));
}