0
我想在此代碼塊使用AND
以及&&
:Laravel運算符AND/&& - 如何使用它們?
public function show($id)
{
$user = Auth::user()->id;
$userEmail = Auth::user()->email;
$share = Share::where('sbj_id', $id)->first();
if ($share->sbj_id == $id && $share->email == $userEmail) {
$items = Item::where('project_id', $id)
->orderBy("created_at", "desc")
->groupBy('label_name')
->get();
$sbj = Sbj::find($id);
$allSbj = Sbj::where('user_id', $user)->orderBy("created_at", "desc")->get();
$labels = Label::all();
$pages = Page::where('project_id', $id)->orderBy('created_at', 'desc')->get();
$people = Friend::where('sbj_id', $id)->orderBy("created_at", "desc")->get();
$myPeeps = Contact::where('my_id', $user)->get();
return View::make('sbjs.show', compact('sbj', 'pages', 'labels', 'people', 'myPeeps', 'allSbj', 'items'));
} else {
return Redirect::action ('[email protected]');
}
}
不過,我看網上,看是否&&
或AND
在Lavavel支持在這方面,但沒有成功。我的應用正在將用戶帶到ELSE
操作。
任何想法?
&&和AND是PHP本身的一部分,不僅僅是Laravel ...我會檢查$ userEmail和$ share-> email的值是你期望的... – Jon