PHP code example of dandelionmood / laravel-relatable
1. Go to this page and download the library: Download dandelionmood/laravel-relatable library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
dandelionmood / laravel-relatable example snippets
// The `Post` class uses the `HasRelatedContent` trait
$post = Post::find(1);
$anotherPost = Post::find(2);
$person = Person::find(1);
$post->relate($anotherPost);
$post->relate($person);
$related = $post->related;
// => Collection containing `$anotherPost` and `$person`