mardi 26 juin 2018

In Laravel scout elastic search engine join query is not working

    I am working on elastic search using laravel scout , my searching working correctly for relational table  ,but I got below error for join query." Method Laravel\Scout\Builder::with does not exist." , joins are working or not working in search.what is other solution for this.

In my model of post model I have written following method.In toSearchableArray I have search data from post and user tables (users name),

        public function toSearchableArray()
            {
                $array = [
                    'user_id' => $this->user_id,
                    'post' => $this->post,
                ];
                $extra_data = [];
                $extra_data['name'] = $this->user->name;

                return array_merge($array, $extra_data);
            }

            /**
             * Get the index name for the model.
             *
             * @return string
             */
            public function searchableAs()
            {
                return 'posts_index';
            }

            public function user()
            {
                return $this->belongsTo('App\User');
            }

In Repository I written "public function elasticSearch($search)" this function to get user and post data. In repository I have wrriten this function , I got error for with method I want to show data from post and user tables how I show it?

         public function elasticSearch($search)
            {
                return $this->post->search($search)->with('user')->get();
                //$ss = Post::search($search)->get();
            }



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire