7 months ago

laravel scout returns empty

Posted 7 months ago by hasen39

my model


namespace App\Organization;

use Illuminate\Database\Eloquent\Model;
use Laravel\Scout\Searchable;
use Illuminate\Foundation\Auth\User as Authenticatable;
use App\ExamTaker\Answer;

class ExamTaker extends Authenticatable
{   use Searchable;
    protected $guards = "exam_taker";

    protected $table="exam_taker";
    protected $primaryKey="username";
    protected $keyType="string";
    public $incrementing=false;

    protected $hidden=[
    public function Answer(){
       return $this->hasMany(Answer::class,'username','username')->whereColumn('answer','correct');

    public function getScoutKey()
        return $this->username;


and my controller


namespace App\Http\Controllers\Organization;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Organization\ExamTaker;

class SerachingController extends Controller
    public function search_exam_taker(Request $request){
        'search' => 'string|required',


       $error = ['errors'=>'result not found'];
        // dd($request->get('search'));
       $result = ExamTaker::search($request->get('search'))->get();
        return $result;
       if ($result->count()>0) {
          return $result;

       return $error;

i asked it before but no one solve please any one

Please sign in or create an account to participate in this conversation.