Laravel mysql order by with wherehas

I have 2 tables :-

  1. users - id,name,email, mobile

  2. user_info - id,user_id, store_name, startup_date

  3. User Model

    class EloquentUser extends Model { protected $table = 'users';

     /**
      * The attributes that are mass assignable.
      *
      * @var array
      */
     protected $fillable = [
         'name',
          'email',
        'mobile'
     ];
    

    }

  4. User Info Model

    class UserInfo extends Model { use HasFactory, SoftDeletes; public $table = 'user_info';

    }

Below is relationship on above 2 tables :-

public function info() {
        return $this->hasOne(UserInfo::class,'user_id','id');
    }

I want to order on base of startup_date but it is giving error column not found. Below is the query :-

$reponse = EloquentUser::with('info')->has('info')->orderBy('info.startup_date')->get();


Comments

Popular posts from this blog

Today Walkin 14th-Sept

Spring Elasticsearch Operations

Hibernate Search - Elasticsearch with JSON manipulation