PHP code example of ismailelbery / laravel-arabic-search

1. Go to this page and download the library: Download ismailelbery/laravel-arabic-search library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

ismailelbery / laravel-arabic-search example snippets


Article::arabicSearch('اسلام')->paginate(20);   // matches إسلام, الإسلام, ...

'rules' => [
    'normalize_dad_zah' => true,
],

use IsmailElbery\ArabicSearch\Concerns\HasArabicSearch;

class Article extends Model
{
    use HasArabicSearch;

    protected array $arabicSearchable = ['title', 'body'];
}

Schema::table('articles', function (Blueprint $table) {
    $table->arabicNormalized(['title', 'body']); // adds title_normalized, body_normalized
});

use IsmailElbery\ArabicSearch\Facades\ArabicSearch;

ArabicSearch::normalize('مُحَمَّدٌ');          // "محمد"
ArabicSearch::tokenize('بسم الله الرحمن');    // ["بسم","الله","الرحمن"]

User::whereArabicVariants('name', 'اسلام')->paginate();
DB::table('users')->whereArabicVariants('name', 'اسلام')->get();

// Two (or more) columns — OR-ed together:
User::whereArabicVariants(['first_name', 'last_name'], 'اسلام')->get();

// Composes with other conditions:
DB::table('docs')->where('pinned', true)
    ->orWhereArabicVariants('title', 'اسلام')->get();
bash
php artisan arabic-search:rebuild "App\Models\Article"