В базе три таблицы, вот модели:
class Day extends Model
{
protected $table = 'day';
public $timestamps = false;
public function weather()
{
return $this->hasMany('models\Weather');
}
}
class Precipitation extends Model
{
protected $table = 'precipitation';
public $timestamps = false;
public function weather()
{
return $this->hasMany('models\Weather');
}
}
class Weather extends Model
{
protected $table = 'weather';
public $timestamps = false;
public function day()
{
return $this->belongsTo('models\Day', 'models\Precipitation');
}
}
Поля в таблице weather: id, name, day_id, precipitation_id В остальных только id и name
Два вопроса: 1. Правильно ли я связал таблицы на уровне моделей? 2. Как написать обычный запрос на выборку из всех трех таблиц?