小编Ang*_*ons的帖子

使用laravel mix设置外部库

我需要在web包上使用外部库和laravel-mix.在网络包上我应该按照webpack文档中的描述做这样的事情

{
    output: {
        // export itself to a global var
        libraryTarget: "var",
        // name of the global var: "Foo"
        library: "Foo"
    },
    externals: {
        // require("jquery") is external and available
        //  on the global var jQuery
        "jquery": "jQuery"
    }
}
Run Code Online (Sandbox Code Playgroud)

但我可以用laravel mix来做到这一点吗?

webpack laravel-5 laravel-mix

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

违反完整性约束:1452 无法添加或更新子行:外键约束失败(Laravel 应用程序)

我的 Laravel 应用程序中出现此错误。

这些是表格:

邮政

Schema::create('posts', function (Blueprint $table) {
        $table->increments('id');
        $table->string('title');
        $table->text('content');
        $table->timestamps();
        $table->integer('user_id')->unsigned();
});
Run Code Online (Sandbox Code Playgroud)

类别

Schema::create('categories', function (Blueprint $table) {
        $table->increments('id');
        $table->string('name');
        $table->timestamps();
});
Run Code Online (Sandbox Code Playgroud)

Post_Category

Schema::create('post_category', function (Blueprint $table) {
       $table->integer('post_id')->unsigned()->unique()->nullable();
       $table->integer('cat_id')->unsigned()->unique()->nullable();
       $table->timestamps();
});
Run Code Online (Sandbox Code Playgroud)

外键

Schema::table('posts', function (Blueprint $table) {
       $table->foreign('id')->references('post_id')->on('post_category')->onDelete('cascade');
});

Schema::table('categories', function (Blueprint $table) {
      $table->foreign('id')->references('cat_id')->on('post_category')->onDelete('cascade');
});
Run Code Online (Sandbox Code Playgroud)

这是我的模型

class Categorie extends Model
{
    protected $table = 'categories';

    public function posts() {
      return $this->hasMany('App\PostCategory');
    }
}
Run Code Online (Sandbox Code Playgroud)

...

class Post extends Model
{
    public function author() {
      return …
Run Code Online (Sandbox Code Playgroud)

mysql foreign-keys laravel laravel-5.4

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

AngularJS - 在两个控制器之间共享变量

我有两个控制器必须相互通信.第一个引用视频播放器,第二个引用时间线.

从第一个开始,我得到了currentTime视频播放的内容,我希望将其传递给第二个应该在播放视频时移动时间栏的视频.

我尝试使用工厂共享一个time在控制器之间调用的变量,但这在此期间不会改变.

第一控制员:

angular.module('videoCtrl', ['vjs.video'])
  .controller('videoController', ['$scope', 'Timeline', function (scope, Timeline) {
        scope.mediaToggle = {
            sources: [
                {
                    src: 'http://static.videogular.com/assets/videos/videogular.mp4',
                    type: 'video/mp4'
                }
            ],
        };

        //listen for when the vjs-media object changes
        scope.$on('vjsVideoReady', function (e, videoData) {
          videoData.player.on('timeupdate', function () {
            var time = this.currentTime();
            Timeline.setTime(time); // setting the time on factory
          })
        });
    }]);
Run Code Online (Sandbox Code Playgroud)

第二控制器:

angular.module('timelineCtrl', ['mt.media-timeline'])
    .controller('timelineController', function ($scope, Timeline) {
    $scope.time = Timeline.getTime(); // here I'm trying to get the …
Run Code Online (Sandbox Code Playgroud)

angularjs

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