28 lines
671 B
PHP
28 lines
671 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class BandGoalLog extends Model
|
|
{
|
|
use HasFactory;
|
|
public $fillable = ['user_id', 'band_id', 'step_num', 'distance', 'kcal', 'sleep'];
|
|
|
|
public function scopeOwner($query, $user_id)
|
|
{
|
|
return $query->where("user_id", $user_id);
|
|
}
|
|
|
|
public function scopeBand($query, $band_id)
|
|
{
|
|
return $query->where("band_id", $band_id);
|
|
}
|
|
|
|
public function scopeTimes($query, $start_time, $end_time)
|
|
{
|
|
return $query->where('created_at', '>=', $start_time)->where("created_at", '<', $end_time);
|
|
}
|
|
}
|