本文整理汇总了PHP中Response函数的典型用法代码示例。如果您正苦于以下问题:PHP Response函数的具体用法?PHP Response怎么用?PHP Response使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Response函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: porCategoria
public function porCategoria($id)
{
$subcategorias = Subcategoria::where('categoria_id', '=', $id)->get()->toArray();
//$subcategorias_lists = $subcategorias::lists('descricao', 'id');
return Response()->json($subcategorias)->header('Access-Control-Allow-Origin', "*");
//return Response()->make($subcategorias);
}
示例2: index
public function index()
{
$user = $this->user->selectAll();
//dd($comment);
//return Response()->json(['name' => 'Seild', 'state' => 'Hyed']);
return Response()->json($user);
}
示例3: index
public function index()
{
//$comments = $this->comment->selectAll();
//return Response()->json(['name' => 'Seild', 'state' => 'Hyed']);
$commments = $this->comment->getAll();
return Response()->json($commments);
}
示例4: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @param string|null $guard
* @return mixed
*/
public function handle($request, Closure $next, $guard = null)
{
if (!Auth::check()) {
return Response()->json(ResponseManager::getError('', 401, 'You are not authorized to access this. Plese login.'));
}
return $next($request);
}
示例5: handle
public function handle($request, Closure $next)
{
if ($request->user() == null || !$request->user()->est_adm()) {
return Response("Accès interdit");
}
return $next($request);
}
示例6: getCost
public function getCost(Request $request)
{
$credentials = new Aws\Credentials\Credentials(env('AWS_KEY'), env('AWS_SECRET'));
$client = Ec2Client::factory(array('credentials' => $credentials, 'version' => 'latest', 'region' => $request->input('region')));
$terminate = Carbon::parse($request->input('terminateTime'));
$terminateTime = Carbon::parse($request->input('terminateTime'));
$terminate->minute = 00;
$terminate->second = 00;
$terminate->addHour();
$launch = Carbon::parse($request->input('launchTime'));
$launchTime = Carbon::parse($request->input('launchTime'));
$launch->minute = 00;
$launch->second = 00;
//$client = \AWS::createClient('ec2');
$result = $client->describeSpotPriceHistory(['AvailabilityZone' => $request->input('availabilityZone'), 'DryRun' => false, 'StartTime' => $launch, 'EndTime' => $terminate, 'InstanceTypes' => [$request->input('instanceType')], 'ProductDescriptions' => ['Linux/UNIX']]);
$total_cost = 0.0;
$total_seconds = $launch->diffInSeconds($terminate);
$total_hours = $total_seconds / (60 * 60);
$last_time = $terminate;
$computed_seconds = 0;
foreach ($result['SpotPriceHistory'] as $price) {
$price['SpotPrice'] = floatval($price['SpotPrice']);
$available_seconds = new Carbon($last_time = $price['Timestamp']);
$available_seconds = $available_seconds->diffInSeconds(Carbon::createFromTimestamp(0));
$remaining_seconds = $total_seconds - $computed_seconds;
$used_seconds = min($available_seconds, $remaining_seconds);
$total_cost = $total_cost + $price['SpotPrice'] / (60 * 60) * $used_seconds;
$computed_seconds = $computed_seconds + $used_seconds;
$last_time = $price['Timestamp'];
}
return Response(['TotalCost' => $total_cost, 'PaidHours' => $launch->diffInSeconds($terminate) / (60 * 60), 'ActualHours' => $launchTime->diffInSeconds($terminateTime) / (60 * 60)]);
}
示例7: rncStad
/**
*Devuelve un pdf con todos los datos
*estadisticos del Reg, de tumores del año
*y del mes que se pase
*responde a @GET /reporte/estadisticas/rncs
*/
public function rncStad(Request $data)
{
//Reglas de validacion
$rules = ['year' => 'required', 'mon' => 'required|numeric|min:1|max:12'];
/*
*Valida datos segun las reglas $rules
*y genera mensajes segun $messages
*/
$validator = Validator::make($data->all(), $rules, $this->messages);
/*
*Si hay error en los datos,
*regresa el primer mensaje de
*error
*/
if ($validator->fails()) {
//Primer mensaje de error
$errMessage = $validator->errors()->first();
return Response()->json(['status' => 'danger', 'message' => $errMessage]);
} else {
$year = $data->year;
$mon = '0' . $data->mon;
$date = $year . '-' . $mon;
$mons = ['ENERO', 'FEBRERO', 'MARZO', 'ABRIL', 'MAYO', 'JUNIO', 'JULIO', 'AGOSTO', 'SEPTIEMBRE', 'OCTUBRE', 'NOVIEMBRE', 'DICIEMBRE'];
$mo = $mons[$mon - 1];
$registers = DB::table('rncs')->where('fec_reg', 'like', $date . '%')->select('reg_rgn', 'nom_pri', 'nom_seg', 'ape_pri', 'ape_seg', 'sex', 'eda_adm', 'prc_edo', 'mun_prc', 'des_ltg', 'cod_ltg', 'sco_ltg', 'des_morf', 'cod_morf', 'fec_fall', 'qui_otra', 'num_his')->get();
$man = DB::table('rncs')->where('fec_reg', 'like', $date . '%')->where('sex', 'MASCULINO')->count();
$girl = DB::table('rncs')->where('fec_reg', 'like', $date . '%')->where('sex', 'FEMENINO')->count();
$view = \View::make('pdfs.rncStad', compact('registers', 'year', 'mo', 'man', 'girl'))->render();
$pdf = \App::make('dompdf.wrapper');
$pdf->loadHTML($view)->setPaper('latter')->setOrientation('landscape');
return $pdf->stream('invoice');
}
}
示例8: getsuma
public function getsuma($valor1, $valor2)
{
$total = $valor1 + $valor2;
$array = ['valor1' => $valor1, 'valor2' => $valor2, 'total' => $total];
//return view('operacion.suma', compact('total','valor1', 'valor2'));
//return view('operacion.suma');
return Response()->json($array);
}
示例9: get
function get($query = null)
{
if ($query == null) {
return false;
}
$search = new GlobalSearch();
Response($search->do_search($query));
}
示例10: getDetailsPage
/**
* @param $idSKu
* @return \Dingo\Api\Http\Response
*/
public function getDetailsPage($idSKu)
{
$product = $this->integrator->getDetailPage($idSKu);
if (!$product) {
throw new StoreResourceFailedException('Product not found');
}
return Response()->json($product);
}
示例11: getFeaturedProducts
/**
* @param Request $request
* @return \Symfony\Component\HttpFoundation\Response
*/
public function getFeaturedProducts(Request $request)
{
try {
$products = $this->integrator->getFeatureds($request);
return Response()->json($products);
} catch (\Exception $e) {
throw new StoreResourceFailedException($e->getMessage());
}
}
示例12: getWhoBougthAlsoBougth
/**
* @return \Symfony\Component\HttpFoundation\Response
*/
public function getWhoBougthAlsoBougth(Request $request)
{
try {
$recommendations = $this->integrator->getWhoViewAlsoView($request);
return Response()->json($recommendations);
} catch (\Exception $e) {
throw new StoreResourceFailedException($e->getMessage());
}
}
示例13: getForm
public function getForm($id_campagne)
{
$campagne = Campagne::find($id_campagne);
if ($campagne != null) {
return view('image_creation', array('campagne' => $campagne));
} else {
return Response("Stop pirater");
}
}
示例14: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
$api_key = Input::get('api_key');
if ($api_key != '2') {
return Response()->json(array('message' => 'There is no api key!'), 404);
} else {
return $next($request);
}
}
示例15: getDepartamento
public function getDepartamento($id)
{
$insumo = Departamento::where('id', $id)->first();
if (!$insumo) {
return Response()->json(['status' => 'danger', 'menssage' => 'Este departamento no existe']);
} else {
return $insumo;
}
}