<?php

namespace App;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use App\Scopes\MessageScope;


class TelecomData extends Model
{
    use SoftDeletes;
    use Encryptable;

    public static $encryptable = [
        'mobile_number',
        'telecom_response'
    ];
    protected static function boot()
    {
        parent::boot();
        static::addGlobalScope(new MessageScope(static::$encryptable));
    }
    protected $table = 'telecom_datas';

    protected $fillable = [
        'mobile_number', 'telecom_response'
    ];

    public function scopeWhere($query, $column, $value){
        return in_array($column, $this->encryptable) ? $query->where($column, wall_encrypt($value)) : $query->where($column, $value);
    }
}
