2016-05-20 6 views
12

メンバー関数呼び出し(null)の呼び出しは、ルーメンでEloquentモデルを使用しようとしたときに受け取るエラーです。PHP Lumen nullへのメンバー関数connection()への呼び出し

コントローラのFUNC:

/** 
    * Display a listing of the resource. 
    * 
    * @return \Illuminate\Http\Response 
    */ 
    public function index(Request $request) 
    { 

     $employees = Employee::orderBy('first_name', 'asc')->get(); 
dd($employees); 

     $response['precontent'] = view('admin::employee.search')->render(); 

     $response['content'] = view('admin::employee.index') 
      ->with(['employees' => $employees]) 
      ->render(); 

     $response['title'] = 'Employees'; 

     return $response; 

    } 

モデル:

<?php 
    namespace App; 

use Illuminate\Database\Eloquent\Model; 

class Employee extends Model 
{ 

    protected $table = 'system_core.employees'; 

    protected $fillable = [ 
     'user_id', 
     'first_name', 
     'last_name', 
     'position', 
     'primary_address', 
     'secondary_address', 
     'phone_1', 
     'phone_2', 
     'birth_date', 
     'start_date', 
     'end_date' 
    ]; 

} 

私はかなりLaravelを経験したが、単なるAPIの使用のための私の最初のルーメンプロジェクトを開始し、私はなぜこれわかりませんよエラーがスローされています。おそらくそれは私の接続設定ですか?すべてのクエリは次のように実行しなければならないであろう?:

$results = app('db')->select("SELECT * FROM users"); 

ありがとうございました!

答えて

関連する問題