本文整理匯總了PHP中Song::whereRaw方法的典型用法代碼示例。如果您正苦於以下問題:PHP Song::whereRaw方法的具體用法?PHP Song::whereRaw怎麽用?PHP Song::whereRaw使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Song
的用法示例。
在下文中一共展示了Song::whereRaw方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: store
/**
* Store a newly created song in storage.
*
* @return Response
*/
public function store()
{
// Set rules for validator
$rules = array("artist" => "required", "title" => "required", "requester" => "required", "link" => "required|url");
// Validate input
$validator = Validator::make(Input::all(), $rules);
if ($validator->fails()) {
// TODO: Remember form input...
return Redirect::to('song/create')->withErrors($validator, "song");
}
// Create new song
$song = Input::all();
// Set or unset remember cookie
if (isset($song['remember-requester'])) {
$cookie = Cookie::make("requester", $song['requester']);
} else {
$cookie = Cookie::forget("requester");
}
$artist = DB::getPdo()->quote($song['artist']);
$title = DB::getPdo()->quote($song['title']);
if (Song::whereRaw("LOWER(artist) = LOWER({$artist}) AND LOWER(title) = LOWER({$title})")->count() > 0) {
return Redirect::to('song/create')->with('error', "HEBBEN WE AL!!!")->withCookie($cookie);
}
Song::create($song);
// Set success message
$msg = "Gefeliciteerd! Je nummer is aangevraagd :D";
// Redirect to song index page with message and cookie
return Redirect::to("/")->with("success", $msg)->withCookie($cookie);
}