我有桌子,Station&设备,第三个枢轴工作台station_equipment,附加字段" status"除了各自的表ID之外,状态可以是活动的还是非活动的,我只想获取Active元素,但是我的查询继续检索具有这两种状态的设备。
查询:
$eqestacion = Station::where('station.id', $id)
->whereHas('equipments', function($query) {
$query->where('equipment_station.status','=','active');
})->with('equipments')
->get();
电台型号:
public function equipments(){
return $this->belongsToMany('App\Equipment')->withPivot('status')->withTimestamps();
}
Equiment Model:
public function stations()
return $this->belongsToMany('App\Station')
->orderBy('pivot_created_at','desc')->withPivot('status')->withTimestamps();
}
提前致谢
答案 0 :(得分:1)
这会为您提供身份ControlTemplate
的{{1}}:
Duration
这会为您提供与DoubleAnimation
相关联的所有有效ControlTemplate
。
private void UpDateList()
{
// add data connection and fill data set.
SqlConnection conn = new SqlConnection(dataSource);
DataTable dt = new DataTable();
string sqlString = "select * from Suppliers";
SqlCommand cmd = new SqlCommand();
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
try
{
cmd.Connection = conn;
conn.Open();
cmd.CommandText = sqlString;
da.Fill(ds);
conn.Close();
}
catch (SqlException ex)
{
MessageBox.Show(ex.ToString());
}
finally
{
conn.Close();
}
foreach(DataRow dRow in ds.Tables[0].Rows)
{
ArrayList values = new ArrayList();
foreach(object value in dRow.ItemArray)
{
values.Add(value);
_Suppliers.Add(values);
}
}
lstSuppliers.DataSource = _Suppliers;
lstSuppliers.Update();
}