PHP code example of rkwp / object-iterable-laravel
1. Go to this page and download the library: Download rkwp/object-iterable-laravel 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/ */
namespace App\DataType\Devel\Users;
use App\DataStructure\Devel\Users\UserStruct;
use App\Helper\ObjectIterable;
class TUser extends ObjectIterable {
use UserStruct;
function __construct()
{
foreach (get_object_vars($this) as $name => $value) {
unset($this->{$name});
}
}
/**
* @return self|ObjectIterable
*/
public function set($items) {
$this->assign($items, static::class);
return $this;
}
}
namespace App\DataStructure\Devel\Users;
use App\DataType\Devel\Users\TProfile;
trait UserStruct {
public $id;
public $name;
public $email;
public $created_at;
public $status;
public TProfile $profile; // ini saya tambahkan sendiri secara manual, tapi class TProfile tetap saya buat menggunakan perintah artisan yang tadi
}