@if(isset($options->model) && isset($options->type)) @if(class_exists($options->model)) @php $relationshipField = $row->field; @endphp @if($options->type == 'belongsTo') @if(isset($view) && ($view == 'browse' || $view == 'read')) @php $relationshipData = (isset($data)) ? $data : $dataTypeContent; $model = app($options->model); $query = $model::where($options->key,$relationshipData->{$options->column})->first(); @endphp @if(isset($query))

{{ $query->{$options->label} }}

@else

{{ __('voyager::generic.no_results') }}

@endif @else @endif @elseif($options->type == 'hasOne') @php $relationshipData = (isset($data)) ? $data : $dataTypeContent; $model = app($options->model); $query = $model::where($options->column, '=', $relationshipData->{$options->key})->first(); @endphp @if(isset($query))

{{ $query->{$options->label} }}

@else

{{ __('voyager::generic.no_results') }}

@endif @elseif($options->type == 'hasMany') @if(isset($view) && ($view == 'browse' || $view == 'read')) @php $relationshipData = (isset($data)) ? $data : $dataTypeContent; $model = app($options->model); $selected_values = $model::where($options->column, '=', $relationshipData->{$options->key})->get()->map(function ($item, $key) use ($options) { return $item->{$options->label}; })->all(); @endphp @if($view == 'browse') @php $string_values = implode(", ", $selected_values); if(mb_strlen($string_values) > 25){ $string_values = mb_substr($string_values, 0, 25) . '...'; } @endphp @if(empty($selected_values))

{{ __('voyager::generic.no_results') }}

@else

{{ $string_values }}

@endif @else @if(empty($selected_values))

{{ __('voyager::generic.no_results') }}

@else
@foreach($selected_values as $selected_value) {{-- TODO: This could allows us to expand on posts attachments previews on admin --}} @if($relationshipField === 'payment_request_hasmany_attachment_relationship')
@include('vendor.voyager.partials.voyager-file-preview-box', ['asset' => $selected_value])
@else
{{ $selected_value }}
@endif @endforeach
@endif @endif @else @php $model = app($options->model); $query = $model::where($options->column, '=', $dataTypeContent->{$options->key})->get(); @endphp @if(isset($query))
@foreach($query as $query_res) @if($relationshipField === 'payment_request_hasmany_attachment_relationship' && $query_res instanceof \App\Model\Attachment) @include('vendor.voyager.partials.voyager-file-preview-box', ['asset' => $query_res->filename]) @else
{{ $query_res->{$options->label} }}
@endif @endforeach
@else

{{ __('voyager::generic.no_results') }}

@endif @endif @elseif($options->type == 'belongsToMany') @if(isset($view) && ($view == 'browse' || $view == 'read')) @php $relationshipData = (isset($data)) ? $data : $dataTypeContent; $selected_values = isset($relationshipData) ? $relationshipData->belongsToMany($options->model, $options->pivot_table, $options->foreign_pivot_key ?? null, $options->related_pivot_key ?? null, $options->parent_key ?? null, $options->key)->get()->map(function ($item, $key) use ($options) { return $item->{$options->label}; })->all() : array(); @endphp @if($view == 'browse') @php $string_values = implode(", ", $selected_values); if(mb_strlen($string_values) > 25){ $string_values = mb_substr($string_values, 0, 25) . '...'; } @endphp @if(empty($selected_values))

{{ __('voyager::generic.no_results') }}

@else

{{ $string_values }}

@endif @else @if(empty($selected_values))

{{ __('voyager::generic.no_results') }}

@else @endif @endif @else @endif @endif @else cannot make relationship because {{ $options->model }} does not exist. @endif @endif