Routes
You're browsing the documentation for an old version of MoonShine. Consider upgrading your project to MoonShine 2.x.
-
Sections
# Resource routes
In MoonShine, the resource has many routes registered for various actions:
$this->route('index'); // GET|HEAD - list of items$this->route('create'); // GET|HEAD - create a new item$this->route('store'); // POST - save a new item$this->route('edit', $resourceItem); // GET|HEAD - edit an item$this->route('update', $resourceItem); // PUT|PATCH - save an item$this->route('destroy', $resourceItem); // DELETE - delete an item$this->route('show', $resourceItem); // GET|HEAD - view an item$this->route('query-tag', $queryTag); // GET|HEAD - filtered list of items by query filter / tag$this->route('update-column', $resourceItem); // PUT - save an item`s field
# Custom routes
Through the resolveRoutes()
method, you can add or override default routes.
namespace App\MoonShine\Resources; use App\Models\Post;use MoonShine\Resources\Resource; class PostResource extends Resource{ public static string $model = Post::class; // ... public function resolveRoutes(): void { parent::resolveRoutes(); Route::prefix('resource')->group(function (): void { Route::get("{$this->uriKey()}/restore/{resourceItem}", function (Post $item) { $item->restore(); return redirect()->back(); }); }); } // ...}
To access a route outside of a resource, use (new Resource())->route('index')
.