PHP code example of rmscms / core

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

    

rmscms / core example snippets




namespace App\Http\Controllers\Admin;

use RMS\Core\Controllers\Admin\AdminController;
use RMS\Core\Contracts\List\HasList;
use RMS\Core\Contracts\Form\HasForm;

class UsersController extends AdminController implements HasList, HasForm
{
    public function table(): string
    {
        return 'users';
    }
    
    public function modelName(): string
    {
        return \App\Models\User::class;
    }
    
    public function baseRoute(): string
    {
        return 'users';
    }
    
    public function routeParameter(): string
    {
        return 'user';
    }
    
    public function getListFields(): array
    {
        return [
            Field::make('id')->withTitle('ID')->sortable(),
            Field::make('name')->withTitle('Name')->searchable(),
            Field::make('email')->withTitle('Email')->searchable(),
            Field::make('created_at')->withTitle('Created')->type(Field::DATE_TIME),
        ];
    }
    
    public function getFieldsForm(): array
    {
        return [
            Field::string('name', 'Name')->

use RMS\Core\Helpers\RouteHelper;

RouteHelper::adminResource(UsersController::class, 'admin.users');

Field::string('name', 'Name')           // Text input
Field::number('age', 'Age')             // Number input  
Field::boolean('active', 'Active')      // Boolean toggle
Field::select('role', 'Role', $options) // Select dropdown
Field::date('birth_date', 'Birth Date') // Persian date picker
Field::image('avatar', 'Avatar')        // Image upload
Field::price('amount', 'Amount')        // Price with formatter

public function getStats(): array
{
    return [
        [
            'title' => 'Total Users',
            'value' => number_format(1234),
            'unit' => 'users',
            'icon' => 'users',
            'color' => 'primary',
            'colSize' => 'col-xl-3 col-md-6'
        ]
    ];
}

// Always use translation keys
trans('admin.users_management')
trans('admin.create_new_user')
trans('admin.user_created_successfully')