Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/273.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 拉雷维尔有很多没有身份证的人_Php_Mysql_Laravel_Eloquent - Fatal编程技术网

Php 拉雷维尔有很多没有身份证的人

Php 拉雷维尔有很多没有身份证的人,php,mysql,laravel,eloquent,Php,Mysql,Laravel,Eloquent,我在一个有很多关系的中面临一个非常奇怪的问题, 它没有给我任何回报,所以我开始挖掘,试图找到一些东西 现在我有了这个代码 知道它为什么不起作用吗?我在很多地方都有很多关系,从来没有遇到过这个问题 谢谢请确保您已妥善提供了一切;例如,item\u id应该位于相关表GS\u menu\u menu\u categories中,并且应该包含一个id主键,或者如果它们不同,您可以指定两者,即: class Item extends Eloquent { protected $table =

我在一个有很多关系的
中面临一个非常奇怪的问题,
它没有给我任何回报,所以我开始挖掘,试图找到一些东西

现在我有了这个代码

知道它为什么不起作用吗?我在很多地方都有很多关系,从来没有遇到过这个问题


谢谢

请确保您已妥善提供了一切;例如,
item\u id
应该位于相关表
GS\u menu\u menu\u categories
中,并且应该包含一个
id
主键,或者如果它们不同,您可以指定两者,即:

class Item extends Eloquent {

    protected $table = 'items';

    public function menuMenuCategories(){
        // if GS_menu_menu_categories has "the_id" instead of "id" as pk
        return $this->hasMany('MenuMenuCategory','item_id', 'the_id');
    }
}
像这样使用它:

$item = Item::with('menuMenuCategories')->find(1); // the item with id 1
使用以下命令访问相关的模型集合

$menuMenuCategories = $item->menuMenuCategories;

$item->menuMenuCategories->first(); // get the first one
$item->menuMenuCategories->get(1); // get the second one
$item->menuMenuCategories->get(2); // get the third one
不要使用此选项:

    $item->menuMenuCategories()
因此,例如,在视图(
非刀片
)中:


确保你已经妥善提供了一切;例如,
item\u id
应该位于相关表
GS\u menu\u menu\u categories
中,并且应该包含一个
id
主键,或者如果它们不同,您可以指定两者,即:

class Item extends Eloquent {

    protected $table = 'items';

    public function menuMenuCategories(){
        // if GS_menu_menu_categories has "the_id" instead of "id" as pk
        return $this->hasMany('MenuMenuCategory','item_id', 'the_id');
    }
}
像这样使用它:

$item = Item::with('menuMenuCategories')->find(1); // the item with id 1
使用以下命令访问相关的模型集合

$menuMenuCategories = $item->menuMenuCategories;

$item->menuMenuCategories->first(); // get the first one
$item->menuMenuCategories->get(1); // get the second one
$item->menuMenuCategories->get(2); // get the third one
不要使用此选项:

    $item->menuMenuCategories()
因此,例如,在视图(
非刀片
)中:


嘿谢谢您的回答,问题正是您提到的,使用$item->menuMenuCategories而不是$item->menuMenuCategories()!嘿谢谢您的回答,问题正是您提到的,使用$item->menuMenuCategories而不是$item->menuMenuCategories()!