PHP code example of rush-app / core

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

    

rush-app / core example snippets

 artisan core:install
 artisan migrate

Route::resource('posts', 'PostController');

Schema::create('posts', function (Blueprint $table) {
   $table->id();
   $table->boolean('published')->default(false);
   $table->timestamp('published_at')->nullable();
   $table->foreignId('user_id');
   $table->timestamps();
});

Schema::create('post_translations', function (Blueprint $table) {
   $table->id();
   $table->string('title')->nullable();
   $table->string('description')->nullable();
   $table->foreignId('post_id')->constrained()->onDelete('cascade');
   $table->foreignId('language_id');
});

    class Post extends RushApp\Core\Models\BaseModel
    {
       use HasFactory;
   
       protected $fillable = [
          'published',
          'published_at',
          'user_id',
       ];
   
       protected $dates = [
            'published_at',
       ];
   
       public function user(): BelongsTo
       {
            return $this->belongsTo(User::class);
       }
    }

    class PostTranslation extends RushApp\Core\Models\BaseModel
    {
       use HasFactory;
   
       protected $fillable = [
          'title',
          'description',
          'post_id',
          'language_id',
       ];
   
       public $timestamps = false;
    }

    class PostController extends RushApp\Core\Controllers\BaseController
    {
   
       // The name of the model must be indicated in each controller
       protected string $modelClassController = Post::class;
   
       // FormRequest class for validation store process.
       protected ?string $storeRequestClass = StorePostRequest::class;
   
       // FormRequest class for validation update process.
       protected ?string $updateRequestClass = UpdatePostRequest::class;
   
       // Relations of model that can be attached to response (available for 'index' and 'show' method).
       // NOTE: this names should be the same with method in model (Eloquent relations).
       protected array $withRelationNames = [
            'user',
       ];
    }
 Route::post('login', [\RushApp\Core\Controllers\BaseAuthController:class,'login']);