PHP code example of mahdimajidzadeh / ds

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

    

mahdimajidzadeh / ds example snippets


// in your CSP middleware
$nonce = Vite::useCspNonce(); // generates one; or pass your own

$response = $next($request);
$response->headers->set('Content-Security-Policy', "script-src 'self' 'nonce-{$nonce}' 'unsafe-eval'; style-src 'self' 'unsafe-inline'");

use MajidDs\Mds;
use MajidDs\Support\{Persian, Jalali, Iran};

Mds::toman(2500000);                       // ۲٬۵۰۰٬۰۰۰ تومان
Mds::jalali(now(), 'Y/m/d');               // ۱۴۰۵/۰۵/۲۹
Mds::ago(now()->subHours(3));              // ۳ ساعت پیش
Mds::fileSize(162400);                     // ۱۵۹ کیلوبایت
Persian::digits('order 123');              // order ۱۲۳
Persian::latinDigits('۰۹۱۲');              // 0912
Jalali::fromGregorian(2026, 8, 20);        // [1405, 5, 29]
Jalali::toGregorian(1405, 5, 29);          // [2026, 8, 20]
Iran::normalizeMobile('+98 912 345 6789'); // 09123456789
Iran::nationalId('0013542877');            // true

return [
    'currency' => 'toman',        // default currency for prices
    'persian_digits' => true,     // global default; override per component with :fa="..."
];
bash
php artisan vendor:publish --tag=mds-config
bash
php artisan vendor:publish --tag=mds-views   # -> resources/views/mds/