我一直关注http://laravelcode.com/post/how-to-integrate-paypal-payment-gateway-in-laravel-54
上的教程我现在正试图在我正在开发的应用程序中使用它,但我对PHP / Laravel很新,所以试图将这些paypal函数放入我自己的Controller / Forms中已经建成了。
我有一个控制器" BookingsController"在../bookings/create上有一个表格,当欧盟按下提交按钮时,它会将信息输入数据库,这是完美的,然后运行PayPal位以将欧盟带到PayPal结账,这是我和#39;我来了。
我的控制器: -
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Market;
use App\Stall;
use App\Booking;
use Auth;
use GuzzleHttp\Transaction;
class BookingsController extends Controller
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
//
}
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public function create()
{
$market = Market::where('is_active', true)->orderBy('name')->pluck('name','id');
$stall = Stall::pluck('name','id')->all();
return view ('bookings.create', compact('market','stall'));
}
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
$this->validate($request, [
'name' => 'required',
'email' => 'email',
'address' => 'required',
'phone' => 'required',
]);
//Uncomment the below line to test form values
// return $request->all();
$booking = new Booking;
$booking->name = $request->input('name');
$booking->email = $request->input('email');
$booking->address = $request->input('address');
$booking->phone = $request->input('phone');
$booking->market_id = $request->input('market_id');
$booking->stall_id = $request->input('stall_id');
$booking->itemtype = $request->input('itemtype');
$booking->clothesrail = $request->input('clothesrail');
$booking->businessname = $request->input('businessname');
$booking->insurance = $request->input('insurance');
//Get the stall cost
//$stallPrice = Stall::pluck('cost')->where('id', '=', $booking->stall_id);
$stallPrice = 15;
//Check if the user is logged in. If so then submit the user_id
if (Auth::check())
{
$booking->user_id = auth()->user()->id;
}
//return $stallPrice;
//$booking->save();
//Redirect user based on logged in session_status
if (Auth::check())
{
return redirect('/dashboard')->with('success', 'Stall Booked!');
}
return redirect('/confirm')->with('success', 'Stall Booked!');
}
/**
* Display the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function show($id)
{
//
}
/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function edit($id)
{
$booking = Booking::find($id);
return view('bookings.edit')->with('booking', $booking);
}
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @return \Illuminate\Http\Response
*/
public function update(Request $request, $id)
{
$this->validate($request, [
'name' => 'required',
'email' => 'email',
'address' => 'required',
'phone' => 'required',
]);
$booking = Booking::find($id);
$booking->name = $request->input('name');
$booking->email = $request->input('email');
$booking->address = $request->input('address');
$booking->phone = $request->input('phone');
$booking->market_id = $request->input('market_id');
$booking->stall_id = $request->input('stall_id');
$booking->itemtype = $request->input('itemtype');
$booking->clothesrail = $request->input('clothesrail');
$booking->businessname = $request->input('businessname');
$booking->insurance = $request->input('insurance');
//Check if the user is logged in. If so then submit the user_id
if (Auth::check())
{
$booking->user_id = auth()->user()->id;
}
$booking->save();
return redirect('/admin/dashboard')->with('success', 'Booking Updated');
}
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function destroy($id)
{
$booking = Booking::find($id);
$booking->delete();
return redirect('/admin/dashboard')->with('success', 'Booking Removed');
}
}
我的观点与表格: -
@extends('layouts.app')
@section('content')
<div class="row">
<div class="col-md-8 col-md-offset-2">
<div class="panel panel-default">
<div class="panel-heading">Book a Stall</div>
<div class="alert alert-info" role="alert">Clothes Rails are not provided. You will need to provide this yourself.</div>
<div class="panel-body">
{!!Form::open(['action' => 'BookingsController@store','method' => 'POST'])!!}
@if (Auth::check())
{{Form::bsText('name',Auth::user()->name)}}
{{Form::bsText('email',Auth::user()->email)}}
{{Form::bsText('address',Auth::user()->address)}}
{{Form::bsText('phone',Auth::user()->phone)}}
@else
{{Form::bsText('name','',['placeholder' => 'Name'])}}
{{Form::bsText('email','',['placeholder' => 'Email'])}}
{{Form::bsText('address','',['placeholder' => 'Address'])}}
{{Form::bsText('phone','',['placeholder' => 'Phone'])}}
@endif
<div class="form-group">
{!! Form::label('market_id', 'Date:') !!}
{!! Form::select('market_id', $market , null, ['class'=>'form-control'])!!}
</div>
<div class="form-group">
{!! Form::label('stall_id', 'Type of stall:') !!}
{!! Form::select('stall_id', $stall , null, ['id' => 'stall_id', 'class'=>'form-control'])!!}
</div>
{{Form::bsText('itemtype','',['placeholder' => 'Type of items to sell'])}}
<div class="form-group">
{!! Form::label('clothesrail', 'Clothes Rail?:') !!}
{!! Form::label('clothesrail', 'Yes') !!}
{!! Form::radio('clothesrail', 1, ['class'=>'form-control'])!!}
{!! Form::label('clothesrail', 'No') !!}
{!! Form::radio('clothesrail', 0, ['class'=>'form-control'])!!}
</div>
<div class="form-group">
{!! Form::label('businessname', 'Business Name:') !!}
{!! Form::text('businessname', null, ['id' => 'businessname', 'class'=>'form-control hidden'])!!}
</div>
<div class="form-group">
{!! Form::label('insurance', 'Public Liability Insurance??:') !!}
{!! Form::label('insurance', 'Yes') !!}
{!! Form::radio('insurance', 1, ['id' => 'insurance', 'class'=>'form-control'])!!}
{!! Form::label('insurance', 'No') !!}
{!! Form::radio('insurance', 0, ['id' => 'insurance', 'class'=>'form-control'])!!}
</div>
{{Form::bsSubmit('Submit')}}
{!! Form::close() !!}
</div>
</div>
</div>
</div>
@endsection
注意:
答案 0 :(得分:1)
只需改变:
var a = Observable.Interval(TimeSpan.FromSeconds(1))
.Take(3) //causes termination after 3 values
.MaxBy(o => o)
.Publish();
以强>
$stallPrice = Stall::pluck('cost')->where('id', '=', $booking->stall_id);
在这里,您需要使用实际的停顿表名称$stallPrice = DB::table('your_stall_table')->find($booking->stall_id)->cost;
。