繁体   English   中英

如何在Laravel中为两种不同类型的用户提供相同的功能?

[英]How can I give two different types of users the same functionality in Laravel?

我想为两种不同类型的用户提供创建相同事件的能力,但是事件需要user_id,这两种不同类型的用户可以共享。

我正在Laravel中创建一个应用程序,其中两个不同类型的用户,即播放器和供应商,每个都可以创建一个事件。

播放机

Schema::create('players', function (Blueprint $table) {
            $table->increments('id');
            $table->string('first_name');
            $table->string('last_name');
            $table->integer('player_id_type')->default('1');
            $table->unsignedBigInteger('player_id');
            $table->string('email')->unique();
            $table->string('password');
            $table->rememberToken();
            $table->timestamps();
        });

供应商

Schema::create('vendors', function (Blueprint $table) {
            $table->increments('id');
            $table->string('store name');
            $table->string('email')->unique();
            $table->string('password');
            $table->rememberToken();
            $table->timestamps();
        });

事件

Schema::create('events', function (Blueprint $table) {
            $table->increments('id');
            $table->string('user_id');
            $table->string('name')
        });

问题是玩家和供应商都可以拥有id = 1.此外,在创建事件时,我不知道是否要查找具有该ID或供应商的玩家。

请关于如何解决这个问题或以不同方式实施它的一些建议。

谢谢。

存在冲突,在重新检索'event'实体时,你有两个相同主键的表而不是表引用user_id? 因此,您可以添加第三个名为user的表,并与事件相关联,以便减少冲突

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM