Answer the question
In order to leave comments, you need to log in
Why can't link tables in Laravel?
controller:
public function getMyInvest() {
$myInvest = Invest::->where('user_id', Session::get('id_user'))->get();
return view('invest.my-invest', ['invests' => $myInvest]);
}
@foreach($invests as $invest)
<tr>
<th scope="row">{{$invest->id}}</th>
<td>{{$invest->tarif_id->name}}</td>
<td>{{$invest->created_at}} - 16.03.18</td>
<td>{{$invest->sum}}руб.</td>
<td><a class="glyphicon icon-remove" href="" > </a></td>
</tr>
@endforeach
class Invest extends Model
{
public $timestamps = false;
public function tarif_id() {
return $this->hasOne('App\Models\Invest_tarif', 'id');
}
}
Answer the question
In order to leave comments, you need to log in
The error is obvious if you even try to read the documentation: follow the codestyle
(tarif_id -> tariff, Invest_tarif -> InvestTariff) and everything will work for you.
It's also interesting how you try to use the created_at field if timestamps are disabled ..
PS: is there a new operator in php ::->
?))
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question