MOON
Server: Apache
System: Linux e2e-78-16.ssdcloudindia.net 3.10.0-1160.45.1.el7.x86_64 #1 SMP Wed Oct 13 17:20:51 UTC 2021 x86_64
User: imensosw (1005)
PHP: 7.4.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: /home/imensosw/www/mpl.imenso.co/app/Models/Device.php
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Device extends Model
{
    protected $table = 'user_devices';

    protected $casts = [
        'last_logged_in_at' => 'datetime',
    ];

    protected $hidden = [
        'serial', 'fcm_token',
    ];

    protected $fillable = [
        'model',
        'platform',
        'version',
        'manufacturer',
        'serial',
    ];

    public function owner()
    {
        return $this->belongsTo(\App\Models\User::class);
    }

    public static function addNew($data)
    {
        $device = new self;
        $device->uuid = $data['uuid'];
        $device->model = $data['model'];
        $device->platform = $data['platform'];
        $device->version = $data['version'];
        $device->manufacturer ="sumsung";
        $device->serial ="unknown";
        $device->save();

        return $device;
    }

    public function updateLastLoginDate()
    {
        $this->last_logged_in_at = new \Carbon\Carbon;
        $this->save();
    }

    public function removeForceLogout()
    {
        $this->force_logout = 0;
        $this->save();
    }

    public function updateFCMToken($token)
    {
        $this->fcm_token = $token;
        $this->save();
    }

    public function removeFCMToken()
    {
        $this->fcm_token = NULL;
        $this->save();
    }

    public function clearFCMToken()
    {
        $this->fcm_token = NULL;
        $this->save();
    }

    public function setUser(User $user)
    {
        $this->user_id = $user->id;
        $this->save();
    }
}