I have 2 related tables, I need to filter the date of a table by month
My first table have the following fields: Id_agendamien_persona , Id_agendamiento, id_persona
The second table have the following fields: Id_agendamiento, fecha
so I need to filter fecha in the second table,
Mi controller
public function listar(){
$contactos = Contacto::pluck('completo','id_contacto');
$contacto_x_agendamientos = Contacto_x_Agendamiento::all();
array_add($contactos,0,"::Seleccione::");
return view('agendamiento.listar')->with(compact('contacto_x_agendamientos','contactos'));
}
My model
first table
class Contacto_x_Agendamiento extends Model
{
protected $table = "contacto_x_agendamiento";
protected $primaryKey = 'id_contacto_x_agendamiento';
const CREATED_AT = 'fecha_creado';
const UPDATED_AT = 'fecha_modificado';
public function Agendamiento(){
return $this->hasOne(Agendamiento::class,'id_agendamiento','id_agendamiento');
}
}
second table
class Agendamiento extends Model
{
protected $table = "agendamiento";
protected $primaryKey = 'id_agendamiento';
const CREATED_AT = 'fecha_creado';
const UPDATED_AT = 'fecha_modificado';
public function scopeMes($query){
return $query->whereMonth('fecha_agendar','=',date('m'))->get();
}
}
View
<td></td>
error
Property [fecha_agendar] does not exist on this collection instance.
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2Gtqcgs
via IFTTT
Aucun commentaire:
Enregistrer un commentaire