You see, I have a table Game with the variable nombre
, which obviously is a string of characters.
Well, I have created a form to search for a row using a substring:
@extends('layouts.app')
@section('content')
<div class="container">
<div class="row justify-content-center">
<div class="col-md-8">
<div class="card">
<div class="card-header">Introduzca el nombre del juego que busca</div>
<div class="card-body">
<form method="POST" action="busca_nombre" novalidate>
@csrf
<div class="form-group row">
<label for="nombre" class="col-md-4 col-form-label text-md-right">Nombre del juego que busca</label>
<div class="col-md-6">
<input id="nombre" type="text" class="form-control{{ $errors->has('nombre') ? ' is-invalid' : '' }}" name="nombre" value="{{ old('nombre') }}" required autofocus>
@if($errors->has('nombre'))
<span class="invalid-feedback">
<strong>{{ $errors->first('nombre') }}</strong>
</span>
@endif
</div>
</div>
<input type="hidden" name="user_id" value="{{ auth()->user()->id }}"/>
<div class="form-group row mb-0">
<div class="col-md-6 offset-md-4">
<button type="submit" class="btn btn-primary">
Buscar Juego
</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
@endsection
And this happened to the following function:
public function encuentroNombre(NombreRequest $request){
public function encuentroNombre(NombreRequest $request){
$juegos=Juego::where(stripos('nombre',$request->nombre),'>',0)->orderBy('numero')->get();
if(count($juegos))
return view('saludos',compact('juegos'));
else
return back()->with('message',['danger','No se ha encontrado ningun juego cuyo nombre contenga la palabra escrita.']);
}
Well, I get this error message:
SQLSTATE [42S22]: Column not found: 1054 Unknown column '' in 'where clause '(SQL: select * from
juegos
where' '> 0 order bynumero
asc)
How do I indicate that I want you to check if a substring is in the variable nombre
of the table Game?