我在我的本地windows10 PC上开发了一个Laravel 5.2应用程序,使用xampp,apache2和php 7.0.3作为环境,一切正常。我也尝试在安装了php 5.3的xampp上运行,运行良好。现在我想在debian 8 jessie服务器上部署应用程序,安装apache2和php 5.6。
我上传应用程序后,每当我提到如下代码中的雄辩关系时,我就会遇到问题
@if ($pegawai->list_pendidikan_pegawai->count() >0)
@foreach ($pegawai->list_pendidikan_pegawai as $pendidikan)
@if (($pendidikan->pendidikan_pendidikan != null) && ($pendidikan->status != 0))
<tr>
<td>{{ $i++ }}</td>
<td>{{$pendidikan->pendidikan_pendidikan->nama}}</td>
<td>{{$pendidikan->nama_tempat}}</td>
<td>{{$pendidikan->no_ijazah}}</td>
<td>{{$pendidikan->tgl_ijazah->format('d-m-Y')}}</td>
</tr>
@else
@endif
@endforeach
@endif
它返回
Trying to get property of non-object
基于上面的例子,这里是riwayat_pendidikan模型
class riwayat_pendidikan extends Model
{
protected $table = 'riwayat_pendidikan';
protected $fillable = ['pegawai', 'jenjang_pendidikan', 'pendidikan', 'nama_tempat', 'propinsi', 'kabkot', 'tempat', 'no_ijazah', 'tgl_ijazah', 'kepala', 'scan_ijazah', 'status'];
public function pendidikan_pendidikan()
{
return $this->belongsTo('App\ref_jenis_pendidikan', 'pendidikan', 'id');
}
}
这是主模型
class master extends Model
{
protected $table = 'master';
protected $fillable = ['pegawai', 'sk_pengangkatan', 'tmt_pengangkatan', 'pendidikan', 'jabatan', 'jenis_kepegawaian', 'unor', 'unor_induk', 'scan_izin_prinsip', 'pejabat_pengangkat','status'];
public function list_pendidikan_pegawai()
{
return $this->hasMany('App\riwayat_pendidikan', 'pegawai', 'id');
}
}
这是控制器
/**
* Display the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function show($id)
{
$pegawai = master::find($id);
return view('show.show_pegawai', compact('pegawai'));
}
这是debian服务器上的php --ini结果
/root$ php --ini
Configuration File (php.ini) Path: /etc/php5/cli
Loaded Configuration File: /etc/php5/cli/php.ini
Scan for additional .ini files in: /etc/php5/cli/conf.d
Additional .ini files parsed: /etc/php5/cli/conf.d/05-opcache.ini,
/etc/php5/cli/conf.d/10-pdo.ini,
/etc/php5/cli/conf.d/20-gd.ini,
/etc/php5/cli/conf.d/20-json.ini,
/etc/php5/cli/conf.d/20-mcrypt.ini,
/etc/php5/cli/conf.d/20-mysql.ini,
/etc/php5/cli/conf.d/20-mysqli.ini,
/etc/php5/cli/conf.d/20-pdo_mysql.ini,
/etc/php5/cli/conf.d/20-readline.ini
我不知道为什么它在不同环境中出错。任何你可以帮助我的方式都会很棒。我非常坚持这一点。
这是dd($ pegawai)结果
master {#407 ▼
#table: "master"
#fillable: array:11 [▶]
#dates: array:1 [▶]
#connection: null
#primaryKey: "id"
#perPage: 15
+incrementing: true
+timestamps: true
#attributes: array:15 [▶]
#original: array:15 [▼
"id" => 2
"pegawai" => 2
"pendidikan" => 0
"sk_pengangkatan" => "123644747hhhh"
"tmt_pengangkatan" => "2016-06-01"
"jabatan" => 27
"jenis_kepegawaian" => 3
"unor" => 992
"unor_induk" => 28
"pejabat_pengangkat" => ""
"scan_izin_prinsip" => ""
"status" => 1
"deleted_at" => "2016-06-12 20:54:53"
"created_at" => "2016-06-07 07:19:04"
"updated_at" => "2016-06-12 13:54:53"
]
#relations: []
#hidden: []
#visible: []
#appends: []
#guarded: array:1 [▶]
#dateFormat: null
#casts: []
#touches: []
#observables: []
#with: []
#morphClass: null
+exists: true
+wasRecentlyCreated: false
}