コード例 #1
0
 public function edit_list()
 {
     $list_id = Request::segment(3);
     $list = Lists::find($list_id)->toArray();
     $response_array = array();
     $response_array['list'] = $list;
     $response_array['list']['owner'] = User::find($list['owner_id'])->toArray();
     $response_array['list']['products'] = array();
     $products = DB::table('list_products')->leftJoin('products', 'list_products.product_id', '=', 'products.id')->where('list_products.list_id', $list_id)->select('products.*', 'list_products.quantity')->orderBy('list_products.sort_order')->get();
     if ($products) {
         foreach ($products as $product) {
             $product = json_decode(json_encode($product), true);
             array_push($response_array['list']['products'], $product);
         }
     }
     return View::make('edit_list')->with('data', $response_array)->with('store', $this->store)->with('departments', $this->departments)->with('zipcode', $this->zipcode)->with('city', $this->city)->with('stores', $this->stores);
 }
コード例 #2
0
 public function save_list()
 {
     $id = Input::get('id');
     $list = Lists::find($id);
     if (!$list) {
         $list = new Lists();
     }
     $list->name = Input::get('name');
     $list->description = Input::get('description');
     $list->direction = Input::get('direction');
     $image = Input::file('background_image');
     $validator = Validator::make(array('ima' => $image), array('ima' => 'required|mimes:jpeg,bmp,png'));
     if ($validator->fails()) {
         $error_messages = $validator->messages();
         $response_array = array('success' => false, 'error' => 'Invalid Input', 'error_code' => 401);
         $response_code = 200;
         $message = "Invalid Input File";
         $type = "failed";
         return Redirect::to('/admin/lists')->with('type', $type)->with('message', $message);
     } else {
         if (Input::hasFile('background_image')) {
             $list->background_image_url = upload_image(Input::file('background_image'));
         }
         $list->fav_count = $list->fav_count ? $list->fav_count : 0;
         $list->save();
         $message = "Successfully updated the list";
         $type = "success";
         return Redirect::to('/admin/lists')->with('type', $type)->with('message', $message);
     }
 }
コード例 #3
0
ファイル: index.php プロジェクト: quannguyenngoc/PhotoFun
<?php

require_once 'common.php';
// random image
$id = array_key_exists('id', $_GET) ? $_GET['id'] : 1;
$list = new Lists();
$data['current'] = $list->find('id', $id)->get_array();
$data['next'] = $list->get_next();
$data['previous'] = $list->get_previous();
$c = new Comments($id);
$data['comments'] = $c->get_all();
print $twig->render('index.html', $data);
コード例 #4
0
ファイル: MoviesController.php プロジェクト: huoybb/movie
 public function addToListAction(Movies $movie, $page = 0)
 {
     $this->view->movie = $movie;
     $this->view->page = $this->getPaginator(Lists::find(), 25, $page);
     $this->view->listForm = myForm::buildListForm($movie);
     $this->view->relatedLists = $movie->getRelatedLists();
     $this->view->lists = $movie->getNotRelatedLists($this->view->relatedLists);
 }