PHP code example of cmxperts / belongs-to-one
1. Go to this page and download the library: Download cmxperts/belongs-to-one 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/ */
cmxperts / belongs-to-one example snippets
namespace App\Models;
use App\Models\Group;
Use Illuminate\Database\Eloquent\Model;
use cmXperts\Database\Eloquent\Relations\BelongsToOneTrait;
class Record extends Model
{
use BelongsToOneTrait;
public function group()
{
return $this->belongsToOne(Group::class);
}
}
$record = Record::with('group')->first();