小编Lov*_*ock的帖子

检测CKEditor的焦点

试图解决问题在IOS设备上键盘破坏固定元素.

单击CKEditor文本区域时,我的目标是将该固定元素的样式设置为固定.

但是不确定如何检测CKEditor的焦点.

我没有尝试过任何工作,这里是基本的:

http://jsfiddle.net/B4yGJ/180/

CKEDITOR.replace('editor1');

$('#editor1').focus(function() {
  alert('Focused');
});
Run Code Online (Sandbox Code Playgroud)

html javascript jquery ckeditor

6
推荐指数
1
解决办法
5976
查看次数

Laravel 5 - 将用户模型移动到应用程序/模型导致自动加载问题

处理包含两个User模型的继承的Laravel Spark项目.

一个是App目录中的标准Spark模型,另一个是App/Models内部.我已经将两个模型结合起来并更新了auth.php以引用Models目录中的User模型,但是composer dump-autoload却说它无法找到App/User模型.

如何告诉自动装带器用户模型不再存在,而是在Models目录中?

编辑:

我已将命名空间更改为App/Models但仍收到错误:

class_parents(): Class App\User does not exist and could not be loaded
Run Code Online (Sandbox Code Playgroud)

在我的终端上运行dump-autload时

第二编辑:

修复过,没有意识到命名空间被引用了这么多.在App\User上找到并替换并对问题进行了排序.

php autoload laravel laravel-5 laravel-spark

6
推荐指数
1
解决办法
1103
查看次数

exif 数据中没有方向 - PHP 图像上传

一直试图检测从 iPhone 上传的图像的图像方向,然后从中调整它们的方向。

我正在尝试解决在 potrait 中拍摄的图像以 -90 度旋转上传的问题。我尝试了许多不起作用的 switch 语句,所以决定在我的 JSON 返回中返回 exif 数据。

我看到的问题是它们在 exif 数据中没有方向。

我这样做:

$imagefile = $fileToUpload["tmp_name"];
$destinationImage = imagecreatefromstring(file_get_contents($imagefile));
$exif = exif_read_data($imagefile);
$moveUploadedFile = imagejpeg($destinationImage, $this->uploadDir . "/" . $newFileName, 100);
imagedestroy($destinationImage);

if ($moveUploadedFile) {
  $return['ort'] = $exif;
  echo json_encode($return);
}
Run Code Online (Sandbox Code Playgroud)

我在返回(使用萤火虫)中看到的是:

FileName:"phpUQZFHh"
FileDateTime:1410465904
FileSize:473421
FileType:2
MimeType:"image/jpeg"
SectionsFound:"COMMENT"

Computed: OBJECT:
Height:700
Width:933
IsColor:1

Comment: ARRAY:
0:"CREATOR: gd-jpeg v1.0 (using IJG JPEG v62), quality = 100"
Run Code Online (Sandbox Code Playgroud)

我希望能够像这样使用 exif 数据:

    if (!empty($exif['Orientation'])){
        //get the orientation
        $ort = …
Run Code Online (Sandbox Code Playgroud)

php gd exif image-processing ios

5
推荐指数
1
解决办法
2752
查看次数

警告:要求(...):无法打开流:中没有这样的文件或目录

刚刚将我的 Laravel 站点移至我的实时服务器,并立即面临此错误。

完整的错误是:

Warning: require(/var/sites/b/beta.buildsanctuary.com/public_html/local/bootstrap/../vendor/autoload.php): failed to open stream: No such file or directory in /var/sites/b/beta.buildsanctuary.com/public_html/local/bootstrap/autoload.php on line 17

Fatal error: require(): Failed opening required '/var/sites/b/beta.buildsanctuary.com/public_html/local/bootstrap/../vendor/autoload.php' (include_path='.:/usr/local/lib/php') in /var/sites/b/beta.buildsanctuary.com/public_html/local/bootstrap/autoload.php on line 17
Run Code Online (Sandbox Code Playgroud)

第 17 行是:

需要目录.'/../vendor/autoload.php';

文件夹结构为:

beta.buildsanctuary.com
  -- public_html
  -- subdomains
    -- beta
      -- local
        -- bootstrap
        -- vendor
Run Code Online (Sandbox Code Playgroud)

这哪里出错了有什么帮助吗?以及如何修复?尝试各种路径拉我的头发。

谢谢,克雷格。

php require laravel

5
推荐指数
2
解决办法
4万
查看次数

检测当前页面是否为Web根目录

如果当前页面是根"/",则寻找通过PHP检查的最简单方法

我只想在我的网站的根目录上显示某个元素,但是使用刀片模板并在模板中为所有页面设置了这个元素.

谢谢.

例如

<?php
  if ($page == $root) {
    // show
  }
?>
Run Code Online (Sandbox Code Playgroud)

如果它有助于我使用Laravel 4.2.

php laravel

5
推荐指数
4
解决办法
8569
查看次数

使用Axios取消Vue.js中的多个API调用

我正在使用一个带有多个"模块"的仪表板,每个模块都有自己的API调用.大多数端点很快,但有一些可能需要几秒钟.

我有一个日期范围的过滤选项,每次更改时我都会运行数据的API调用.

问题是,如果用户在其他人加载之前不断快速更改日期范围,我不希望用户能够堆叠API调用.

我使用单个文件vue组件,并为每个API调用提供一个方法,然后使用一个方法对这些组进行分组和调用.

watch: {
    dateFilter: function() {
        this.initStatModules();
    }
},
methods: {
    getCustomers: function() {
        var $this = this;
        return axios.get(`/api/v1/reports/${$this.team.id}/stats-dashboard/customers?date=${$this.dateFilter}`).then(function(response) {
            $this.customers = response.data;
        });
    },
    getBookings: function() {
        var $this = this;
        return axios.get(`/api/v1/reports/${$this.team.id}/stats-dashboard/bookings`).then(function(response) {
            $this.bookings = response.data;
        });
    },
    getTotalRevenue: function() {
        var $this = this;
        return axios.get(`/api/v1/reports/${$this.team.id}/services-revenue?date=${$this.dateFilter}`).then(function(response) {
            $this.totalRevenue = response.data.data.totalRevenue;
        });

    },
    initStatModules: function() {
        this.getCustomers();
        this.getBookings();
        this.getTotalRevenue();
    }
}
Run Code Online (Sandbox Code Playgroud)

我希望能够做的是取消watch或initStatModules方法中的所有挂起的API请求.

看看axios docs:https://github.com/axios/axios#cancellation它是受支持的,但是我无法理解如何按照自己的意愿实现它.

谢谢!

ajax vue.js axios vuejs2

5
推荐指数
1
解决办法
1783
查看次数

Laravel Eloquent -created_at 是 X 天前

我有一系列的日子想要检查以 Laravel Spark 结束的试验:

$trialIntervals = [10, 5, 3, 1, 0];
Run Code Online (Sandbox Code Playgroud)

我获取所有团队,然后使用 diffInDays 检查他们的 Trial_ends_at 日期是否为间隔之一:

$daysTillTrialEnds = Carbon::parse($team->trial_ends_at)->diffInDays(Carbon::now());
Run Code Online (Sandbox Code Playgroud)

然后,我检查该值是否已经是数据库和间隔中的现有结果:

if ( in_array($daysTillTrialEnds, $trialIntervals) && !TrialEndingNotification::where('team_id', $team->id)->where('days_notified_at', $daysTillTrialEnds)->count() ) {

   // not yet been added to db

}
Run Code Online (Sandbox Code Playgroud)

我有一个名为“days_notified_at”的字段,我正在使用该字段检查我是否已添加该行并通知客户。然而,该字段再也不会使用,我宁愿引用created_at日期并删除该字段。

我的问题是我基本上是如何做到这一点的:

->where(Carbon::parse('created_at')->diffInDays(Carbon::now()), $daysTillTrialEnds)
Run Code Online (Sandbox Code Playgroud)

没有出现此错误:

DateTime::__construct(): Failed to parse time string (created_at) at position 0 (c): The timezone could not be found in the database
Run Code Online (Sandbox Code Playgroud)

目的是 where 将仅显示created_at 日期为 X 天前的行。

php sql laravel eloquent laravel-5

5
推荐指数
1
解决办法
1万
查看次数

Laravel - 没有安装Imagick

使用Laravel并尝试使用Imagine处理图像上传.

问题是我收到错误说明:

Imagine \ Exception \ RuntimeException

Imagick not installed
Open: /Applications/MAMP/htdocs/laravelcms/vendor/imagine/imagine/lib/Imagine/Imagick/Imagine.php

{
/**
* @throws RuntimeException
*/
public function __construct()
{
if (!class_exists('Imagick')) {
throw new RuntimeException('Imagick not installed');
}
Run Code Online (Sandbox Code Playgroud)

我按照本指南,正确创建了所有文件夹和文件等,如下所述:

http://creolab.hr/2013/07/image-manipulation-in-laravel-4-with-imagine/

我还检查了Imagick文件夹,所有文件等都在正确的位置.

有帮助吗?

谢谢,克雷格.

php imagick laravel laravel-4 php-imagine

4
推荐指数
2
解决办法
1万
查看次数

在路由中使用资源时使用Controller中的自定义功能 - Laravel

正在使用Laravel构建框架网站并在用户系统上工作.

我通过资源路由使用控制器:

Route::resource('user', 'UserController');
Run Code Online (Sandbox Code Playgroud)

这适用于控制器中所有正常的创建,索引,存储等功能.

对于我的注册表格,这是开场白:

{{ Form::open(array('route' => 'user.store', 'class'=>'small-form form-holder')) }}
Run Code Online (Sandbox Code Playgroud)

想想这有多好,我在UserController中创建了一个登录函数,并尝试使用我的登录表单:

{{ Form::open(array('route' => 'user.login', 'class'=>'small-form form-holder')) }}
Run Code Online (Sandbox Code Playgroud)

但是,这会返回未定义错误的路由.这是因为我设置的资源路径吗?我知道我可以设置一个使用控制器登录方法的自定义路由,但我喜欢这种做事方式.

php model-view-controller routes laravel laravel-4

4
推荐指数
1
解决办法
7941
查看次数

雄辩的sortBy-指定asc或desc

尝试对我雄辩的收藏进行排序:

$collection->sortBy('field');
Run Code Online (Sandbox Code Playgroud)

Laravel 4的文档中没有有关如何为这种排序方法选择降序或升序的信息。

可能吗?

php arrays eloquent laravel-4

4
推荐指数
3
解决办法
2万
查看次数