im having this error with Eloquent models while trying to make multiple model joins:
BadMethodCallException in Builder.php line 2450: Call to undefined method Illuminate\Database\Query\Builder::adminis()
These are my models:
<?php
namespace App\Modelos;
use Illuminate\Database\Eloquent\Model;
class srh_inf_persona extends Model
{
protected $table = 'srh_inf_personas';
protected $primaryKey = ['infp_cedula'];
public function adminis()
{
return $this->hasMany('App\Modelos\srh_infa_admini');
}
}
use Illuminate\Database\Eloquent\Model;
class srh_inf_admini extends Model
{
protected $table = 'srh_inf_adminis';
public $timestamps = 'false';
protected $primaryKey = ['infa_cedula'];
public function persona()
{
return $this->belongsTo('App\Modelos\srh_inf_persona');
}
}
and this is my controller query:
<?php
namespace App\Http\Controllers\Controladores;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Modelos\srh_inf_persona; // Llamado del modelo SRH_INF_PERSONA
use App\Modelos\srh_inf_admini; // Llamado del modelo SRH_INF_PERSONA
class SolicitudController extends Controller
{
// Consulta para generar la solicitud de permisos
public function nuevasolicitud($ced)
{
$consulta = srh_inf_persona::select('infp_cedula')->adminis()
->where('infp_cedula',$ced)
->first();
return view('permisos.solicitud',[ 'personas' => $consulta ]);
}
}
Any idea what the problem is? Thanks alot.