as we go to make everything easy, we are today releasing a very very good package to build a flutter app by just using 1 command to generate full CRUD from your schema and generated TomatoPHP files
Requirements
please check that you have flutter installed and working on your system by check
flutter doctor
and you must have at least one emulator or device connected to your system
and you must have 2 packages working on your Laravel app Tomato Admin and Tomato CRM
after installing the package please make sure that you add a guard of accounts
to your auth.php config like this
'guards' => [
'web' => [
'driver' => 'session',
'provider' => 'users',
],
'accounts' => [
'driver' => 'session',
'provider' => 'accounts',
],
],
...
'providers' => [
'users' => [
'driver' => 'eloquent',
'model' => App\Models\User::class,
],
'accounts' => [
'driver' => 'eloquent',
'model' => \TomatoPHP\TomatoCrm\Models\Account::class,
],
],
Installation
composer require tomatophp/tomato-flutter
now you are ready to generate a new app
to generate a new app you just need to run this command
php artisan tomato-flutter:generate
Generate Module
to generate a new module you just need to run this command
php artisan tomato-flutter:module
Generate Controller
to generate a new controller you just need to run this command
php artisan tomato-flutter:controller
Generate Service
to generate a new service you just need to run this command
php artisan tomato-flutter:service
Generate CRUD
to generate a new CRUD from any table on your tomato-php generated CRUDs just need to run this command
php artisan tomato-flutter:crud
please note that the generated files will match only APIs generated by TomatoPHP and you need to add API routes to the api.php
Route::middleware(['auth:sanctum'])->name('api.')->group(function () {
Route::get('customers', [\Modules\Customers\Http\Controllers\CustomerController::class, 'index'])->name('customers.index');
Route::post('customers', [\Modules\Customers\Http\Controllers\CustomerController::class, 'store'])->name('customers.store');
Route::get('customers/{model}', [\Modules\Customers\Http\Controllers\CustomerController::class, 'show'])->name('customers.show');
Route::post('customers/{model}', [\Modules\Customers\Http\Controllers\CustomerController::class, 'update'])->name('customers.update');
Route::delete('customers/{model}', [\Modules\Customers\Http\Controllers\CustomerController::class, 'destroy'])->name('customers.destroy');
});
Change Endpoint
if you like to change the endpoint to match your URL you can change it from the file
flutter/YOUR_APP/lib/config/Config.dart
and change it to your endpoint, if you are using Android you check the app please make the endpoint hit to http://10.0.2.2:8000/api
and run
php artisan serv
on your app.
Top comments (0)