PHP code example of omgitslock / relation-parser
1. Go to this page and download the library: Download omgitslock/relation-parser 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/ */
omgitslock / relation-parser example snippets
use Illuminate\Database\Eloquent\Model;
class Post extends Model
{
public function comments()
{
return $this->hasMany('App\Comment');
}
public function user()
{
return $this->belongsTo('App\User');
}
}
$relations = $relationBag->getRelations();
//получим имя и вид каждого отношения
foreach($relations as $relation){
echo 'Метод ' . $relation->getMethod(). ', тип ' . $relation->getType() . PHP_EOL;
}