コード例 #1
0
 /**
  * Resource create view
  * GET         /resource/create
  * @return Response
  */
 public function create()
 {
     $exist = $this->model->where('cat_status', 'close')->first();
     if ($exist) {
         return Redirect::route($this->resource . '.newCat', $exist->id);
     } else {
         $model = $this->model;
         $model->name = '';
         $model->sort_order = '';
         $model->save();
         return Redirect::route($this->resource . '.newCat', $model->id);
     }
 }
コード例 #2
0
 public function postComment($slug)
 {
     // Get comment
     $content = e(Input::get('content'));
     // Check word
     if (mb_strlen($content) < 3) {
         return Redirect::back()->withInput()->withErrors($this->messages->add('content', '评论不得少于3个字符。'));
     }
     // Find article
     $job = $this->model->where('slug', $slug)->first();
     // Create comment
     $comment = new JobComment();
     $comment->content = $content;
     $comment->job_id = $job->id;
     $comment->user_id = Auth::user()->id;
     if ($comment->save()) {
         // Create success
         // Updated comments
         $job->comments_count = $job->comments->count();
         $job->save();
         // Return success
         return Redirect::back()->with('success', '评论成功。');
     } else {
         // Create fail
         return Redirect::back()->withInput()->with('error', '评论失败。');
     }
 }
コード例 #3
0
 /**
  * Resource edit view
  * GET         /resource/{id}/edit
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     $data = $this->model->find($id);
     $categoryLists = TravelCategories::lists('name', 'id');
     $travel = $this->model->where('slug', $data->slug)->first();
     return View::make($this->resourceView . '.edit')->with(compact('data', 'categoryLists', 'travel'));
 }
コード例 #4
0
 /**
  * Resource create view
  * @param  int $id post ID
  * @return response
  */
 public function newPost($id)
 {
     $data = $this->model->find($id);
     $categoryLists = Category::lists('name', 'id');
     $article = $this->model->where('id', $id)->first();
     return View::make($this->resourceView . '.create')->with(compact('data', 'categoryLists', 'article'));
 }
コード例 #5
0
 /**
  * Show search result
  * @return response
  */
 public function search()
 {
     $query = $this->model->where('post_status', 'open')->orderBy('created_at', 'desc');
     $categories = TravelCategories::where('cat_status', 'open')->orderBy('sort_order')->get();
     // Get search conditions
     switch (Input::get('target')) {
         case 'title':
             $title = Input::get('like');
             break;
     }
     // Construct query statement
     isset($title) and $query->where('title', 'like', "%{$title}%")->orWhere('content', 'like', "%{$title}%");
     $datas = $query->paginate(6);
     return View::make('travel.search')->with(compact('datas', 'categories'));
 }
コード例 #6
0
 /**
  * Action: Seller send goods with express
  * @return Response
  */
 public function sendGoods()
 {
     // Get all form data.
     $data = Input::all();
     $rules = array('id' => 'required', 'express_name' => 'required', 'invoice_no' => 'required');
     // Custom validation message
     $messages = array('express_name.required' => '请填写物流公司名称', 'invoice_no.required' => '请填写物流单号');
     // Begin verification
     $validator = Validator::make($data, $rules, $messages);
     if ($validator->passes()) {
         $product_order = $this->model->find(Input::get('id'));
         $product_order->is_express = true;
         $product_order->express_name = Input::get('express_name');
         $product_order->invoice_no = Input::get('invoice_no');
         // Alipay Dualfun API
         require_once app_path('api/alipay/alipay.config.php');
         require_once app_path('api/alipay/lib/alipay_submit.class.php');
         $trade_no = $this->model->where('id', Input::get('id'))->first()->alipay_trade;
         // Alipay trade number (required)
         $logistics_name = Input::get('express_name');
         // Express company name (required)
         $invoice_no = Input::get('invoice_no');
         // Express billing number
         $transport_type = "EXPRESS";
         // Express type: POST, EXPRESS or EMS
         // Constructs an array of arguments to request, no need to change
         $parameter = array("service" => "send_goods_confirm_by_platform", "partner" => trim($alipay_config['partner']), "trade_no" => $trade_no, "logistics_name" => $logistics_name, "invoice_no" => $invoice_no, "transport_type" => $transport_type, "_input_charset" => trim(strtolower($alipay_config['input_charset'])));
         // Establishment request
         $alipaySubmit = new AlipaySubmit($alipay_config);
         $html_text = $alipaySubmit->buildRequestHttp($parameter);
         $doc = new DOMDocument();
         $doc->loadXML($html_text);
         $product_order->save();
         return Redirect::back()->with('success', '<strong>发货成功!等待对方确认收货。</strong>');
     } else {
         return Redirect::back()->withInput()->withErrors($validator);
     }
 }
コード例 #7
0
 /**
  * View: User timeline
  * @return Respanse
  */
 public function getTimeline($id)
 {
     $timeline = $this->model->where('user_id', $id)->paginate(8);
     $user = User::where('id', $id)->first();
     return View::make('timeline.timeline')->with(compact('timeline', 'user'));
 }
コード例 #8
0
ファイル: Repository.php プロジェクト: vinelab/agency
 /**
  * Remove a selected record.
  *
  * @param  string $key
  * @return boolean
  */
 public function remove($key)
 {
     $record = $this->model->where($this->model->getKeyName(), $key)->findOrFail($key);
     return $record->delete();
 }
コード例 #9
0
 /**
  * Action: Show page post action
  * @return Response
  */
 public function postAction($slug)
 {
     $postComment = e(Input::get('postComment'));
     if ($postComment) {
         // Get comment
         $content = e(Input::get('content'));
         // Check word
         if (mb_strlen($content) < 3) {
             return Redirect::back()->withInput()->withErrors($this->messages->add('content', '评论不得少于3个字符。'));
         }
         // Find article
         $product = $this->model->where('slug', $slug)->first();
         // Create comment
         $comment = new ProductComment();
         $comment->content = $content;
         $comment->product_id = $product->id;
         $comment->user_id = Auth::user()->id;
         if ($comment->save()) {
             // Create success
             // Updated comments
             $product->comments_count = $product->comments->count();
             $product->save();
             // Return success
             return Redirect::back()->with('success', '评论成功。');
         } else {
             // Create fail
             return Redirect::back()->withInput()->with('error', '评论失败。');
         }
     } else {
         $data = Input::all();
         $rules = array('quantity' => 'required|integer', 'product_id' => 'required', 'price' => 'required', 'seller_id' => 'required', 'inventory' => 'required');
         if (e($data['inventory']) < e($data['quantity'])) {
             return Redirect::back()->with('error', '<strong>请输入正确的' . $this->resourceName . '购买数量</strong>');
         } elseif (Auth::user()->id == e($data['seller_id'])) {
             return Redirect::back()->with('error', '<strong>您不能购买自己出售的商品</strong>');
         } else {
             // Custom validation message
             $messages = $this->validatorMessages;
             // Begin verification
             $validator = Validator::make($data, $rules, $messages);
             if ($validator->passes()) {
                 // Verification success
                 // Add recource
                 $model = new ShoppingCart();
                 $model->buyer_id = Auth::user()->id;
                 $model->quantity = e($data['quantity']);
                 $model->product_id = e($data['product_id']);
                 $model->price = e($data['price']);
                 $model->payment = e($data['quantity']) * e($data['price']);
                 $model->seller_id = e($data['seller_id']);
                 if ($model->save()) {
                     // Add success
                     return Redirect::back()->with('success', '<strong>' . $this->resourceName . '已添加到购物车:</strong>您可以继续选购' . $this->resourceName . ',或立即结算。');
                 } else {
                     // Add fail
                     return Redirect::back()->withInput()->with('error', '<strong>' . $this->resourceName . '添加到购物车失败。</strong>');
                 }
             } else {
                 // Verification fail
                 return Redirect::back()->withInput()->withErrors($validator);
             }
         }
     }
 }
コード例 #10
0
ファイル: InviteRepository.php プロジェクト: TorchSK/woofyard
 public function getInvite($code)
 {
     return $this->model->where('code', '=', $code)->first();
 }
コード例 #11
0
ファイル: Repository.php プロジェクト: adibhanna/agency
 /**
  * Remove a selected record.
  *
  * @param  string $key
  * @return boolean
  */
 public function remove($key)
 {
     return $this->model->where($this->model->getKeyName(), $key)->delete();
 }