<?php

namespace App\Models;

use Dcat\Admin\Traits\HasDateTimeFormatter;

use Illuminate\Database\Eloquent\Model;

/**
 * App\Models\UserShare
 *
 * @property int $id
 * @property int $user_id 用户
 * @property int $child_id 分销ID
 * @property string $income 收入
 * @property \Illuminate\Support\Carbon|null $created_at
 * @property \Illuminate\Support\Carbon|null $updated_at
 * @method static \Illuminate\Database\Eloquent\Builder|UserShare newModelQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|UserShare newQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|UserShare query()
 * @method static \Illuminate\Database\Eloquent\Builder|UserShare whereChildId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|UserShare whereCreatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|UserShare whereId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|UserShare whereIncome($value)
 * @method static \Illuminate\Database\Eloquent\Builder|UserShare whereUpdatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|UserShare whereUserId($value)
 * @mixin \Eloquent
 * @property-read \App\Models\User $child
 * @property-read \App\Models\User $user
 */
class UserShare extends Model
{
	use HasDateTimeFormatter;
    protected $table = 'user_shares';


    protected $fillable = [
        'user_id',
        'child_id',
        'income'
    ];


    public function user()
    {
        return $this->belongsTo(User::class);
    }

    public function child()
    {
        return $this->belongsTo(User::class,'child_id');
    }

}
