<?php
namespace App\Domain\Users\DataTransferObjects;

use App\Models\User;
use Spatie\DataTransferObject\DataTransferObject;

class UserData extends DataTransferObject
{
    public $id;
    public $name;
    public $user_char;
    public $color;
    public $photo_path;
    public $banner_path;
    public $username;
    public $private;
    public $is_auth_user;

    public static function fromModel(User $user)
    {
        $idCheck = auth()->user() ? $user->id === auth()->user()->id : false;
        return new self([
            'id' => $user->id,
            'name' => $user->name,
            'user_char' => $user->user_char,
            'color' => $user->color,
            'photo_path' => $user->photo_path,
            'banner_path' => $user->banner_path,
            'username' => $user->username,
            'private' => $user->private,
            'is_auth_user' => $idCheck,
        ]);
    }
}
