save to codehub
This commit is contained in:
148
app/Models/User.php
Normal file
148
app/Models/User.php
Normal file
@@ -0,0 +1,148 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
// use Laravel\Passport\HasApiTokens;
|
||||
use Laravel\Sanctum\HasApiTokens;
|
||||
// use PHPOpenSourceSaver\JWTAuth\Contracts\JWTSubject;
|
||||
use Tymon\JWTAuth\Contracts\JWTSubject;
|
||||
use App\Models\ContactUs;
|
||||
use App\Models\UserThought;
|
||||
use App\Models\UserOverView;
|
||||
|
||||
use App\Models\DailyStepsCount;
|
||||
|
||||
use Carbon\Carbon;
|
||||
|
||||
class User extends Authenticatable implements JWTSubject
|
||||
{
|
||||
|
||||
use HasApiTokens;
|
||||
use Notifiable;
|
||||
use HasFactory;
|
||||
use SoftDeletes;
|
||||
|
||||
protected $dates = ['deleted_at'];
|
||||
protected $table = 'users';
|
||||
|
||||
protected $guarded = [];
|
||||
// protected $fillable = [
|
||||
// 'full_name',
|
||||
// 'contact_number',
|
||||
// 'email_id',
|
||||
// 'offering_name',
|
||||
// 'offering_type',
|
||||
// 'price_per_spot',
|
||||
// 'transaction_date',
|
||||
// 'booking_schedule',
|
||||
// 'answers_0_q_text',
|
||||
// 'answers_0_q_type',
|
||||
// 'answers_0_q_ans',
|
||||
// 'answers_1_q_text',
|
||||
// 'answers_1_q_type',
|
||||
// 'answers_1_q_ans',
|
||||
// 'answers_2_q_text',
|
||||
// 'answers_2_q_type',
|
||||
// 'answers_2_q_ans',
|
||||
// 'answers_3_q_text',
|
||||
// 'answers_3_q_type',
|
||||
// 'answers_3_q_ans',
|
||||
// 'answers_4_q_text',
|
||||
// 'answers_4_q_type',
|
||||
// 'answers_4_q_ans',
|
||||
// 'answers_5_q_text',
|
||||
// 'answers_5_q_type',
|
||||
// 'answers_5_q_ans',
|
||||
// 'answers_6_q_text',
|
||||
// 'answers_6_q_type',
|
||||
// 'answers_6_q_ans',
|
||||
// 'gst_name',
|
||||
// 'gst_number',
|
||||
// 'gst_company_address',
|
||||
// 'billing_state',
|
||||
// 'password',
|
||||
// 'signup_from',
|
||||
// 'google_id',
|
||||
// 'apple_id',
|
||||
// 'user_type',
|
||||
// 'status',
|
||||
// 'utm_source',
|
||||
// 'address',
|
||||
// 'fitness_goal',
|
||||
// 'hear_about',
|
||||
// 'start_date',
|
||||
// 'end_date',
|
||||
// ];
|
||||
protected $hidden = [
|
||||
'password', 'remember_token',
|
||||
];
|
||||
public function getJWTIdentifier()
|
||||
{
|
||||
return $this->getKey();
|
||||
}
|
||||
|
||||
public function getJWTCustomClaims()
|
||||
{
|
||||
return [];
|
||||
}
|
||||
/**
|
||||
* Get the identifier that will be stored in the subject claim of the JWT.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
// public function getJWTIdentifier() {
|
||||
// return $this->getKey();
|
||||
// }
|
||||
|
||||
/**
|
||||
* Return a key value array, containing any custom claims to be added to the JWT.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
// public function getJWTCustomClaims() {
|
||||
// return [];
|
||||
// }
|
||||
|
||||
public function ContactUs() {
|
||||
return $this->hasOne(ContactUs::class);
|
||||
}
|
||||
|
||||
public function userThought() {
|
||||
return $this->hasOne(UserThought::class, 'user_id', 'id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Created By : Pradyumn Dwivedi
|
||||
* Created at : 06-feb-2023
|
||||
* Use : To get user details data in user listing
|
||||
*/
|
||||
public function user_detail(){
|
||||
return $this->hasOne('App\Models\UserDetail', 'user_id', 'id')->withDefault();
|
||||
}
|
||||
|
||||
public function leaderboard_master()
|
||||
{
|
||||
return $this->hasMany(LeaderboardMaster::class);
|
||||
}
|
||||
|
||||
public function stepCount()
|
||||
{
|
||||
return $this->hasMany(DailyStepsCount::class)->where('date', Carbon::today()->toDateString());
|
||||
}
|
||||
|
||||
public function latestStepCount()
|
||||
{
|
||||
return $this->hasOne(DailyStepsCount::class)->orderBy('date', 'desc');
|
||||
}
|
||||
|
||||
public function getLatestStepCountArrayAttribute()
|
||||
{
|
||||
$latestStepCount = $this->latestStepCount;
|
||||
return $latestStepCount ? [$latestStepCount->toArray()] : [];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user