2019-05-20 07:37:41 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App;
|
|
|
|
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
2020-01-08 17:03:41 +01:00
|
|
|
use Illuminate\Support\Facades\Storage;
|
2020-01-21 21:31:28 +01:00
|
|
|
use Illuminate\Contracts\Encryption\DecryptException;
|
2019-05-20 07:37:41 +02:00
|
|
|
|
2019-05-24 14:44:41 +02:00
|
|
|
class TwoFAccount extends Model
|
2019-05-20 07:37:41 +02:00
|
|
|
{
|
2020-01-10 13:43:36 +01:00
|
|
|
/**
|
|
|
|
* model's array form.
|
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
*/
|
|
|
|
protected $fillable = ['service', 'account', 'uri', 'icon'];
|
2019-05-24 14:44:41 +02:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The table associated with the model.
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
protected $table = 'twofaccounts';
|
2020-01-08 17:03:41 +01:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Null empty icon resource has gone
|
|
|
|
*
|
|
|
|
* @param string $value
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function getIconAttribute($value)
|
|
|
|
{
|
2020-01-10 13:43:36 +01:00
|
|
|
if (\App::environment('testing') == false) {
|
|
|
|
if( !Storage::exists('public/icons/' . pathinfo($value)['basename']) ) {
|
2020-01-08 17:03:41 +01:00
|
|
|
|
2020-01-10 13:43:36 +01:00
|
|
|
return '';
|
|
|
|
}
|
2020-01-08 17:03:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return $value;
|
|
|
|
}
|
2020-01-21 21:31:28 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the user's first name.
|
|
|
|
*
|
|
|
|
* @param string $value
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
// public function setUriAttribute($value)
|
|
|
|
// {
|
|
|
|
// $this->attributes['uri'] = encrypt($value);
|
|
|
|
// }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the user's first name.
|
|
|
|
*
|
|
|
|
* @param string $value
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
// public function getUriAttribute($value)
|
|
|
|
// {
|
|
|
|
// try {
|
|
|
|
|
|
|
|
// return decrypt($value);
|
|
|
|
|
|
|
|
// } catch (DecryptException $e) {
|
|
|
|
|
|
|
|
// return null;
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
2019-05-20 07:37:41 +02:00
|
|
|
}
|