コード例 #1
0
ファイル: CouponController.php プロジェクト: sientong/tagin
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function edit($id)
 {
     $categories = Category::lists('name', 'id');
     $merchants = Merchant::lists('name', 'id');
     $coupon = Coupon::find($id);
     return view('admin.coupon.update', compact('categories', 'merchants'))->with('coupon', $coupon);
 }
コード例 #2
0
ファイル: CustomerController.php プロジェクト: EDDYMENS/Zowy
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     if (session('user')) {
         //$customers = Customer::orderBy('id', 'desc')->paginate(10);
         $customers = Merchant::find(session('user'))->customers()->orderBy('id', 'desc')->paginate(10);
         return view('customers.index', compact('customers'));
     } else {
         return back();
     }
 }
コード例 #3
0
ファイル: routes.php プロジェクト: sientong/tagin
*/
use App\Coupon;
use App\Article;
use App\Merchant;
use App\Category;
Route::get('/', function () {
    $merchants = Merchant::all()->take(12);
    $coupons = Coupon::select('coupons.*', 'merchants.logo', 'merchants.name as merchantName')->join('merchants', 'coupons.merchant_id', '=', 'merchants.id')->orderBy('created_at', 'desc')->take(8)->get();
    $articles = Article::orderBy('created_at', 'desc')->take(8)->get();
    return view('welcome')->with('coupons', $coupons)->with('merchants', $merchants)->with('articles', $articles);
});
Route::post('infos/uploadImage', ['as' => 'image.upload', 'uses' => 'ArticleController@uploadImage']);
Route::get('image/browse', ['as' => 'image.browse', 'uses' => 'ArticleController@browseImage']);
Route::get('/category', function () {
    $categories = Category::all()->where('type', 'shopping');
    $merchants = Merchant::all();
    return view('coupon.category')->with('categories', $categories)->with('merchants', $merchants);
});
Route::get('/merchant/{name}', array('uses' => 'MerchantController@showList'));
Route::get('/category/{name}', array('uses' => 'CategoryController@showCategory'));
Route::get('/modal/{id}', array('uses' => 'CategoryController@showCategoryModal'));
Route::get('/about', function () {
    return view('about');
});
Route::get('/legal', function () {
    return view('legal');
});
Route::get('/login', function () {
    return view('login');
});
Route::get('/article', function () {
コード例 #4
0
 public function addBusStop(Request $request, $id)
 {
     $input = $request->all();
     $agent = Merchant::find($id);
     if (isset($input['type']) && $input['type'] == 'genticket') {
         $validator = Validator::make($request->all(), ["terminal_id" => "required", "ticket_type" => "required"]);
         if ($validator->fails()) {
             if ($request->ajax()) {
                 return response()->json($validator->messages());
             } else {
                 return \Redirect::back()->withErrors($validator)->withInput();
             }
         }
         //$input = $request->all();
         $stack = new Ticketstack();
         $stack->batch_code = Ticket::stackCode();
         $stack->created_at = date("Y-m-d H:i:s");
         $stack->save();
         $ticket = new Ticket();
         $terminal = Busstop::where("id", "=", trim($input['terminal_id']))->first();
         $count = $input['qty'];
         $account = Account::where("app_id", "=", $input['app_id'])->first();
         for ($k = 1; $k <= $count; $k++) {
             $time = time();
             DB::table('ticketseed')->insert(['code' => $time]);
             $mid = DB::table("ticketseed")->max("id");
             //$amount   =  ($input['ticket_type'] == 1) ? $terminal->one_way_to_fare : $terminal->one_way_from_fare ;
             $amount = 1000;
             Ticket::insert(array("code" => $ticket->ticketCode($mid), "account_id" => $account->id, "app_id" => $input['app_id'], "agent_id" => $id, "serial_no" => $ticket->uniqueID($mid), "terminal_id" => $terminal->id, "stack_id" => $stack->id, "route_id" => $input['route_id'], "amount" => $amount, "ticket_type" => $input['ticket_type']));
         }
         $account->balance += $amount * $input['qty'];
         $agent->balance += $amount * $input['qty'];
         $account->update();
         $agent->update();
     } else {
         $account = new Account();
         $mid = Account::uniqueID() + 1;
         $terminal_id = DB::table("busstops")->where("short_name", "=", $input['short_name'])->pluck("id");
         $account->merchant_id = $input['merchant_id'];
         $account->busstop_id = $terminal_id;
         $m = $account->merchant_id + $mid;
         $realid = uniqid($m);
         $realid = substr($realid, -1, 5);
         $realid = $realid . str_pad($mid, 5, 0, STR_PAD_LEFT);
         $account->account_id = uniqid($m);
         if ($account->save()) {
             return response()->json("record saved successfully");
         }
     }
 }
コード例 #5
0
ファイル: MerchantController.php プロジェクト: sientong/tagin
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $merchant = Merchant::findOrFail($id);
     $merchant->delete();
     return Redirect::route('admin.merchant.index');
 }
コード例 #6
0
ファイル: ProductController.php プロジェクト: EDDYMENS/Zowy
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     $product = Merchant::find(session('user'))->products->find($id);
     if (!is_null($product)) {
         $product = Product::findOrFail($id);
         return view('products.edit', compact('product'));
     } else {
         return back();
     }
 }
コード例 #7
0
ファイル: TeleBot.php プロジェクト: EDDYMENS/Zowy
 public function products($telegramid)
 {
     if ($telegramid != $this->support_channel) {
         $merchant = Merchant::where('chat_id', $telegramid)->first();
         if ($merchant) {
             $products = $merchant->products()->get();
             $reponse = [];
             $reponse['status_code'] = "200";
             $reponse['state'] = "true";
             $reponse['message'] = "Products retrived successfully ";
             $reponse['products'] = $products;
             return $reponse;
         } else {
             $reponse = [];
             $reponse['status_code'] = "400";
             $reponse['state'] = "false";
             $reponse['message'] = "Merchant does not exist";
             return $reponse;
         }
     } else {
         $reponse = [];
         $reponse['status_code'] = "211";
         $reponse['state'] = "false";
         $reponse['message'] = "You need to link your store to your telegram channel. Type /register to get started";
         return $reponse;
     }
 }