PHP code example of khaled-dev / includable
1. Go to this page and download the library: Download khaled-dev/includable 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/ */
khaled-dev / includable example snippets
namespace App;
use Khaled7\Includable\Includable;
use Illuminate\Foundation\Auth\User as Authenticatable;
class User extends Authenticatable
{
use Includable;
/**
* The attributes that are includable,
* references to a relations method.
*
* @var array
*/
protected $includable = [
'posts',
'votes',
];
public function posts()
{
return $this->hasMany(Post::class);
}
public function votes()
{
return $this->hasMany(Vote::class);
}
// Not includable, coz not in $includable
public function subscribes()
{
return $this->hasMany(Subscribe::class);
}
}