我有以下路线:
Route::get('notes/main', function(){
$destinations = Destination::where('show', '=','1')->get();
$notes = Destination::find($destination->id)->notes()->get();
return View::make('notes.main')
->with('destinations', $destinations);
});
//关系模型:
<?php
class Destination extends Eloquent {
public function notes()
{
return $this->has_many('Note');
}
}
<?php
class Note extends Eloquent
{
public function destination()
{
return $this->belongs_to('Destination');
}
}
//看法:
@foreach( $destinations as $destination)
{{ $destination->name}}<br>
{ $notes->destination->text }} // this isn't echoed
@endforeach
过滤这个并定义 $destination->id 的正确方法是什么
谢谢
我将如何过滤循环内 if 语句中的注释?@if (isset($note->title) != 'shorttext')
@else
<p> {{ $note->text }} </p>
@endif
@endforeach