Exemple #1
0
 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());
 }
 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');
     }
 }
 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.');
 }
Exemple #4
0
 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;
         }
     }
 }
Exemple #5
0
 * @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'])));
<?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);
    }
}
		
		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-->
Exemple #8
0
<?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;
    ?>