PHP code example of eroslover / laravel-references
1. Go to this page and download the library: Download eroslover/laravel-references 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/ */
eroslover / laravel-references example snippets
// photo of some persons
$photo = Photo::find(1);
// persons you want to refer with this photo
$person1 = Person::find(1);
$person2 = Person::find(2);
// making a reference
$photo->ref($person1);
$photo->ref($person2);
// you are able to refer a collection of persons
$persons = Person::find([1, 2]);
$photo->ref($persons);
return [
/*
* Name of the database table that will store model references.
*/
'table_name' => 'references'
];
namespace App;
use Eroslover\References\Traits\References;
use Eroslover\References\Interfaces\ReferenceInterface;
use Illuminate\Database\Eloquent\Model;
class Photo extends Model implements ReferenceInterface
{
use References;
}
namespace App;
use Illuminate\Database\Eloquent\Model;
class Person extends Model {}
class Location extends Model {}
class Event extends Model {}