public function delete( ReportDetailRequest $request )
{
$id = (int)$request->id;
$customerRecord = CustomerInfo::find($id);
$customerRecord->delete();
}
Run Code Online (Sandbox Code Playgroud)
我目前在 Laravel 应用程序中有上述内容,其中将 DELETE 请求发送到该控制器。目前,正如您所看到的,它非常简单,但查询似乎非常慢。它在 2.23 秒内返回邮递员。我应该怎么做才能加快速度?据我所知,数据库层 (mysql) 确实有一个关于 ID 的索引,并且应用程序没有在调试中运行。这是典型的吗?
编辑:很好地认为请求验证可能正在做某事(它正在验证该用户是否有权删除)。
class ReportDetailRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
$id = (int)$this->route('id');
$customerInfo = CustomerInfo::find($id)->first();
$company = $customerInfo->company_id;
return (auth()->user()->company->id == $company );
}
/**
* Get the validation rules that apply to the request.
* …Run Code Online (Sandbox Code Playgroud) 我已经从我的应用程序创建了日历文件(.ics)输出,以便在日历应用程序(如Google日历)中使用.我通过验证器运行了下面的文件,但似乎谷歌和雅虎日历都没想玩.我的本地Mac日历客户端100%工作.任何人都可以看到下面的文件明显有可能在Google日历中窒息吗?或者他们需要的任何其他字段?我也从雅虎日历中得到500错误.此时撕掉头发.
我曾尝试过有时区信息,也没有时区信息,但似乎并没有多大区别.
标头输出
header('Expires: Sat, 26 Jul 1997 05:00:00 GMT' );
header('Last-Modified: ' . gmdate( 'D, d M Y H:i:s' ) . ' GMT' );
header('Cache-Control: no-store, no-cache, must-revalidate' );
header('Cache-Control: post-check=0, pre-check=0', false );
header('Pragma: no-cache' );
header('Content-type: text/calendar;');
header('Content-Disposition: inline; filename="calendar.ics"');
header("Content-Description: File Transfer");
header("Content-Transfer-Encoding: binary");
header("Content-Length: " . strlen($generated));
Run Code Online (Sandbox Code Playgroud)
UTC时间或TZID我已经尝试过,似乎没有什么区别.如果有人有一个非常简单的.ics事件的URL示例,似乎工作"跨日历"很想看到它.或者,如果某人可以为此目的提供一些体面的库,并不是很难集成到CakePHP项目中,那就足够了.
BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//MS//NONSGML//EN
X-WR-CALNAME:Holidays
CALSCALE:GREGORIAN
METHOD:PUBLISH
BEGIN:VEVENT
UID:1075
DTSTART;TZID=Europe/London:20150114T080000
DTEND;TZID=Europe/London:20150114T170000
DTSTAMP:20150114T080000Z
CREATED:20151019T211433Z
DESCRIPTION:Stat Holiday (1.0 days)
LAST-MODIFIED:20150114T080000Z
LOCATION:
SUMMARY: Statutory Day
SEQUENCE:0
STATUS:CONFIRMED
TRANSP:OPAQUE
END:VEVENT
BEGIN:VEVENT
UID:1076 …Run Code Online (Sandbox Code Playgroud) 我正在使用Laravel 5.4和Dingo API,我正在尝试使用Laravel的OAuth 2.0(Passport)来处理Internal Dingo请求.以前,我使用的是JWT,但现在我想使用OAuth.这是我之前的调度程序代码,它传递了所需的令牌以对内部请求执行身份验证.
public function getDispatcher()
{
$token = JWTAuth::fromUser(Auth::user());
return $this->api->header('Authorization','Bearer'.$token)->be(Auth::user());
}
Run Code Online (Sandbox Code Playgroud)
现在我正在使用OAuth进行身份验证,我的JavaScript代码只需在JavaScript中使用此方法传递cookie即可获得身份验证,这非常有效.
现在我需要修改getDispatcher()方法以在Dingo中的"内部请求"上获取OAuth令牌.有没有人有关于如何做到这一点的任何提示?从理论上讲,我可以为每个用户创建一个个人访问令牌,但这似乎只是内部请求的过度杀伤.任何建议或方法表示赞赏.如何在不通过完整OAuth流程的情况下获取OAuth令牌,或者如何仅为内部请求关闭身份验证.
根据以下答案更新:
'api.auth'自己在路线上(只是Dingo)并且内部请求有效.auth:api(Passport)+ api.auth我得到了内部请求不允许的方法,它以JSON的形式返回.尝试调用内部POST请求时出现{"message":"405 Method Not Allowed"}.(当尝试POST到这些路由时,看起来像301重定向到登录页面,反过来导致API路径以某种方式变成GET,从而抛出405错误).
通过Postman的API请求以反向容量工作.两个活动时都找不到用户(['middleware'=> ['auth:api','api.auth'])当(auth:api只是Passport)激活时它工作正常.
哪个会更快.
1)循环datareader并基于填充的数据表创建自定义行和列
2)或者创建一个dataAdapter对象并且只是(填充)一个数据表.
在动态创建数据表时,数据加载器的性能是否仍然适用?
它是留在这里,还是作为一个"我太"的产品,这个东西被迅速推出,以回应Rails社区?
是否有必要通过学习曲线,并且框架是否只会以这种方式工作,而没有Page back模型?
如果是这样,哪里是获取.NET的MVC基础知识的最佳位置?
我已经在网上快速浏览了Joel Birch实施的Superfish菜单,该菜单适用于onclick,而不是悬停.
在Github找到了Karl Swedberg的这个链接,看起来像票.
https://gist.github.com/917446
它就像一个魅力,直到我点击一个活动的链接,此时菜单关闭,似乎返回false.
如何让它导航到实际的链接目的地?
作为表格的结果,我正在尝试保存新的品牌记录.在我看来,Gender是一个下拉列表,返回一个Integer,它是从ViewData填充的("性别")
我按如下方式设置了我的链接:
gID = CInt(Request.Form("Gender"))
Brand.GenderReference.EntityKey = New EntityKey("DB_ENTITIES.Gender", "Id", gID)
TryUpdateModel(Brand)
DB.SaveChanges()
Run Code Online (Sandbox Code Playgroud)
这导致以下错误.
Entities in 'DB_ENTITIES.Brand' participate in the 'FK_Brand_Gender' relationship. 0 related 'Gender' were found. 1 'Gender' is expected.
Run Code Online (Sandbox Code Playgroud)
有人可以用简单的英语向我解释参数.我也尝试过DB.Gender作为第一个参数,但没有快乐.
我目前正在尝试使用Laravel Cashier在React应用程序中处理Billing。使用要求3D安全的测试卡(直接从Stripes文档中提取)(4000000000003220)时,我会IncompletePayment exception抛出异常。
如文档中所述,这显然是正常的:https : //laravel.com/docs/6.x/billing#payments-requiring-additional-confirmation
try {
$subscription = $user->newSubscription('default', $planId)
->create($paymentMethod);
} catch (IncompletePayment $exception) {
return redirect()->route(
'cashier.payment',
[$exception->payment->id, 'redirect' => route('home')]
);
}
Run Code Online (Sandbox Code Playgroud)
现在,Laravel建议我在这种情况下转到他们的“确认”页面。但是,这就是我的困惑所在。首先,我已经通过我的React应用程序中的Stripe Elements向客户询问了他们的信用卡,因此转发到从Laravel生成的服务器端页面可能很难。我想在我的React Application中优雅地处理所有这些。
在将任何内容发送到服务器之前(通过Stripe Elements javascript已经为我处理过),我还已经通过上述弹出窗口确认了该卡对3D安全有效。因此文档说明:
在付款确认页上,将提示客户再次输入其信用卡信息,并执行Stripe要求的任何其他操作,例如“ 3D Secure”确认。
似乎无论如何这都是重复。有人可以指导我在这种情况下需要做什么吗?松散地在我的React App中,我做了以下工作:
生成服务器端的意图,然后将其触发以做出反应:在计费过程中:
stripe.confirmCardSetup(
billingStatus.paymentIntent.client_secret,
{
payment_method: {
card: card,
billing_details: {
name: 'Jenny Rosen'
}
}
}
)
.then((res)=>{
console.log(res);
processPayment( res );
});
Run Code Online (Sandbox Code Playgroud)
流程Payment方法命中服务器:
var data = new FormData();
data.append( "coreId", plan.id );
data.append( "productId", plan.product_id );
data.append( "planId", …Run Code Online (Sandbox Code Playgroud) php laravel stripe-payments laravel-cashier react-stripe-elements
我正在使用 Rollup 将表单组件的共享库放在一起,该库使用 Formik 作为基础层。我目前收到以下“调度程序”的编译错误,它由 Formik 在后台使用。
我尝试将它作为单独的 npm 依赖项手动安装,但仍然出现以下错误。
[!] Error: 'unstable_runWithPriority' is not exported by node_modules/formik/node_modules/scheduler/index.js
https://rollupjs.org/guide/en/#error-name-is-not-exported-by-module
node_modules/formik/dist/formik.esm.js (9:9)
7: import toPath from 'lodash-es/toPath';
8: import invariant from 'tiny-warning';
9: import { unstable_runWithPriority, LowPriority } from 'scheduler';
Run Code Online (Sandbox Code Playgroud)
遵循汇总文档:我尝试使用 rollup.config.js 的命名导出部分,例如:
plugins: [
peerDepsExternal(),
postcss({ extract: true, plugins: [autoprefixer] }),
json({ include: 'node_modules/**' }),
babel({ exclude: 'node_modules/**', presets: ['@babel/env', '@babel/preset-react'] }),
localResolve(),
resolve({dedupe: [ 'react', 'react-dom' ]}),
commonjs({
namedExports: {
// left-hand side can be an absolute path, a …Run Code Online (Sandbox Code Playgroud) 我正在学习 Vue atm,但我无法通过 Vue Routes 在子组件和父组件之间传递道具。我有一个 Layout 组件,它有一个包装 DIV,如下所示:
<template>
<div class="container" v-bind:class="cssClass">
<router-view></router-view>
</div>
</template>
<script>
export default {
name: 'Layout',
props: ['cssClass']
}
</script>
Run Code Online (Sandbox Code Playgroud)
我在我的基本 App JS 中定义了我的路线,如下所示。所以我对第一次加载的看法是“容器动画”类,一切都很好。
const router = new VueRouter({
routes: [
{ path: '/', component: Layout, props: { cssClass: 'container-animated' },
children: [
{ path: '', component: Homepage },
{ path: '/hello-world', component: HelloWorldPage, props: { cssClass: '' } }
]
},
]
});
Run Code Online (Sandbox Code Playgroud)
但是,一旦我点击 /hello-world 路线,我想将一个空的 cssClass 道具传递给 Layout,(HelloWorldPage 当前嵌套在其中) - 我该怎么做?道具甚至是实现这一目标的机制吗?
laravel ×3
php ×3
javascript ×2
performance ×2
.net ×1
asp.net-mvc ×1
calendar ×1
dataadapter ×1
datareader ×1
datatable ×1
dingo-api ×1
entity ×1
entitykey ×1
foreign-keys ×1
formik ×1
jquery ×1
laravel-5 ×1
menu ×1
mysql ×1
oauth ×1
reactjs ×1
rollupjs ×1
superfish ×1
timezone ×1
vue-router ×1
vue.js ×1
vuejs2 ×1