select `user_watched_lectures`.`user_id` as `pivot_user_id`, `user_watched_lectures`.`lecture_id` as `pivot_lecture_id`, `user_watched_lectures`.`created_at` as `pivot_created_at`, `user_watched_lectures`.`updated_at` as `pivot_updated_at`, `user_watched_lectures`.*, `lectures`.*from `lectures` inner join `user_watched_lectures` on `lectures`.`id` = `user_watched_lectures`.`lecture_id`where `user_watched_lectures`.`user_id` = 1order by `user_watched_lectures`.`id` desc, `order` asc, `created_at` asclimit 10 offset 0
dd
dd(CourseBundle::with('courses')->get()->toArray());
<?phpnamespace App\Models;use Illuminate\Database\Eloquent\Factories\HasFactory;use Illuminate\Database\Eloquent\Model;use Illuminate\Database\Eloquent\Relations\BelongsToMany;class CourseBundle extends Model{ use HasFactory; protected $guarded = ['id']; public function courses(): BelongsToMany { return $this->belongsToMany(Course::class, 'course_course_bundles', 'course_bundle_id', 'course_id') ->withTimestamps(); }}