scope for laravel of a relationship

0

I have a registration table and a student-related table, one to many, and I want to make a scope in the enrollment model in such a way that I look for the student's routine, at the moment I have a scope by date. How could I make that scope? this is or that I have

class Matricula extends Model

protected $table = "matriculas";

protected $fillable = ['estado', 'monto', 'fecha', 'id_alumno'];

public function alumno()
{
    return $this->belongsTo(Alumno::class,'id_alumno','id');
}

public function scopeSearch($query, $fecha)
{
    return $query->whereMonth('fecha', 'LIKE', "%$fecha%");
}

with that scope I can only search by dates, how can I do one to search by student's rut, if the tables are related?

    
asked by Edgardo Escobar 26.05.2017 в 00:10
source

0 answers