PHP code example of plank / larelations
1. Go to this page and download the library: Download plank/larelations 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/ */
plank / larelations example snippets
$extractor = new \Plank\Larelations\Extractor();
$instances = $extractor->extract($post);
$instances = \Plank\Larelations\Facades\Larelations::extract(Post::class);
foreach ($instances as $instance) {
if ($instance->isChild()) {
// Handle child types of relations
}
if ($instance->relation instanceof \Znck\Eloquent\Traits\BelongsToThrough) {
// Handle custom relation
}
// The method property is the \ReflectionMethod of the relation instance
$instance->method->getName(); // posts
}