?
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use App\Models\Profile;
use App\Models\Transaction;
use App\Models\Courses;
class Dashboard extends Model
{
use HasFactory;
public static function InstructorStatsForAdmin ($userid){
$CourseCount = Courses::Where('currentstatus','0')
->Where('createby',$userid)
->with('getCategoryName')
->with('getWidgetAdType')
->count();
$StudentCount= Transaction::Where('currentstatus','0')
->Where('productauthorid',$userid)
->with('getCheckoutDetails')
->orderBy('id', 'asc')
->distinct('userid')
->count();
$GetLast30DaysNetAmt = Transaction::Where('currentstatus','0')
->Where('productauthorid',$userid)
->where('createdate', '>', now()->subDays(30)->endOfDay())
->sum('netamount');
$GetLast30DaysData = Transaction::Where('currentstatus','0')
->Where('productauthorid',$userid)
->where('createdate', '>', now()->subDays(30)->endOfDay())
->count();
$GetLast90DaysNetAmt = Transaction::Where('currentstatus','0')
->Where('productauthorid',$userid)
->where('createdate', '>', now()->subDays(90)->endOfDay())
->sum('netamount');
$GetLast90DaysData = Transaction::Where('currentstatus','0')
->Where('productauthorid',$userid)
->where('createdate', '>', now()->subDays(90)->endOfDay())
->count();
$InstructorCollect = collect([$CourseCount, $StudentCount, $GetLast30DaysNetAmt, $GetLast30DaysData,$GetLast90DaysNetAmt, $GetLast90DaysData ]);
return $InstructorCollect ;
}
}