本文整理汇总了PHP中Album::create方法的典型用法代码示例。如果您正苦于以下问题:PHP Album::create方法的具体用法?PHP Album::create怎么用?PHP Album::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Album
的用法示例。
在下文中一共展示了Album::create方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testRemoveTrackFromAlbum
public function testRemoveTrackFromAlbum()
{
$album = Album::create('id', 'Album name');
$album->addTrack(Track::create('id', 'Track name'));
$album->removeTrack(Track::create('id', 'Track name'));
$this->assertCount(0, $album->getTracks());
}
示例2: testCreateAlbum
public function testCreateAlbum()
{
$album = Album::create('My Album');
$album2 = Album::byId($album->getId());
$this->assertEquals($album->getId(), $album2->getId());
$this->assertEquals($album->getName(), $album2->getName());
}
示例3: testRemoveAlbumFromArtist
public function testRemoveAlbumFromArtist()
{
$artist = Artist::create('id', 'Artist name');
$artist->addAlbum(Album::create('id', 'Album name'));
$artist->removeAlbum(Album::create('id', 'Album name'));
$this->assertCount(0, $artist->getAlbums());
}
示例4: run
public function run()
{
$faker = Faker::create();
$usersId = DB::table('users')->lists('id');
for ($i = 0; $i < rand(10, 20); $i++) {
Album::create(['name' => $faker->word(), 'owner_id' => $usersId[rand(0, sizeof($usersId) - 1)]]);
}
}
示例5: testAssignToAlbum
public function testAssignToAlbum()
{
$album = Album::create('My temporary album name');
$media = MediaObject::create('path/to');
$album->addObject($media);
foreach ($album->getObjects() as $object) {
$this->assertEquals($media->getId(), $object->getId());
$this->assertEquals($media->uri(), $object->uri());
}
}
示例6: create
/**
* Create a new Album
*
* @param int $categoryId
*
* @return \Illuminate\View\View | \Illuminate\Http\RedirectResponse
*/
public function create($categoryId)
{
$category = Category::findOrFail($categoryId);
if (Request::isMethod('GET')) {
return View::make('album.create', compact('category'));
} elseif (Request::isMethod('POST')) {
$validator = Validator::make(Input::all(), Album::$rules);
if ($validator->fails()) {
return Redirect::back()->withErrors($validator)->withInput();
}
Album::create(['category_id' => $categoryId, 'name' => Input::get('name')]);
return Redirect::to('/categories/' . $categoryId . '/albums')->with('success', 'Album created');
}
}
示例7: run
public function run()
{
Album::create(['user_id' => '1', 'title' => '戏剧人生,人生戏剧']);
Album::create(['user_id' => '1', 'title' => '戏剧人生,人生戏剧']);
Album::create(['user_id' => '1', 'title' => '戏剧人生,人生戏剧']);
Album::create(['user_id' => '1', 'title' => '戏剧人生,人生戏剧']);
Album::create(['user_id' => '2', 'title' => '戏剧人生,人生戏剧']);
Album::create(['user_id' => '2', 'title' => '戏剧人生,人生戏剧']);
Album::create(['user_id' => '2', 'title' => '戏剧人生,人生戏剧']);
Album::create(['user_id' => '2', 'title' => '戏剧人生,人生戏剧']);
Album::create(['user_id' => '3', 'title' => '戏剧人生,人生戏剧']);
Album::create(['user_id' => '3', 'title' => '戏剧人生,人生戏剧']);
Album::create(['user_id' => '3', 'title' => '戏剧人生,人生戏剧']);
Album::create(['user_id' => '3', 'title' => '戏剧人生,人生戏剧']);
Album::create(['user_id' => '4', 'title' => '戏剧人生,人生戏剧']);
Album::create(['user_id' => '4', 'title' => '戏剧人生,人生戏剧']);
Album::create(['user_id' => '4', 'title' => '戏剧人生,人生戏剧']);
Album::create(['user_id' => '4', 'title' => '戏剧人生,人生戏剧']);
}
示例8: Album
<?php
require_once 'config.php';
require_once 'Album.php';
if (isset($_POST['submit'])) {
$album = new Album($_POST['album_title'], $_POST['date'], $_POST['format']);
$album->create();
}
?>
<html>
<head>
<title>Albums</title>
</head>
<body>
<form method="POST" action="">
Enter the name of your album:
<input type="text" name="album_title"></input>
Enter the release date:
<input type="date" name="date"></input>
Enter the album format:
<input type="text" name="format"></input>
<input type="submit" name="submit" value="submit"></input>
</form>
<?php
if (isset($album)) {
?>
<p>The last album entered was "<?php
echo $album->album_title;
?>
示例9: intval
<?php
include 'models.php';
if (isset($_POST['id'])) {
$a = Album::find($_POST['id']);
$a->Title = $_POST['title'];
$a->Artist = intval($_POST['artist']);
if ($a->save()) {
header("Location: " . "album.php?id=" . $a->AlbumId);
}
} else {
$a = Album::create($_POST['title'], intval($_POST['artist']));
if ($a->save()) {
header("Location: " . "album.php?id=" . $a->AlbumId);
}
}
示例10: isset
<!DOCTYPE html>
<script src="//code.jquery.com/jquery-1.11.3.min.js"></script>
<script type="text/javascript">
</script>
<?php
include 'models.php';
$album = isset($_GET['id']) ? Album::find($_GET['id']) : Album::create(null, 1);
?>
<html lang="en">
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" integrity="sha512-dTfge/zgoMYpP7QbHy4gWMEGsbsdZeCXz7irItjcC3sPUFtf0kuFbDz/ixG7ArTxmDjLXDmezHubeNikyKGVyQ==" crossorigin="anonymous">
<title>New Album</title>
</head>
<body>
<div class="container">
<div class="jumbotron">
<h1>Nuevo Album</h1>
<p></p>
</div>
<div class="row">
<div class="col-md-3 col-md-offset-4 col-xs-5 col-xs-offset-2 col-sm-4 col-sm-offset-4 ">
<form action="guardar_album.php" method="POST">
<?php
if (isset($album->AlbumId)) {
?>
<label for="id">Id</label>
<input type="text" <?php
echo "value='{$album->AlbumId}'";