feat: strava sync
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Concerns\HasUlids;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class StravaConnection extends Model
|
||||
{
|
||||
use HasUlids;
|
||||
|
||||
protected $fillable = [
|
||||
'user_id',
|
||||
'athlete_id',
|
||||
'access_token',
|
||||
'refresh_token',
|
||||
'expires_at',
|
||||
'scopes',
|
||||
'athlete',
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'access_token',
|
||||
'refresh_token',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'athlete_id' => 'integer',
|
||||
'access_token' => 'encrypted',
|
||||
'refresh_token' => 'encrypted',
|
||||
'expires_at' => 'datetime',
|
||||
'scopes' => 'array',
|
||||
'athlete' => 'array',
|
||||
];
|
||||
}
|
||||
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,7 @@ use Illuminate\Database\Eloquent\Concerns\HasUlids;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Laravel\Sanctum\HasApiTokens;
|
||||
@@ -78,6 +79,11 @@ class User extends Authenticatable implements FilamentUser
|
||||
return $this->hasMany(WorkoutSessions::class);
|
||||
}
|
||||
|
||||
public function stravaConnection(): HasOne
|
||||
{
|
||||
return $this->hasOne(StravaConnection::class);
|
||||
}
|
||||
|
||||
public function likedMealPosts(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(MealPosts::class, 'meal_post_likes', 'user_id', 'meal_posts_id')
|
||||
|
||||
Reference in New Issue
Block a user