PHPackages                             tomatophp/laravel-tomato - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. tomatophp/laravel-tomato

ActiveLibrary[API Development](/categories/api)

tomatophp/laravel-tomato
========================

Basic Laravel Helpers for requests and controllers build by TomatoPHP

v1.0.0(2y ago)14MITPHPPHP ^8.1|^8.2

Since Mar 10Pushed 2y ago1 watchersCompare

[ Source](https://github.com/tomatophp/laravel-tomato)[ Packagist](https://packagist.org/packages/tomatophp/laravel-tomato)[ RSS](/packages/tomatophp-laravel-tomato/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (1)Versions (2)Used By (0)

[![Screenshot](https://github.com/tomatophp/laravel-tomato/raw/master/art/screenshot.png)](https://github.com/tomatophp/laravel-tomato/blob/master/art/screenshot.png)

Laravel Tomato
==============

[](#laravel-tomato)

Basic Laravel Helpers for requests and controllers build by TomatoPHP

Installation
------------

[](#installation)

```
composer require tomatophp/laravel-tomato
```

Features
--------

[](#features)

- `Tomato::menu()` inject and handle menus across your application
- `Tomato::widget()` inject and handle widgets across your application
- `Tomato::slot()` inject and handle slots across your application
- `Tomato::request()` handle and validate requests
- `Tomato::response()` handle api responses

Usage
-----

[](#usage)

you can use the helper by Facade class or by using the helper function

```
use TomatoPHP\LaravelTomato\Facades\Tomato::register();
```

or just

```
tomato()::register();
```

Register Components
-------------------

[](#register-components)

you can register your menu, widget, or slot in your service provider `boot()` method

```
Tomato::register([
    Menu::make()
        ->group(__('CRM'))
        ->label(__('Name'))
        ->route('home')
        ->icon('home'),
    Widget::make()
        ->group(__('CRM'))
        ->label(__('Name'))
        ->counter(100)
        ->icon("bx bx-user"),
    Slot::make()
        ->position(Positions::dashboardTop)
        ->view('dashboard-top'),
]);
```

you can register any type of component and we will check it and handle it for you

all components have a macroable methods to add more functionality to it.

Get Components
--------------

[](#get-components)

you can get your components like this

```
Tomato::menu()->get();
Tomato::widget()->get();
Tomato::slot()->get();
```

it will return an array of registered components for you

Request
-------

[](#request)

you can use the request helper to handle and validate your requests like this

```
return Tomato::request()->index(
   request: request(),
   model: App\Models\User::class,
);
```

### 🔁 Index Request

[](#-index-request)

this method returns view or JsonResponse based on the request type. and we get the request type by check if the route has `auth:sanctum` middleware or not.

this method accept some arguments:

- `request` the request object
- `model` the model you want to get
- `view` the view you want to return
- `table` the table class you want to use
- `data` the data you want to pass to the view
- `api` if you want to return JsonResponse or not
- `resource` resource class to resource your returned data
- `query` if you want to add some query to the model
- `filters` if you want to add some filters to the table

```
public function index(Request $request): View|JsonResponse
{
    return Tomato::index(
        request: $request, //Required
        model: $this->model, //Required
        view: 'users.index',
        table: \App\Tables\UserTable::class,
        data: [
            'name' => 'john doe',
        ],
        api: true,
        resource: UserResource::class,
        query: User::query()->where('is_activated',true),
        filters: [
            'is_activated',
        ],
    );
}
```

### 🔁 JSON Request

[](#-json-request)

this method return only json response of the model to make it easy to access it with `x-splade-select` or `x-tomato-admin-select`

this method accept some arguments:

- `request` the request object
- `model` the model you want to get
- `data` the data you want to pass to the view
- `paginate` if you want to paginate the response or not
- `query` if you want to add some query to the model
- `filters` if you want to add some filters to the table

```
public function api(Request $request): JsonResponse
{
    return Tomato::json(
        request: $request, //Required
        model: \App\Models\User::class, //Required
        data: [
            'name' => 'john doe',
        ],
        paginate: 10,
        query: User::query()->where('is_activated',true),
        filters: [
            'is_activated',
        ],
    );
}
```

### 🔁 Get Request

[](#-get-request)

this method returns view or JsonResponse based on the request type. and we get the request type by check if the route has `auth:sanctum` middleware or not.

this method accept some arguments:

- `model` the model you want to get
- `view` the view you want to return
- `data` the data you want to pass to the view
- `hasMedia` if you want to get the media of the model or not
- `collection [array]` the media collection you want to get as array take true if it's multi or false if it's single
- `attach [array]` to attach some data to the model
- `api` if you want to return JsonResponse or not
- `resource` resource class to resource your returned data
- `query` if you want to add some query to the model

```
public function show(\App\Models\User $model): View|JsonResponse
{
    return Tomato::get(
        model: $model, //Required
        view: 'users.show', //Required
        data: [
            'name' => 'john doe',
        ],
        hasMedia: true,
        collection: [
            'avatar' => false,
            'gallery' => true
        ],
        attach: [
            'roles' => $model->roles,
        ],
        api: true,
        resource: UserResource::class,
        query: User::query()->where('is_activated',true)
    );
}
```

### 🔁 Store Request

[](#-store-request)

this method returns RedirectResponse or JsonResponse based on the request type. and we get the request type by check if the route has `auth:sanctum` middleware or not.

this method accept some arguments:

- `request` the request object
- `model` the model you want to get
- `validation` the validation rules you want to use
- `message` the message you want to return with the response
- `validationError` the message you want to return if the validation failed
- `redirect` the redirect route you want to redirect to
- `hasMedia` if you want to get the media of the model or not
- `collection [array]` the media collection you want to get as array take true if it's multi or false if it's single
- `api` if you want to return JsonResponse or not

```
public function store(Request $request): RedirectResponse|JsonResponse
{
    $response = Tomato::store(
        request: $request, //Required
        model: \App\Models\User::class, //Required
        validation: [
            'name' => 'required|string|max:255',
            'email' => 'required|string|email|max:255|unique:users',
        ],
        message: __('User created successfully'),
        validationError: __('Error When Try To Store User'),
        redirect: 'admin.users.index',
        hasMedia: true,
        collection: [
            'avatar' => false,
            'gallery' => true
        ],
        api: true,
    );

    if($response instanceof JsonResponse){
        return $response;
    }

    return $response->redirect;
}
```

### 🔁 Update Request

[](#-update-request)

this method returns RedirectResponse or JsonResponse based on the request type. and we get the request type by check if the route has `auth:sanctum` middleware or not.

this method accept some arguments:

- `request` the request object
- `model` the model you want to get
- `validation` the validation rules you want to use
- `message` the message you want to return with the response
- `validationError` the message you want to return if the validation failed
- `redirect` the redirect route you want to redirect to
- `hasMedia` if you want to get the media of the model or not
- `collection [array]` the media collection you want to get as array take true if it's multi or false if it's single
- `api` if you want to return JsonResponse or not

```
public function update(Request $request, \App\Models\User $model): RedirectResponse|JsonResponse
{
    $response = Tomato::update(
        request: $request, //Required
        model: $model, //Required
        validation: [
            'name' => 'required|string|max:255',
            'email' => 'required|string|email|max:255|unique:users',
        ],
        message: __('User updated successfully'),
        redirect: 'admin.users.index',
        hasMedia: true,
        collection: [
            'avatar' => false,
            'gallery' => true
        ],
        api: true,
    );

     if($response instanceof JsonResponse){
         return $response;
     }

     return $response->redirect;
}
```

### 🔁 Destroy Request

[](#-destroy-request)

this method returns RedirectResponse or JsonResponse based on the request type. and we get the request type by check if the route has `auth:sanctum` middleware or not.

this method accept some arguments:

- `model` the model you want to get
- `message` the message you want to return with the response
- `redirect` the redirect route you want to redirect to
- `api` if you want to return JsonResponse or not

```
public function destroy(\App\Models\User $model): RedirectResponse|JsonResponse
{
    $response = Tomato::destroy(
        model: $model, //Required
        message: __('User deleted successfully'), //Required
        redirect: 'admin.users.index',
    );

    if($response instanceof JsonResponse){
        return $response;
    }

    return $response->redirect;
}
```

Request With Media
------------------

[](#request-with-media)

to make media handling work you must install `spatie/laravel-medialibrary` package and run the migration

```
composer require spatie/laravel-medialibrary
php artisan vendor:publish --provider="Spatie\MediaLibrary\MediaLibraryServiceProvider" --tag="migrations"
php artisan migrate
```

and your model must use `HasMedia` trait

```
use Spatie\MediaLibrary\HasMedia;
use Spatie\MediaLibrary\InteractsWithMedia;

class User extends Model implements HasMedia
{
    use InteractsWithMedia;
}
```

Handel Alerts
-------------

[](#handel-alerts)

and we have handel Toaster for you if you are using Splade it will working automatically and if you have `yoeunes/toastr` package it will working fine too. or you can use fetch `toaster` variable from session to get the flash messages.

Support
-------

[](#support)

you can join our discord server to get support [TomatoPHP](https://discord.gg/Xqmt35Uh)

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Security
--------

[](#security)

Please see [SECURITY](SECURITY.md) for more information about security.

Credits
-------

[](#credits)

- [Fady Mondy](mailto:info@3x1.io)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

793d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/2147eb2fca7ab5f0124d0fafd88ba2d2a5dfa3a0036fb8872d1084b7cba29366?d=identicon)[fadymondy](/maintainers/fadymondy)

---

Top Contributors

[![fadymondy](https://avatars.githubusercontent.com/u/11937812?v=4)](https://github.com/fadymondy "fadymondy (9 commits)")

---

Tags

phpapilaravelhelpersquerycontrollerstablerequests

### Embed Badge

![Health badge](/badges/tomatophp-laravel-tomato/health.svg)

```
[![Health](https://phpackages.com/badges/tomatophp-laravel-tomato/health.svg)](https://phpackages.com/packages/tomatophp-laravel-tomato)
```

###  Alternatives

[joisarjignesh/bigbluebutton

BigBlueButton Server API Library for Laravel

162145.5k1](/packages/joisarjignesh-bigbluebutton)[jeroen-g/flickr

Modern PHP package to make Flickr API calls. Ships with Laravel implementation.

2559.9k2](/packages/jeroen-g-flickr)[exlo89/laravel-sevdesk-api

A helpful Sevdesk API client for Laravel.

1116.5k](/packages/exlo89-laravel-sevdesk-api)[dystcz/lunar-api

Dystore API layer for Lunar e-commerce package

411.1k3](/packages/dystcz-lunar-api)[yxx/laravel-quick

agile development

145.3k](/packages/yxx-laravel-quick)[gufy/whmcs

WHMCS API for Laravel 5

201.7k](/packages/gufy-whmcs)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
