本文整理汇总了PHP中Song::create方法的典型用法代码示例。如果您正苦于以下问题:PHP Song::create方法的具体用法?PHP Song::create怎么用?PHP Song::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Song
的用法示例。
在下文中一共展示了Song::create方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例2: Song
<?php
//ini_set("display_errors", 1);
require __DIR__ . '/autoload.php';
//create new Songs
$model = new Song();
$model->status = 2;
$model->rate = 66;
$model->save(3);
$model = new Song(['title' => 'I can teach you', 'artist' => 'bon jovi', 'status' => 1]);
$model->create();