PHP code example of internexus / larapid

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

    

internexus / larapid example snippets




namespace App\Providers;

use App\Entities\UserEntity;
use Illuminate\Support\ServiceProvider;
use Internexus\Larapid\Facades\Larapid;

class LarapidServiceProvider extends ServiceProvider
{
    public function register()
    {
        Larapid::entities([
            UserEntity::class,
        ]);
    }
}



namespace App\Entities;

use App\Models\User;
use Internexus\Larapid\Entities\Entity;
use Internexus\Larapid\Fields\Email;
use Internexus\Larapid\Fields\Password;
use Internexus\Larapid\Fields\Text;

class UserEntity extends Entity
{
    public static $model = User::class;

    public static $title = 'Usuários';

    public function fields() {
        return [
            Text::make('Nome', 'name')->rules('

Text::make('Label', 'column')

Date::make('Created at', 'created_at')

Datetime::make('Created at', 'created_at')

Boolean::make('Public')

Email::make('E-mail')

Password::make('Password')

Url::make('Url')

Money::make('Price')

Number::make('Price')->min(10)->max(100)

Select::make('Status')->options([1 => 'Approved', 2 => 'Cancelled'])

Textarea::make('Content')

Media::make('Featured image', 'media_id')
     ->accept(['jpg', 'png'])
     ->maxSize(100000) // in bytes
     ->minDimension(100, 100)
     ->maxDimension(1920, 1080)

HasMany::make('User posts', 'user_id', PostEntity::class, 'posts')

BelongsTo::make('User role', 'role_id', UserEntity::class)

php artisan vendor:publish --tag=larapid