merhaba;
one to one yaptıklarımın hepsi çalışıyor. one to many hata alıyorum.
user tablom
id name
61 furkan
taksit tablom
id userid taksittutari
144 61 100
145 61 100
146 61 100
user modelim
<?php
namespace App;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Zizaco\Entrust\Traits\EntrustUserTrait;
class User extends Authenticatable
{
use EntrustUserTrait;
protected $fillable = [
'id','name', 'email',
];
/**
* The attributes that should be hidden for arrays.
*
* @var array
*/
protected $hidden = [
'password', 'remember_token',
];
protected $dates = ['kayittarihi'];
public function taksitler()
{
return $this->hasMany('App\Taksit', 'userid');
}
}
taksit model
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Taksit extends Model
{
public $fillable = ['id','userid','taksittutari','taksittarihi','odemeid','ilktaksit'];
public function User() {//ürüne ait Model
// return $this->belongsTo('App\Bolum', 'bolumid', 'id');
return $this->belongsTo('App\User', 'userid');
}
}
controller
$user = User::with('programlar')->with('okullar')->with('akademik')->with('egitim')->with('bolumler')->with('majorlar')->with('durumlar')->with('taksitler')->find($id);
return view('ogrenci.show', compact('user'));
blade
@foreach ($user as $u)
<tr>
<td> {{ $i=$i+1 }}</td>
<td> {{ $u->taksitler->taksittutari }}</td>
<td>
<div class="progress progress-xs">
<div class="progress-bar progress-bar-danger" style="width: 55%"></div>
</div>
</td>
<td><span class="badge bg-red">55%</span></td>
</tr>
@endforeach
hata
ErrorException in ffe8110b8792415ca88c096a4815b5335966ff9f.php line 783:
Trying to get property of non-object
in ffe8110b8792415ca88c096a4815b5335966ff9f.php line 783
at HandleExceptions->handleError('8', 'Trying to get property of non-object',