我曾经有Angular Stripe Checkout表单,我正在尝试将我的表单更新为最近推出的新Stripe Card Elements.
删除表单输入字段并将其替换为Stripe Card元素后,我的表单如下所示:
<form name="payment" ng-submit="vm.submit()">
<div class="row">
<label for="card-element">
Credit or debit card
</label>
<div id="card-element">
<!-- a Stripe Element will be inserted here. -->
</div>
</div>
<button class="btn btn-primary" type="submit" ng-disabled="vm.submitting">Pay!</button>
<div ng-show="vm.cardError" class="row">
<div class="has-error">
<p class="help-block">* {{vm.cardError}}</p>
</div>
</div>
</form>
Run Code Online (Sandbox Code Playgroud)
以前在角,提交表单的时候,我正在处理submit(),并stripeResponseHandler从控制器.使用新更改更新我的Angular Controller后,我的控制器现在看起来像这样:
function PaymentController() {
var vm = this;
var elements = stripe.elements();
var style = {
base: {
color: '#32325d',
lineHeight: '24px',
fontFamily: 'Helvetica Neue', …Run Code Online (Sandbox Code Playgroud) dom-manipulation angularjs stripe-payments angularjs-directive angular-controller
我必须从一个有 200 万行的表中提取数据。雄辩的查询如下所示:
$imagesData = Images::whereIn('file_id', $fileIds)
->with('image.user')
->with('file')
->orderBy('created_at', 'DESC')
->simplePaginate(12);
Run Code Online (Sandbox Code Playgroud)
中使用的$fileIds数组whereIn可以包含 100 甚至 1000 个文件 ID。
上述查询在小表中工作正常。但是在Images表中有超过 200 万行的生产站点中,需要超过 15 秒才能得到回复。我仅将 Laravel 用于 api。
我已阅读有关此主题的其他讨论。我换paginate()到simplePaginate()。一些人建议也许有一个DB::查询whereRaw可能比whereIn. 有人说这可能是由于处理时 php 中的 PDO 而whereIn有些人建议使用Images::whereIn我已经使用过的。
我使用 MariaDB,将 InnoDB 用于数据库引擎并将其加载到 RAM 中。sql 查询对于所有其他查询都表现良好,但只有那些必须从像这样的大表中收集数据的查询才需要时间。
我如何优化上面的 Laravel 查询,以便在表有数百万行时,如果可能的话,我可以将查询响应减少到几秒钟?
我有一个在该视图中使用父作用域的指令.该指令有一个使用隔离范围的子指令.我试图让父指令观察对子指令的ngModel所做的任何更改,并在更改时更新自己的模态.这是一个可能更好解释的jsfiddle:http://jsfiddle.net/Alien_time/CnDKN/
这是代码:
<div ng-app="app">
<div ng-controller="MyController">
<form name="someForm">
<div this-directive ng-model="theModel"></div>
</form>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
使用Javascript:
var app = angular.module('app', []);
app.controller('MyController', function() {
});
app.directive('thisDirective', function($compile, $timeout) {
return {
scope: false,
link: function(scope, element, attrs) {
var ngModel = attrs.ngModel;
var htmlText = '<input type="text" ng-model="'+ ngModel + '" />' +
'<div child-directive ng-model="'+ ngModel + '"></div>';
$compile(htmlText)(scope, function(_element, _scope) {
element.replaceWith(_element);
});
// Not sure how to watch changes in childDirective's ngModel ???????
}, // …Run Code Online (Sandbox Code Playgroud) javascript angularjs angularjs-directive angularjs-scope angular-ngmodel
我通过composer安装了Laravel 5,安装完成后,App Key自动生成.我去了.env档案,我可以在那里看到APP_KEY.但是,我也注意到里面还有另一个APP_KEY config/app.php:
'key' => env('APP_KEY', 'SomeRandomString'),
'cipher' => 'AES-256-CBC',
Run Code Online (Sandbox Code Playgroud)
我的新手问题是:
1)为什么在2个不同的位置有App键?
2)当生成App Key时,为什么还没有更新config/app.php文件?
3)我是否需要手动将.envApp密钥粘贴到config/app.php文件中,或者只要.env它在那里就没有必要?
4)在将来的更新中,我是否需要继续将App密钥添加到app.php文件中?意思是,它会在更新期间重置吗?
我想在通知电子邮件中添加用户的名字.目前,Laravel通知电子邮件开始如下:
Hello,
Run Code Online (Sandbox Code Playgroud)
我想将其更改为:
Hello Donald,
Run Code Online (Sandbox Code Playgroud)
现在,我有这样的设置.此示例适用于密码重置通知电子邮件:
用户模型:
public function sendPasswordResetNotification($token)
{
$this->notify(new PasswordReset($token));
}
Run Code Online (Sandbox Code Playgroud)
应用程序\声明\ PasswordReset:
class PasswordReset extends Notification
{
use Queueable;
/**
* Create a new notification instance.
*
* @return void
*/
public function __construct()
{
//
}
/**
* Get the notification's delivery channels.
*
* @param mixed $notifiable
* @return array
*/
public function via($notifiable)
{
return ['mail'];
}
/**
* Get the mail representation of the notification.
*
* @param mixed $notifiable
* @return …Run Code Online (Sandbox Code Playgroud) notifications laravel laravel-mail laravel-5.3 laravel-notification
我在Ionic 1(Angular 1.3)中使用Cordova Camera Plugin,我需要将此图像上传到服务器.由于cordova-plugin-file-transfer现在已弃用,建议现在使用xhr上传文件cordova-plugin-file,因此我不知道如何继续.我找不到任何这方面的例子,我读到的链接对我如何上传imageUrl得到的Cordova Camera Plugin 没有帮助.这是我到目前为止:
function openCamera() {
var options = {
quality: 50,
destinationType: Camera.DestinationType.FILE_URI,
sourceType: Camera.PictureSourceType.CAMERA,
allowEdit: true,
encodingType: Camera.EncodingType.JPEG,
mediaType: Camera.MediaType.PICTURE,
correctOrientation: true
}
var func = fileTransfer;
navigator.camera.getPicture(function cameraSuccess(imageUri) {
console.log(imageUri);
// Upload the picture
func(imageUri);
}, function cameraError(error) {
console.debug("Unable to obtain picture: " + error, "app");
}, options);
}
function fileTransfer(imageUri) {
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function (fs) {
console.log('file system open: ' + fs.name); …Run Code Online (Sandbox Code Playgroud) file-upload angularjs cordova ionic-framework cordova-plugins
我正在尝试获取当前页面的 url 并将其存储到我的自定义皮肤模板中的变量中。我正在尝试这样做,以便我可以将此网址用于其他目的。我正在尝试做这样的事情
function currentpageurl() //Some Custom function
{
$url= [something that can get current page's url in mediawiki and store it to this variable]
.....use the $url variable for other purposes....
......
.....
}
Run Code Online (Sandbox Code Playgroud)
Mediawiki 是否有一种方法可以识别当前页面的 url 或者是我查找当前页面的唯一选择是使用这种方法?
$url="http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
Run Code Online (Sandbox Code Playgroud) 我已将字体图标添加到这样的列表中:
a:before {
font-family: FontAwesome;
content: "\f015";
.. etc..
}
Run Code Online (Sandbox Code Playgroud)
当父锚标记悬停时,我想要这样:在伪旋转之前.我尝试过这个,但它不起作用:
a:hover:before {
-webkit-transform:rotate(360deg);
-moz-transform:rotate(360deg);
-o-transform:rotate(360deg);
}
Run Code Online (Sandbox Code Playgroud)
这不行吗?如果父元素悬停,我该怎样才能在:before元素上获得旋转效果?
我在Laravel 5.3中创建了Mailable Class,它调用了视图.但是,我需要将一些变量从我的Controller传递给Mailable类,然后在View中使用这些值.这是我的设置:
控制器:
$mailData = array(
'userId' => $result['user_id'],
'action' => $result['user_action'],
'object' => $result['user_object'],
);
Mail::send(new Notification($mailData));
Run Code Online (Sandbox Code Playgroud)
可邮寄:
class Notification extends Mailable
{
use Queueable, SerializesModels;
protected $mailData;
/**
* Create a new message instance.
*
* @return void
*/
public function __construct($mailData)
{
$this->$mailData = $mailData;
}
/**
* Build the message.
*
* @return $this
*/
public function build()
{
// Array for Blade
$input = array(
'action' => $mailData['action'],
'object' => $mailData['object'],
);
return $this->view('emails.notification') …Run Code Online (Sandbox Code Playgroud) 我在 Laravel + Angular 应用程序中使用 JWT。我看到 Laravel 5.3 具有开箱即用的登录限制功能。但是,在使用 JWT Auth 时如何才能使其发挥作用呢?我有以下代码,但登录限制不起作用。尽管多次失败的尝试,我只收到Invalid Login Details错误,但它没有限制并显示Too many logins错误:
class LoginController extends Controller
{
use AuthenticatesUsers;
protected $maxLoginAttempts=5;
protected $lockoutTime=300;
public function login(Request $request)
{
$credentials = $request->only('email', 'password');
$this->validate($request, [
'email' => 'required',
'password' => 'required',
]);
if ($this->hasTooManyLoginAttempts($request)) {
$this->fireLockoutEvent($request);
return response()->json(['error' => 'Too many logins'], 400);
}
try {
if (! $token = JWTAuth::attempt($credentials)) {
return response()->json(['error' => 'Invalid Login Details'], 401);
}
} catch (JWTException …Run Code Online (Sandbox Code Playgroud) laravel ×5
angularjs ×3
laravel-5 ×3
laravel-5.3 ×3
laravel-mail ×2
composer-php ×1
cordova ×1
css ×1
css3 ×1
eloquent ×1
file-upload ×1
font-awesome ×1
hover ×1
indexing ×1
javascript ×1
jwt ×1
mariadb ×1
mediawiki ×1
php ×1
pseudo-class ×1