PHP code example of wearepixel / laravel-model-objects

1. Go to this page and download the library: Download wearepixel/laravel-model-objects 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/ */

    

wearepixel / laravel-model-objects example snippets




namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use WeArePixel\LaravelModelObjects\HasModelObject;

class User extends Model
{
    use HasModelObject;

    protected $hiddenProperties = [
        'user_id',
    ];
}

// ...
$user = User::find(1);
$userObject = $user->modelObject;

return [
    /**
     * Hide the primary key from the model object
     */
    'hide_primary_key' => env('LARAVEL_MODEL_OBJECTS_HIDE_PRIMARY_KEY', true),

    /**
     * Hide timestamps from the model object
     */
    'hide_timestamps' => env('LARAVEL_MODEL_OBJECTS_HIDE_TIMESTAMPS', true),
];

protected $hiddenProperties = [
    'user_id',
];
sh
php artisan vendor:publish --provider="WeArePixel\LaravelModelObjects\LaravelModelObjectsServiceProvider"