PHP code example of vpremiss / arabicable

1. Go to this page and download the library: Download vpremiss/arabicable 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/ */

    

vpremiss / arabicable example snippets


  use Illuminate\Database\Schema\Blueprint;
  use Illuminate\Support\Facades\Schema;
  // ...
  Schema::create('notes', function (Blueprint $table) {
      $table->id();
      $table->arabicText('content'); // this also creates `content_searchable` and `content_with_harakat` of the same type
      $table->timestamps();
  });
  

  use Illuminate\Database\Eloquent\Model;
  use VPremiss\Arabicable\Traits\Arabicable;

  class Note extends Model
  {
      use Arabicable;

      protected $fillable = ['content']; // or you'd guard the property differently
  }
  

  // When spacing_after_punctuation_only is set to `false` in configuration (default)

  $note = Note::create([
      'content' => '"الجَمَاعَةُ مَا وَافَقَ الحَقّ، أَنْتَ الجَمَاعَةُ وَلَو كُنْتَ وَحْدَكْ."',
  ]);

  echo $note->content; // "الجماعة ما وافق الحق ، أنت الجماعة ولو كنت وحدك ."
  echo $note->{ar_with_harakat('content')}; // "الجَمَاعَةُ مَا وَافَقَ الحَقّ ، أَنْتَ الجَمَاعَةُ وَلَو كُنْتَ وَحْدَكْ ."
  echo $note->{ar_searchable('content')}; // "الجماعة ما وافق الحق انت الجماعة ولو كنت وحدك"

  // When spacing_after_punctuation_only is set to `true` in configuration

  $seriousContentPoliticiansDoNotLike = <<<Arabic
  - قال المُزني: سألتُ الشافعي عن مسألة في "الكلام"، فقال: سَلني عن شيء إذا أخطأتَ فيه قُلتُ "أخطأتَ!"، ولا تسألني عن شيء إذا أخطأتَ فيه قُلتُ "كفرتَ".
  Arabic;

  $note->update(['content' => $seriousContentPoliticiansDoNotLike]);

  echo $note->content;
  // - قال المزني: سألت الشافعي عن مسألة في "الكلام"، فقال: سلني عن شيء إذا أخطأت فيه قلت "أخطأت!"، ولا تسألني عن شيء إذا أخطأت فيه قلت "كفرت".
  echo $note->{ar_with_harakat('content')};
  // - قال المُزني: سألتُ الشافعي عن مسألة في "الكلام"، فقال: سَلني عن شيء إذا أخطأتَ فيه قُلتُ "أخطأتَ!"، ولا تسألني عن شيء إذا أخطأتَ فيه قُلتُ "كفرتَ".
  echo $note->{ar_searchable('content')};
  // قال المزني سالت الشافعي عن مسالة في الكلام فقال سلني عن شيء اذا اخطات فيه قلت اخطات ولا تسالني عن شيء اذا اخطات فيه قلت كفرت
  
bash
   php artisan arabicable:install
   
bash
   php artisan vendor:publish --tag="arabicable-config" --force
   php artisan vendor:publish --tag="arabicable-migrations" --force
   php artisan vendor:publish --tag="arabicable-seeders" --force