Laravel 5.5未定义变量:结果

时间:2018-04-01 12:02:34

标签: php laravel-5

这是PHP:

rclone sync  "C:\my path" "remote":"folder" --log-file "C:\Users\user\Desktop\log.log"  --log-level INFO --delete-after   --exclude "desktop.ini" 

start "" "C:\Users\user\Desktop\some other script.py"

此行发生错误:

    if($criteria == 'schools'){
        $result = $result->where('name', 'LIKE', '%'.$searchItem.'%');
    }elseif($criteria == 'bachelorsdegree'){
        $result = $result->where('undergradcourses', 'LIKE', '%'.$searchItem.'%');
    }elseif($criteria == 'mastersdegree'){
        $result = $result->where('postgradcourses', 'LIKE', '%'.$searchItem.'%');
    }elseif($criteria == 'technicalvocational'){
        $result = $result->where('technicalandvocationalcourses', 'LIKE', '%'.$searchItem.'%');
    }elseif($criteria == 'certificateshortcourse'){
        $result = $result->where('shortcoursesandcertifications', 'LIKE', '%'.$searchItem.'%');
    }

当我拿出这条线时开始:

        $result = $result->where('undergradcourses', 'LIKE', '%'.$searchItem.'%');

问题是:我在主搜索表单中取出了具有searchLocation字段的输入字段,因此当您进行搜索时,我不希望“searchLocation”再次出现在搜索参数中。搜索表单中存在的字段是searchItem,以及学校标准下学位类型的下拉菜单。

有什么想法吗?

编辑:

在添加位置字段和学位类型下拉菜单之前,这是原始代码:

 $result = schools::where('location', 'LIKE', '%'.$searchLocation.'%');

这是我当前的$结果代码(最后一个代码段):

    if($criteria == 'schools'){

    $first=schools::whereRaw("MATCH(name,describtion,school_type) AGAINST('$type')");


    $result=schools::where([

        ['ownership', $ownership],

        ['location',$location],

        ['school_type',$type],

        ])

    ->orwhere([

        ['ownership', $ownership],

        ['location',$location]

        ])

    ->orwhere('fees',$fees)

    ->union($first)

    ->get();

    if(count($result)>0){

    $count=count($result);

    return view('schools', array('result' => $result))->with(array('searchItem'=>$searchItem,'criteria'=>$criteria,'count'=>$count));   

    }

    else{

        return view('schools')->with(array('msg'=>'No result found','count'=>'0','searchItem'=>$searchItem,'criteria'=>$criteria));

    }

0 个答案:

没有答案