public function update(Request $request) { $id = $request->input('id'); $bids = Bids::find($id); if (!empty($bids)) { $bids->price = $request->input('price'); $bids->text = $request->input('text'); $bids->timestamp = date('Y-m-d H:i:s'); $bids->save(); $comm = new Comm(); $comm->mm = $request->input('mm'); $comm->customer = $request->input('quote_id'); $comm->supplier = Auth::user()->id; $comm->save(); } else { $bids = new Bids(); $bids->quote_id = $request->input('quote_id'); $bids->user_id = $request->input('user_id'); $bids->price = $request->input('price'); $bids->text = $request->input('text'); $bids->timestamp = date('Y-m-d H:i:s'); $bids->save(); $comm = new Comm(); $comm->mm = $request->input('mm'); $comm->customer = $request->input('quote_id'); $comm->supplier = Auth::user()->id; $comm->save(); } return redirect()->action('HomeController@jobs')->with('status', 'Thank you. Your rate has been sent to the move manager.'); }
public function check($bid) { $bid = Bids::findOrFail(Input::get("bid")); $offset = Input::get("offset"); if ($offset < 0) { $now = \Carbon\Carbon::now()->subHours($offset); } else { $now = \Carbon\Carbon::now()->addHours($offset); } if (strtotime($bid->expiration) - strtotime($now) < 0) { //bid is expired if ($bid->amount < $bid->reservedPrice) { //void since bidding price is less then reserved price $bid->delete(); return "Bidding price less then reserved price"; } else { //proceed and Charge //since we get information about expiration from client we have to check it on the server as well //check wether winning user has its card working if ($bid->customerId) { \Stripe\Stripe::setApiKey("sk_test_Z98H9hmuZWjFWfbkPFvrJMgk"); \Stripe\Charge::create(array("amount" => $bid->priceToCents(), "currency" => "usd", "customer" => $bid->customerId)); \Log::info('Charged: ' . $bid->amount); } $bid->complete = 1; $bid->save(); $bid->delete(); } } else { //someone is messing with javascript return "error"; } return "Bidding is valid"; }
/** * Insertion d'une nouvelle enchère dans la BDD * * @param Request $request * @param int $item_id Identifiant de l'item * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector */ public function create(Request $request, $item_id) { $datas = $request->all(); // Création d'une nouvelle enchère $bid = new Bids(); $bid->user_id = Auth::user()->id; $bid->item_id = $item_id; $bid->price = trim($datas['price']); if ($bid->save()) { $request->session()->flash('message', 'success|Votre enchère a bien été saisie !'); } else { $request->session()->flash('message', 'error|Il s\'est passé un truc, dsl'); } return redirect(URL::previous()); }
/** * Define the application's command schedule. * * @param \Illuminate\Console\Scheduling\Schedule $schedule * @return void */ protected function schedule(Schedule $schedule) { // $schedule->command('inspire') // ->hourly(); $schedule->call(function () { $bids = Bids::orderBy('id')->get(); foreach ($bids as $bid) { if (strtotime($bid->expiration) - strtotime(\Carbon\Carbon::now()) < 0) { if ($bid->customerId) { \Stripe\Stripe::setApiKey("sk_test_Z98H9hmuZWjFWfbkPFvrJMgk"); \Stripe\Charge::create(array("amount" => $bid->priceToCents(), "currency" => "usd", "customer" => $bid->customerId)); \Log::info('Charged: ' . $bid->amount); } $bid->delete(); \Log::info('Deleted bid: ' . $bid->id); } } })->everyMinute(); }
public function deleteBid($id) { $bid = Bids::where('product_id', '=', $id); $bid->delete(); return \Redirect::route('admin.products.index')->with('message', 'Bid deleted!'); }
@append @section('content') <h2 class="text-center page-title">Enchères en cours</h2> <hr> <div class="row"> {!! BootForm::open()->action(route('redirect_to'))->method('get')->name('form_sort')->class('form-inline text-right') !!} {!! BootForm::select('Trier par : ', 'url')->options($sortOptionsDefinitions)->select(Request::url()) !!} {!! BootForm::submit('Trier') !!} {!! BootForm::close() !!} </div> <hr> <div class="items-row"> <?php foreach ($items as $item) { $min_price = Bids::getLastBidPriceOrProductPrice($item->id); $min_bid = $min_price + 0.01; $date_end = strtotime($item->date_end); $form_id = 'form_' . $item->id; ?> <div class="item"> <div class="well item--well"> <div class="thumbnail item--thumbnail"> <a href="{{ route('item', ['id' => $item->id]) }}"> <img src="{{ asset(preg_replace('/\.jpg$/', '_thumb.jpg', $item->photo)) }}" title="{{ $item->name }}" alt="Photo vente : {{ $item->name }}"> </a> </div> <div class="caption"> <h3 class="item--name"> <a href="{{ route('item', ['id' => $item->id]) }}" title="{{ $item->name }}">{{ Str::words($item->name, 10) }}</a> <small>({{ $item->category->name }})</small></h3>