【问题标题】:I want to find the value who exist in array我想找到数组中存在的值
【发布时间】:2020-09-14 21:30:51
【问题描述】:

我有 2 个查询,我想知道第一个查询 (dateincal) 中存在的第二个查询的元素 (date_debut)。第二个查询的元素可以在第一个查询中出现一次或多次。 一旦找到日期(日期首次亮相)(dateincal),我希望能够检索找到的元素的其他信息

        $feries = Jourferie::Select('dateincal', 'description')
                    ->where('dateincal', '>=', Carbon::now()->startOfMonth())
                    ->where('dateincal', '<=', Carbon::now()->endOfMonth())
                    ->get();

    $plannings = Planning::Select('date_debut', 'id', 'agent_id', 'site_id')
                 ->where('id', '!=', 0)
                 ->where('statut', 'provisoire')
                 ->get();

【问题讨论】:

    标签: laravel eloquent laravel-query-builder


    【解决方案1】:

    不知道这样能不能帮到你:

    foreach($feries as $ferie){
    
    $myresult = $plannings->contains('date_debut',$ferie->dateincal) 
    /* do things */
    
    }
    

    【讨论】:

    • 感谢您的解决方案,但结果不是我所期望的,当我想要拥有现有值时它返回 true
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-12-24
    • 2021-12-15
    • 1970-01-01
    • 2022-09-22
    • 2020-10-08
    相关资源
    最近更新 更多