Litstack Documentation

website·Indexed 32 days ago

https://litstack.io/docs/master/

Documentation for Litstack 3.x, a Laravel-based admin panel and CMS. Includes guides on CRUD configuration, form fields (WYSIWYG, DateTime, Image, etc.), chart generation, localization, and installation.

Tokens
48.6K
Snippets
411
Records
449
Agent score
60%

What's inside Litstack

  1. Overview of Litstack Laravel Admin Panel

    Litstack is an open-source framework designed for the rapid creation of Laravel Admin Panels. It allows developers to extend Laravel models with CRUD functionality and manage content through a highly extensible, configurable interface. It supports headless API-based applications and is compatible with Livewire, Vue, and standard Blade components.
  2. Create a basic Page in LitStack

    Pages are the fundamental building blocks for configuring the admin backend in LitStack. You can create a page by returning an instance of Ignite\Page\Page from a controller. Use the title() method to set the page heading.
    namespace Lit\Controllers;
    
    use Ignite\Page\Page;
    
    class MyPageController
    {
        public function __invoke()
        {
            $page = new Page;
    
            return $page->title('My Page');
        }
    }
  3. Create a basic Page in LitStack

    Pages are the fundamental building blocks for the admin backend in LitStack, allowing you to configure Vue applications via PHP. You can create a page by returning an instance of Ignite\Page\Page from a controller.
    namespace Lit\Controllers;
    
    use Ignite\Page\Page;
    
    class MyPageController
    {
        public function __invoke()
        {
            $page = new Page;
    
            return $page->title('My Page');
        }
    }
  4. Understand the Litstack isolated directory structure

    Litstack creates a ./lit folder within your Laravel application to act as an isolated administration application. This separation ensures that administration logic is decoupled from your core business logic. The ./lit directory mirrors a standard Laravel structure, containing its own ./lit/app folder for PHP classes and ./lit/resources folder for assets and views.
  5. Use Bootstrap Vue for Litstack frontend components

    Litstack utilizes Bootstrap Vue to ensure uniform page design. Developers can use any of the standard Bootstrap Vue components to build application interfaces.
  6. Use Bootstrap Vue for Litstack frontend components

    Litstack uses Bootstrap Vue to ensure uniform page building. Developers can utilize the full suite of Bootstrap Vue components to build the application frontend.
  7. Understand the Litstack isolated directory structure

    Litstack creates a ./lit folder within your Laravel application. This folder acts as an isolated Laravel application specifically for your administration logic, separating it from your main business logic. It includes its own ./lit/resources (assets and views) and ./lit/app (PHP classes) directories.
  8. Configure the CRUD index page

    Each CRUD configuration can have an index page to show an overview of models. This is configured within the index method of the corresponding config class using the Ignite egelen//CrudIndex object. Since CrudIndex extends Ignite egelen//Page, you can also bind Vue components or Blade views to the page.
    use Ignite
    Crud
    CrudIndex;
    
    public function index(CrudIndex $page)
    {
        // Build your index page here.
        $page->component('foo'); // Bind Vue component
        $page->view('foo');      // Bind Blade view
    }
  9. Filter model queries based on user ownership

    To restrict which records a user can see or interact with (e.g., hiding records not created by the current user), override the query method in the CRUD controller to add a where clause to the base query.
    class PostController
    {
        public function query($query)
        {
            $query->where('created_by', lit_user()->id);
        }
    }
  10. Integrate List fields into a CRUD Model

    List fields do not require a dedicated column in the model's database table because they are stored centrally in a database table. To enable a list field in a model, use the listItems() method. Data can then be retrieved as a property of the model instance.
    // In the Model
    public function menue()
    {
        return $this->listItems('menue');
    }
    
    // Retrieving data
    Post::find($id)->menue;
  11. Add routes and groups to a Route collection

    Routes are added to a collection using the route method, which takes a display title, an identifier, and a closure that returns the actual route URL. Routes can also be organized into groups using the group method, which is useful for dynamic lists like model show routes.
    // Adding a single route
    $collection->route('Home', 'home', fn($locale) => route('home'));
    
    // Adding a group of routes (e.g., for Articles)
    $collection->group('Articles', function($group) {
        $articles = Article::all();
        foreach($articles as $article) {
            $group->route($article->title, $article->id, function() use ($article) {
                return route('articles.show', $article->id);
            });
        }
    });
  12. Display fields conditionally based on model values

    Use the when() method on a field to make it visible only when a specific model attribute matches a given value. This allows for dynamic forms where fields appear or disappear based on user selection.
    $form->select('type')
        ->options([
            'news' => 'News',
            'blog' => 'Blog',
        ])
        ->title('Type');
    
    $form->input('news_title')
        ->title('Title')
        ->when('type', 'news');