1. Go to this page and download the library: Download teksite/extralaravel 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/ */
return [
// Hidden field used by the honeypot middleware and the @honeypot directive.
'honeypot' => [
'enabled' => true,
'status' => 403, // must be a 4xx/5xx code, otherwise 403 is used
'field_name' => env('HONEYPOT_FIELD_NAME', 'honeypot'),
],
// Application locales in which JalaliDateCast converts between Gregorian and Jalali dates.
'jalali_date_locales' => ['fa'],
// Locales treated as right-to-left by is_rtl().
'rtl_locales' => ['ar', 'fa', 'he', 'ur', 'ps', 'ku', 'ckb', 'sd', 'yi', 'dv', 'ug'],
// Length limits used by PasswordRule when no explicit values are passed to its constructor.
'password' => [
'min_length' => 8,
'max_length' => 128,
],
// Directory (relative to base_path()) that getStaticData() may read PHP files from.
'data_path' => 'app/data',
];
use Teksite\Extralaravel\Casts\IpCast;
protected $casts = [
'ip' => IpCast::class,
];
$model->ip = null; // stores the current request IP
$model->ip = '192.168.1.10'; // stored as given
$model->ip = 'not-an-ip'; // throws InvalidArgumentException
use Teksite\Extralaravel\Casts\JalaliDateCast;
protected $casts = [
'published_at' => JalaliDateCast::class,
];
app()->setLocale('fa');
$post->published_at; // "1403/05/10 14:30:00" (date-only columns: "1403/05/10")
$post->published_at = '1403/05/10 14:30'; // saved as "2024-07-31 14:30:00"
$post->published_at = '۱۴۰۳/۰۵/۱۰'; // Persian digits are accepted, saved as "2024-07-31"
use Teksite\Extralaravel\Casts\SlugCast;
protected $casts = [
'slug' => SlugCast::class,
];
use Teksite\Extralaravel\Rules\CodeMeliRule;
$request->validate([
'national_code' => ['
use Teksite\Extralaravel\Enums\MobilePatterns;
use Teksite\Extralaravel\Rules\MobileRule;
new MobileRule(); // Iran
new MobileRule('germany'); // by name
new MobileRule('DE'); // by ISO code
new MobileRule(MobilePatterns::TURKEY); // by enum
new MobileRule(['iran', MobilePatterns::USA, 'iraq']); // any of several countries
use Teksite\Extralaravel\Rules\PasswordRule;
new PasswordRule(); // limits from config: 8 to 128 characters
new PasswordRule(10); // minimum 10
new PasswordRule(10, 64); // minimum 10, maximum 64
use Teksite\Extralaravel\Rules\NoHtmlRule;
'name' => ['
use Teksite\Extralaravel\Rules\NeverPassRule;
'field' => [new NeverPassRule()],
namespace App\Http\Requests;
use Teksite\Extralaravel\Http\ApiFormRequest;
class StoreUserRequest extends ApiFormRequest
{
public function authorize(): bool
{
return true;
}
public function rules(): array
{
return [
'name' => ['
use Illuminate\Foundation\Auth\User as Authenticatable;
use Teksite\Extralaravel\Traits\MustVerifyPhone;
class User extends Authenticatable
{
use MustVerifyPhone;
protected function casts(): array
{
return ['phone_verified_at' => 'datetime'];
}
// Required: the package does not depend on any SMS provider.
public function sendPhoneVerificationNotification(): void
{
// Send an SMS or notification here.
}
}
use App\Models\User;
use Teksite\Extralaravel\Traits\TrashMethods;
class UserTrashManager
{
use TrashMethods;
protected function getModelClass(): string
{
return User::class;
}
}
$manager = new UserTrashManager();