PHP code example of uteq / laravel-move

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

    

uteq / laravel-move example snippets




namespace App\Move;

use Uteq\Move\Fields\Id;
use Uteq\Move\Fields\Text;
use Uteq\Move\Resource;

class User extends Resource
{
    public static $model = \App\Models\User::class;

    public static string $title = 'name';

    public function fields()
    {
        return [
            Id::make(),

            Text::make('Name', 'name'),
        ];
    }
}



namespace App\Move;

use Uteq\Move\Fields\Id;
use Uteq\Move\Fields\Text;
use Uteq\Move\Resource;

class User extends Resource
{
    public static $model = \App\Models\User::class;

    public static string $title = 'name';

    public function fields()
    {
        return [
            Id::make(),

            Text::make('Naam', 'name')
                ->rules(['romForm(),

            Panel::make('Wachtwoord wijzigen', [
                Password::make('Wachtwoord', 'password', null)
                    ->creationRules($this->passwordRules())
                    -> public function actions()
    {
        return [];
    }
}

use Illuminate\Support\Facades\Route;

function register()
{
    Route::move('my-prefix');
}

use Uteq\Move\Facades\Move;

public function register()
{
    Move::resourceNamespace('App\\Resources', 'resources');
}

$table->json('meta')->nullable();

protected $casts ['meta' => 'json'];

Text::make('My meta value', 'meta.my_value'),

Move::useSidebarGroups(true);

Move::useSidebarGroups(false);

class User extends \Uteq\Move\Resource
{
    public static string $group = 'admin';
}

use \Uteq\Move\Facades\Move;

Move::resolveResource('resources.your-resource');

class StoreHandler
{
    public function __invoke(Model $model, array $input = [])
    {
        //... Basic validation
        
        $model->fill($input)->save();
        
        return $model;
    }
}

use Uteq\Move\Resource;

public function register()
{
    Resource::$defaultActionHandlers = [
        'update' => StoreResource::class,
        'create' => StoreResource::class,
        'delete' => DeleteResource::class,
    ];
}

use Uteq\Move\Resource;
use App\Actions\CustomResource;

class CustomResource extends Resource
{
    public array $actionHandlers = [
        'create' => CustomResource\Create::class,
        'update' => CustomResource\Update::class,
        'delete' => CustomResource\Delete::class,
    ];
}

public function beforeSave()
{
    return [
        fn($resource, $model, $data) => $data['rand'] = rand(1, 99),
        function($resource, $model, $data) {
            return $data['rand'] = rand(1, 99);
        },
        new MyCustomBeforeSaveAction,
    ];
}

public function afterSave()
{
    return [
        fn($resource, $model, $data) => $data['rand'] = rand(1, 99),
        function($resource, $model, $data) {
            return $data['rand'] = rand(1, 99);
        },
        new MyCustomAfterSaveAction,
    ];
}

Text::make('Name', 'name')
    ->beforeStore(function($value) {
        // ... Mutate the fields value to any given format.
        return $value;
    });
bash
php artisan move:install --team
bash
php artisan migrate
bash
php artisan vendor:publish --provider="Uteq\Move\MoveServiceProvider" --tag="move-config"
bash
php artisan move:resource User --model=User