public function relation(Request $request)
    {
        $slug = $this->getSlug($request);
        $page = $request->input('page');
        $on_page = 50;
        $search = $request->input('search', false);
        $dataType = Voyager::model('DataType')->where('slug', '=', $slug)->first();

        foreach ($dataType->editRows as $key => $row) {
            if ($row->field === $request->input('type')) {
                $options = $row->details;
                $skip = $on_page * ($page - 1);

                // If search query, use LIKE to filter results depending on field label
                if ($search) {
                    $total_count = app($options->model)->where($options->label, 'LIKE', '%'.$search.'%')->count();
                    $relationshipOptions = app($options->model)->take($on_page)->skip($skip)
                        ->where($options->label, 'LIKE', '%'.$search.'%')
                        ->get();
                } else {
                    $total_count = app($options->model)->count();
                    $relationshipOptions = app($options->model)->take($on_page)->skip($skip)->get();
                }

                $results = [];
                foreach ($relationshipOptions as $relationshipOption) {
                    $results[] = [
                        'id'   => $relationshipOption->{$options->key},
                        'text' => $relationshipOption->{$options->label},
                    ];
                }

                return response()->json([
                    'results'    => $results,
                    'pagination' => [
                        'more' => ($total_count > ($skip + $on_page)),
                    ],
                ]);
            }
        }

        // No result found, return empty array
        return response()->json([], 404);
    }
public function relation(Request $request)
    {
        $slug = $this->getSlug($request);
        $page = $request->input('page');
        $on_page = 50;
        $search = $request->input('search', false);
        $dataType = Voyager::model('DataType')->where('slug', '=', $slug)->first();

        foreach ($dataType->editRows as $key => $row) {
            if ($row->field === $request->input('type')) {
                $options = $row->details;
                $skip = $on_page * ($page - 1);

                // If search query, use LIKE to filter results depending on field label
                if ($search) {
                    $total_count = app($options->model)->where($options->label, 'LIKE', '%'.$search.'%')->count();
                    $relationshipOptions = app($options->model)->take($on_page)->skip($skip)
                        ->where($options->label, 'LIKE', '%'.$search.'%')
                        ->get();
                } else {
                    $total_count = app($options->model)->count();
                    $relationshipOptions = app($options->model)->take($on_page)->skip($skip)->get();
                }

                $results = [];
                foreach ($relationshipOptions as $relationshipOption) {
                    $results[] = [
                        'id'   => $relationshipOption->{$options->key},
                        'text' => $relationshipOption->{$options->label},
                    ];
                }

                return response()->json([
                    'results'    => $results,
                    'pagination' => [
                        'more' => ($total_count > ($skip + $on_page)),
                    ],
                ]);
            }
        }

        // No result found, return empty array
        return response()->json([], 404);
    }
public function relation ( Request $ request ) { $ slug = $ this -> getSlug ( $ request ) ; $ page = $ request -> input ( 'page' ) ; $ on_page = 50 ; $ search = $ request -> input ( 'search' , false ) ; $ dataType = Voyager :: model ( 'DataType' ) -> where ( 'slug' , '=' , $ slug ) -> first ( ) ; foreach ( $ dataType -> editRows as $ key => $ row ) { if ( $ row -> field === $ request -> input ( 'type' ) ) { $ options = $ row -> details ; $ skip = $ on_page * ( $ page - 1 ) ; // If search query, use LIKE to filter results depending on field label if ( $ search ) { $ total_count = app ( $ options -> model ) -> where ( $ options -> label , 'LIKE' , '%' . $ search . '%' ) -> count ( ) ; $ relationshipOptions = app ( $ options -> model ) -> take ( $ on_page ) -> skip ( $ skip ) -> where ( $ options -> label , 'LIKE' , '%' . $ search . '%' ) -> get ( ) ; } else { $ total_count = app ( $ options -> model ) -> count ( ) ; $ relationshipOptions = app ( $ options -> model ) -> take ( $ on_page ) -> skip ( $ skip ) -> get ( ) ; } $ results = [ ] ; foreach ( $ relationshipOptions as $ relationshipOption ) { $ results [ ] = [ 'id' => $ relationshipOption -> { $ options -> key } , 'text' => $ relationshipOption -> { $ options -> label } , ] ; } return response ( ) -> json ( [ 'results' => $ results , 'pagination' => [ 'more' => ( $ total_count > ( $ skip + $ on_page ) ) , ] , ] ) ; } } // No result found, return empty array return response ( ) -> json ( [ ] , 404 ) ; }
Get BREAD relations data.

@param Request $request

@return mixed
Get BREAD relations data .