PHP code example of mnurullahsaglam / laravel-owner
1. Go to this page and download the library: Download mnurullahsaglam/laravel-owner 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/ */
mnurullahsaglam / laravel-owner example snippets
use Illuminate\Database\Eloquent\Model;
use Mnurullahsaglam\LaravelOwner\HasOwner;
use Mnurullahsaglam\LaravelOwner\OwnerSettings;
class Post extends Model
{
use HasOwner;
public function getOwnerSettings(): OwnerSettings
{
return OwnerSettings::create()
->setOwnerModel(App\Models\Owner::class)
->setOwnerKey('owner_id');
}
}
$post = Post::find(1);
return $post->owner;