chore: code style
This commit is contained in:
@@ -2,16 +2,18 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use App\Interfaces\MarketData\MarketDataInterface;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class MarketData extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $primaryKey = 'symbol';
|
||||
|
||||
protected $keyType = 'string';
|
||||
|
||||
public $incrementing = false;
|
||||
|
||||
protected $fillable = [
|
||||
@@ -25,7 +27,7 @@ class MarketData extends Model
|
||||
'market_cap',
|
||||
'book_value',
|
||||
'last_dividend_date',
|
||||
'dividend_yield'
|
||||
'dividend_yield',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
@@ -37,10 +39,10 @@ class MarketData extends Model
|
||||
'trailing_pe' => 'float',
|
||||
'market_cap' => 'float',
|
||||
'book_value' => 'float',
|
||||
'dividend_yield' => 'float'
|
||||
'dividend_yield' => 'float',
|
||||
];
|
||||
|
||||
public function holdings()
|
||||
public function holdings()
|
||||
{
|
||||
return $this->hasMany(Holding::class, 'symbol', 'symbol');
|
||||
}
|
||||
@@ -50,20 +52,20 @@ class MarketData extends Model
|
||||
return $query->where('symbol', $symbol);
|
||||
}
|
||||
|
||||
public static function getMarketData($symbol, $force = false)
|
||||
public static function getMarketData($symbol, $force = false)
|
||||
{
|
||||
$market_data = self::firstOrNew([
|
||||
'symbol' => $symbol
|
||||
'symbol' => $symbol,
|
||||
]);
|
||||
|
||||
// check if new or stale
|
||||
if (
|
||||
$force
|
||||
|| !$market_data->exists
|
||||
|| ! $market_data->exists
|
||||
|| is_null($market_data->updated_at)
|
||||
|| $market_data->updated_at->diffInMinutes(now()) >= config('investbrain.refresh')
|
||||
) {
|
||||
|
||||
|
||||
// get quote
|
||||
$quote = app(MarketDataInterface::class)->quote($symbol);
|
||||
|
||||
@@ -76,4 +78,4 @@ class MarketData extends Model
|
||||
|
||||
return $market_data;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user