本文整理汇总了PHP中Artist::create方法的典型用法代码示例。如果您正苦于以下问题:PHP Artist::create方法的具体用法?PHP Artist::create怎么用?PHP Artist::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Artist
的用法示例。
在下文中一共展示了Artist::create方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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());
}
示例2: artist_store
public function artist_store()
{
//die('artist store');
$data = Input::all();
$validator = Validator::make($data, Artist::rules());
if ($validator->passes()) {
$artist = Artist::create($data);
if ($artist) {
return Redirect::route('music-artist')->with('message', 'New artist added successfully')->with('type', 'success');
} else {
return Redirect::route('music-artist')->with('message', 'An error occured while saving the record. Please try again later')->with('type', 'danger');
}
} else {
return Redirect::route('music-artist')->withInputs()->withErrors($validator)->with('message', 'Invalid entries. Please try again later')->with('type', 'danger');
}
}
示例3: postAddArtist
public function postAddArtist()
{
$validator = Validator::make(Input::all(), Artist::$rules);
if ($validator->fails()) {
return Redirect::route('partner-add')->withErrors($validator)->withInput();
}
$user_id = Auth::user()->id;
$artist = Artist::create(array('name' => Input::get('name'), 'credentials' => Input::get('credentials'), 'description' => Input::get('description'), 'user_id' => $user_id, 'permalink' => Tools::permalink(Input::get('name'))));
if (Input::hasFile('cover_image')) {
$cover_image = Media::addMedia('cover_image', $artist, $user_id, 'partner-add');
}
if (Input::hasFile('inside_image')) {
$inside_image = Media::addMedia('inside_image', $artist, $user_id, 'partner-add');
}
$artist->update(array('cover_image' => $cover_image, 'inside_image' => $inside_image));
$artist->save();
return Redirect::route('artists-show-single', $artist->permalink)->with('status', 'alert-success')->with('global', 'You have successfully added a new artist/partner.');
}
示例4: create
public function create()
{
if ($this->request()->isPost()) {
$artist = Artist::create(array_merge($this->params()->artist, ['updater_ip_addr' => $this->request()->remoteIp(), 'updater_id' => current_user()->id]));
if ($artist->errors()->blank()) {
$this->respond_to_success("Artist created", ['#show', 'id' => $artist->id]);
} else {
$this->respond_to_error($artist, ['#create', 'alias_id' => $this->params()->alias_id]);
}
} else {
$this->artist = new Artist();
if ($this->params()->name) {
$this->artist->name = $this->params()->name;
$post = Post::where("tags.name = ? AND source LIKE 'http%'", $this->params()->name)->joins('JOIN posts_tags pt ON posts.id = pt.post_id JOIN tags ON pt.tag_id = tags.id')->select('posts.*')->first();
if ($post && $post->source) {
$this->artist->urls = $post->source;
}
}
if ($this->params()->alias_id) {
$this->artist->alias_id = $this->params()->alias_id;
}
}
}
示例5: htmlspecialchars
* @author Antoine De Gieter
*
*/
if (isset($_POST['add_artist']) && isset($_POST['name']) && isset($_POST['biography']) && isset($_SESSION['online']) && $_SESSION['online']) {
$picture = htmlspecialchars($_POST['picture']);
$name = utf8_decode(htmlspecialchars($_POST['name']));
$biography = utf8_decode(trim(htmlspecialchars($_POST['biography'])));
$picture_name = explode(".", $_FILES["picture"]["name"]);
$extension = end($picture_name);
if (is_uploaded_file($_FILES["picture"]["tmp_name"]) && isset($_FILES["picture"]) && $_FILES["picture"]['error'] === 0 && in_array($extension, $allowed_extensions)) {
$picture_name = strtolower(normalize(preg_replace("/[ '\"\\/]/", "", $name))) . '.' . $extension;
$tmp_name = $_FILES["picture"]["tmp_name"];
$path = "./img/artists/" . $picture_name;
move_uploaded_file($tmp_name, $path);
$_SESSION['artistAdded'] = true;
Page::goArtist(Artist::create($name, $biography, $_SESSION['user']->getId(), $picture_name));
} else {
$_SESSION['error'] = true;
}
}
#Process add album
/**
*
* @author Antoine De Gieter
*
*
*/
if (isset($_POST['album_name']) && isset($_POST['disc']) && isset($_POST['release_date']) && isset($_POST['type'])) {
$db = $_SESSION['db'];
$album_name = utf8_decode(trim(htmlspecialchars($_POST['album_name'])));
$disc = utf8_decode(trim(htmlspecialchars($_POST['disc'])));
示例6: header
<?php
include 'models.php';
if (isset($_POST['id'])) {
$a = Artist::find($_POST['id']);
$a->Name = $_POST['name'];
if ($a->save()) {
header("Location: " . "artist.php?id=" . $a->ArtistId);
}
} else {
$a = Artist::create($_POST['name']);
if ($a->save()) {
header("Location: " . "artist.php?id=" . $a->ArtistId);
}
}
示例7: isset
var uno = !!document.forms["formulario"]["name"].value; //Esta es la representación booleana de la cadena
if (
uno &&
(isNaN(document.forms["formulario"]["name"].value))
) {
return true;
}else{
return false;
};
}
</script>
<?php
include 'models.php';
$artist = isset($_GET['id']) ? Artist::find($_GET['id']) : Artist::create(null);
?>
<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 Artist</title>
</head>
<body>
<div class="container">
<div class="jumbotron">
<h1>Nuevo Artista</h1>
</div>
<div class="row"> <!--Sección para hacer el formulario en medio de la pantalla-->
示例8: Artist
<?php
require_once 'config.php';
require_once 'Artist.php';
if (isset($_POST['submit'])) {
$band = new Artist($_POST['name'], $_POST['origin'], $_POST['active_years']);
$band->create();
}
?>
<html>
<head>
<title>Artists</title>
</head>
<body>
<form method="POST" action="">
Enter the name of your artist:
<input type="text" name="name"></input>
Enter the origin of your artist:
<input type="text" name="origin"></input>
Enter the years your artist was active:
<input type="text" name="active_years"></input>
<input type="submit" name="submit" value="submit"></input>
</form>
<?php
if (isset($band)) {
?>
<p>The last band entered was "<?php
echo $band->name;
?>