小编geo*_*310的帖子

Laravel 5迁移标识符名称太长

我正在尝试运行以下迁移:

public function up()
{
    Schema::create('lifestyle_questions', function(Blueprint $table)
    {
        $table->increments('id');
        $table->string('question');
        $table->timestamps();
    });

    Schema::create('lifestyle_question_answers', function(Blueprint $table)
    {
        $table->increments('id');
        $table->integer('lifestyle_question_id')->unsigned();
        $table->foreign('lifestyle_question_id')->references('id')->on('lifestyle_questions');
        $table->string('answer');
        $table->timestamps();
    });

    Schema::create('user_lifestyle_question_answers', function(Blueprint $table)
    {
        $table->integer('user_id')->unsigned();
        $table->foreign('user_id')->references('id')->on('users');
        $table->integer('lifestyle_question_answer_id')->unsigned();
        $table->foreign('lifestyle_question_answer_id')->references('id')->on('lifestyle_question_answers');
    });
}
Run Code Online (Sandbox Code Playgroud)

但是我收到以下错误:

[Illuminate\Database\QueryException]
SQLSTATE[42000]: Syntax error or access violation: 1059 Identifier name 'user_lifestyle_question_answers_lifestyle_question_answer_id_foreign' is too long (SQL: alter table `user_lifestyle_question_answers` add constraint user_lifestyle_question_answers_lifestyle_question_answer_id_foreign foreign key (`lifestyle_question_answer_id`) references `lifestyle_question_answers` (`id`))

[PDOException]
SQLSTATE[42000]: Syntax error or access violation: 1059 Identifier name 'user_lifestyle_question_answers_lifestyle_question_answer_id_foreign' is too long
Run Code Online (Sandbox Code Playgroud)

php laravel eloquent laravel-5

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

以编程方式而不是CLI运行Laravel 5播种机

有没有办法从PHP内部而不是从命令行运行Laravel 5播种机.我正在使用的托管不允许我使用命令行.只是为了确认我想在我的应用代码中做相同的操作:

php artisan db:seed
Run Code Online (Sandbox Code Playgroud)

php laravel laravel-5

16
推荐指数
3
解决办法
7338
查看次数

如何在Laravel 5.1中向电子邮件添加标题

有没有办法在Laravel 5.1中为所有电子邮件添加默认标头?我希望所有电子邮件都使用以下标头发送:

x-mailgun-native-send: true
Run Code Online (Sandbox Code Playgroud)

php laravel laravel-5

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

htaccess如果声明

我的.htaccess文件中有以下行来选择要使用的PHP版本:

AddType x-httpd-php53 .php
Run Code Online (Sandbox Code Playgroud)

这在实时环境中运行良好,但不适用于测试环境并破坏站点.

有没有办法我可以把它放在if语句或服务器的IP或网站的URL或其他什么东西,以便它只在现场环境中生效?

apache .htaccess

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

如何在Laravel 5请求类中使用有时规则

我有以下请求类:

<?php namespace App\Http\Requests\User;

use App\Http\Requests\Request;
use Validator;
use Session;
use Auth;
use App\User;

class RegisterStep1Request extends Request {

    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Set up the validation rules
     */
    public function rules()
    {
        Validator::extend('valid_date', function($attribute, $value, $parameters)
        {
            $pieces = explode('/', $value);
            if(strpos($value, '/')===FALSE) {
                return false;
            } else {
                if(checkdate($pieces[1], $pieces[0], $pieces[2])) {
                    return true;
                } else …
Run Code Online (Sandbox Code Playgroud)

php laravel laravel-5

13
推荐指数
2
解决办法
7300
查看次数

有没有办法告诉 Chrome 密码生成器网站密码策略?

从我目前的测试来看,Chrome 密码生成器似乎只生成包含大写字母、小写字母和数字的密码,但似乎没有使用特殊字符。如果我正在构建一个具有至少需要一个特殊字符的密码策略的网站,是否有办法让 chrome 了解此策略,以便密码生成器生成符合要求的密码?

html passwords google-chrome

12
推荐指数
1
解决办法
4626
查看次数

在Laravel 5中添加新的配置文件无法正常工作

我希望在我的Laravel 5应用程序中有一个新的配置文件来存储我的所有常量.在浏览网络后,我发现建议的解决方案似乎是创建一个新的配置文件,返回一组键值对然后使用它.所以我创建了以下文件:

<?php
// config/constants.php

return [
    'SITE_NAME' => 'Site Name',
    'SITE_EMAIL' => 'email@site.com',
    'ADMIN_EMAIL' => 'admin@site.com'
];
Run Code Online (Sandbox Code Playgroud)

然后在我的一个控制器中,我尝试访问其中一个值,如下所示:

echo Config::get('constants.ADMIN_EMAIL');
Run Code Online (Sandbox Code Playgroud)

我刚收到以下错误:

FatalErrorException in WelcomeController.php line 46:
Class 'App\Http\Controllers\Config' not found
Run Code Online (Sandbox Code Playgroud)

我是否必须做其他事情才能让它发挥作用?

php laravel laravel-5

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

Laravel 5:如何检索已删除的相关模型?

我有以下型号; 品牌,形象和Image_size.品牌有一个图像,图像有很多image_sizes.所有这些模型都使用软删除,删除方面很好.但是,如果我想恢复已删除的品牌,我还需要恢复相关的图像和image_size模型.

我一直在研究使用模型事件,这样当我的品牌模型被恢复时,我可以获得图像并恢复它,然后我将在图像模型中有类似的事件来获取图像大小并恢复它们.对于品牌而言,我很难获得删除的图像记录.这就是我在品牌模型中尝试做的事情:

/**
 * Model events
 */
protected static function boot() {
    parent::boot();

    /**
     * Logic to run before delete
     */
    static::deleting(function($brand) {
         $brand->image->delete();
    });

    /**
    * Logic to run before restore
    */
    static::restoring(function($brand) {
        $brand = Brand::withTrashed()->with('image')->find($brand->id);
        $brand->image->restore();
    });
}
Run Code Online (Sandbox Code Playgroud)

我只是在尝试还原映像的行上收到以下错误消息:

Call to a member function restore() on a non-object
Run Code Online (Sandbox Code Playgroud)

php laravel laravel-5 laravel-5.1

7
推荐指数
1
解决办法
1165
查看次数

Laravel 5.1会话随机到期

我有一个L5.1应用程序,并遇到会话随机到期的问题.它发生在我的本地环境和实时环境中,因此它看起来不像服务器问题.本地我使用XAMPP与PHP 5.5.11.在实时站点上运行Centos 6的专用服务器,使用PHP 5.6.13.

如果我只是在大约20-30页请求会话丢失后最终浏览网站时会出现问题,因此用户已注销.我正在使用数据库驱动程序,这是我的会话配置:

<?php

return [

    /*
    |--------------------------------------------------------------------------
    | Default Session Driver
    |--------------------------------------------------------------------------
    |
    | This option controls the default session "driver" that will be used on
    | requests. By default, we will use the lightweight native driver but
    | you may specify any of the other wonderful drivers provided here.
    |
    | Supported: "file", "cookie", "database", "apc",
    |            "memcached", "redis", "array"
    |
    */

    'driver' => 'database',

    /*
    |--------------------------------------------------------------------------
    | Session Lifetime
    |--------------------------------------------------------------------------
    |
    | Here you may …
Run Code Online (Sandbox Code Playgroud)

php laravel laravel-5 laravel-5.1

7
推荐指数
1
解决办法
1819
查看次数

Internet Explorer没有抗锯齿旋转图像

我有一个带有背景图像的div,我正在旋转.下面是我的css规则来旋转​​它:

#services_parallax { 
-webkit-transform:rotate(3.1deg); /* Webkit */
transform: rotate(3.1deg); /* firefox & IE9+ */
/* IE7 & 8 */ filter: progid:DXImageTransform.Microsoft.Matrix(M11=0.998537, M12=-0.054079, M21=0.054079, M22=0.998537, sizingMethod='auto expand'); 
}
Run Code Online (Sandbox Code Playgroud)

问题是在IE中,图像的边缘非常块状和锯齿状,而不是光滑的线条,并且似乎没有抗锯齿.有谁知道解决这个问题?它是在chrome中完成的,直到我通过应用-webkit-backface-visibility:hidden;来应用修复程序.哪个适用于chrome,我只需要一个IE的类似修复,如果存在的话.

要复制此问题,请将以下内容粘贴到HTML文件中并在IE中查看:

<style type="text/css"> 
#services_parallax { -webkit-transform:rotate(3.1deg); /* Webkit */ 
    transform: rotate(3.1deg); /* firefox & IE9+ */ 
    /* IE7 & 8 */ filter: progid:DXImageTransform.Microsoft.Matrix(M11=0.998537, M12=-0.054079, M21=0.054079, M22=0.998537, sizingMethod='auto expand'); 
    background: url(http://img.netcarshow.com/Pagani-Zonda_R_2009_1600x1200_wallpaper_01.jpg) center center; 
    background-size:100% auto; 
    height:100px; 
    width:700px; 
    margin-top:50px; 
    margin-left:50px; 
} 
</style> 
<div id="services_parallax"></div>
Run Code Online (Sandbox Code Playgroud)

html css internet-explorer transform rotation

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