Viewed   58 times

I'm using the below code to pull some results from the database with Laravel 5.

BookingDates::where('email', Input::get('email'))->orWhere('name', 'like', Input::get('name'))->get()

However, the orWhereLike doesn't seem to be matching any results. What does that code produce in terms of MySQL statements?

I'm trying to achieve something like the following:

select * from booking_dates where email='' or name like '%John%'



If you want to see what is run in the database use dd(DB::getQueryLog()) to see what queries were run.

Try this

BookingDates::where('email', Input::get('email'))
    ->orWhere('name', 'like', '%' . Input::get('name') . '%')->get();
Thursday, September 29, 2022

after reading error msg in CMD (DOS) and check laravel documentation

error in length i dont know if any one see this error before or not but when i edit length its work

i edit 3 migration as below :-

1 -1- Schema::create('users', function (Blueprint $table) { $table->increments('id'); $table->string('name'); $table->string('username')->unique(); $table->string('email')->unique(); $table->string('password'); $table->rememberToken(); $table->timestamps(); $table->integer('role'); });

and now its

        Schema::create('users', function (Blueprint $table) {


number 2 it was

 Schema::create('password_resets', function (Blueprint $table) { $table->string('email')->index(); $table->string('token'); $table->timestamp('created_at')->nullable(); });

and now its :-

        Schema::create('passwordreset', function (Blueprint $table) {

number 3 it was :-

3- Schema::create('tweets', function (Blueprint $table) { $table->increments('id'); $table->integer('user_id')->unsigned()->index(); $table->text('text'); $table->timestamps(); });

now its :-

        Schema::create('tweets', function (Blueprint $table) {
Tuesday, November 22, 2022

A bit of a late response but I figured it out. This is my solution.

I First added this function to my User Modal Class.

public function getRanking(){
   $collection = collect(User::orderBy('wins', 'DESC')->get());
   $data       = $collection->where('id', $this->id);
   $value      = $data->keys()->first() + 1;
   return $value;

Now in my view I run my getRanking() function.

@foreach($ranking as $key => $rankings)
        <td>{{ $rankings->getRanking() }}</td>
        <td><a href="{{ route('profileView', ['id' => $rankings->id]) }}">{{ $rankings->username }}</a></td>
        <td>{{ $rankings->wins }}</td>
        <td>{{ $rankings->losses }}</td>

I am using my array keys to determine the user ranking.

Good night!

Monday, August 1, 2022

Use DB::raw()

User::where(DB::raw('upper(name)'), 'LIKE', '%FOO%')->get()

It would generate query like this

"select * from `users` where upper(name) LIKE ?"
Monday, August 15, 2022

I Solved My Problem Myself by Changing My create_users_table.php


use IlluminateSupportFacadesSchema;
use IlluminateDatabaseSchemaBlueprint;
use IlluminateDatabaseMigrationsMigration;

class CreateUsersTable extends Migration
     * Run the migrations.
     * @return void
    public function up()
        Schema::create('users', function (Blueprint $table) {

     * Reverse the migrations.
     * @return void
    public function down()
Monday, September 19, 2022
Only authorized users can answer the search term. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :