Movies\User::rateMovie PHP Method

rateMovie() public method

public rateMovie ( Movie $movie, float $score )
$movie Movie
$score float
    public function rateMovie(Movie $movie, $score)
    {
        $this->ratings->add(new Rating($this, $movie, $score));
    }

Usage Example

Beispiel #1
0
// Updating a related node
// Find Tom Hanks, filter his movies to find Cast Away and rename it to Cast Away 2
/** @var Person $tomHanks */
$tomHanks = $em->getRepository(Person::class)->findOneBy('name', 'Tom Hanks');
$filter = array_values(array_filter($tomHanks->getMovies()->toArray(), function (\Movies\Movie $movie) {
    return 'Cast Away' === $movie->getTitle();
}));
/** @var \Movies\Movie $castAway */
$castAway = $filter[0];
$castAway->setTitle('Cast Away 2');
$em->flush();
// Create a User and a Rating for the movie "The Matrix"
$user = new User('cypher666');
/** @var Movie $movie */
$movie = $em->getRepository(Movie::class)->findOneBy('title', 'The Matrix');
$user->rateMovie($movie, '4.5');
$em->persist($user);
$em->flush();
function playMovies(\GraphAware\Neo4j\Client\Client $client)
{
    $q = 'CREATE (TheMatrix:Movie {title:\'The Matrix\', released:1999, tagline:\'Welcome to the Real World\'})
CREATE (Keanu:Person {name:\'Keanu Reeves\', born:1964})
CREATE (Carrie:Person {name:\'Carrie-Anne Moss\', born:1967})
CREATE (Laurence:Person {name:\'Laurence Fishburne\', born:1961})
CREATE (Hugo:Person {name:\'Hugo Weaving\', born:1960})
CREATE (AndyW:Person {name:\'Andy Wachowski\', born:1967})
CREATE (LanaW:Person {name:\'Lana Wachowski\', born:1965})
CREATE (JoelS:Person {name:\'Joel Silver\', born:1952})
CREATE
  (Keanu)-[:ACTED_IN {roles:[\'Neo\']}]->(TheMatrix),
  (Carrie)-[:ACTED_IN {roles:[\'Trinity\']}]->(TheMatrix),