I
I
Igor Koch2017-07-03 15:49:43
Laravel
Igor Koch, 2017-07-03 15:49:43

How to make additional communication in Laravel?

The model has two functions

public function variant(){
  return $this->belongsTo('App\Variant')->whereHas('product', function ($query) {
    $query->where('visible', 1);
  });
}

public function varianto(){
  return $this->belongsTo('App\Variant')->whereHas('product', function ($query) {
    $query->where('visible', 1);
  });
}

in template
@foreach($order->items as $item)
  @if($i++)
    <hr>
  @endif

  {{ $item->variant }}1
  {{ $item->varianto }}2
@endforeach

$item->variant - A variant object arrives,
$item->varianto - Null
How to make an additional link?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question