A simple experiment to define Eloquent relationships in a quick easy way using arrays instead of defining a method for each relation.
The scope of EasyRelations is to be only used with simple cases where you dont need to define complex queries or do additional complex queries on the relation.
an example:
<?php
class Post extends Model
{
use EasyRelations;
public array $easyRelations = [
Comment::class => 'hasMany',
User::class => 'belongsTo',
];
}
$post->comments;
$post->user;
Post::with('comments', 'user')->first();