Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Lara Pro Cms Laravel Package

appdezign/lara-pro-cms

Lara Pro CMS 10 is a flexible content management system built on Laravel by Firmaq Media. Designed for building and managing websites with a developer-friendly approach. Full developer guide and documentation available at docs.laracms.nl.

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Setup

  1. Installation:

    composer require appdezign/lara-pro-cms
    

    Run the publisher to configure the package:

    php artisan vendor:publish --provider="Appdezign\LaraProCms\LaraProCmsServiceProvider" --tag="config"
    php artisan vendor:publish --provider="Appdezign\LaraProCms\LaraProCmsServiceProvider" --tag="migrations"
    

    Run migrations:

    php artisan migrate
    
  2. First Use Case: Create a basic content type (e.g., Article) via the Filament admin panel (accessible at /admin).

    • Navigate to Lara CMS → Content Types and click "Create Content Type".
    • Define fields (e.g., title, body, published_at) and save.
    • Create a content item by navigating to Lara CMS → Content and selecting your new type.
  3. Display Content in Blade: Fetch and render content in a Blade template:

    @php
    $article = \Appdezign\LaraProCms\Models\Content::where('type', 'article')->first();
    @endphp
    
    <h1>{{ $article->title }}</h1>
    <div>{!! $article->body !!}</div>
    
  4. Key Documentation:

    • Official Docs (focus on Content Types, Fields, and Routing sections).
    • Run php artisan lara-pro-cms:docs for local documentation (if available).

Implementation Patterns

Core Workflows

1. Content Type Management

  • Dynamic Fields: Define reusable fields (e.g., RichText, Media, Relationship) for content types.
    // Example: Extend a content type via a service provider
    public function boot()
    {
        \Appdezign\LaraProCms\Facades\LaraProCms::extendContentType('article', function ($builder) {
            $builder->addField(\Appdezign\LaraProCms\Fields\Field::make('author')
                ->type('relationship')
                ->relatedTo(\App\Models\User::class));
        });
    }
    
  • Field Validation: Use Laravel validation rules directly in field definitions:
    Field::make('title')
        ->rules('required|max:255')
        ->label('Article Title');
    

2. Routing and Frontend Integration

  • Route Content Types:
    Route::get('/articles/{slug}', [ArticleController::class, 'show'])
        ->name('articles.show');
    
  • Fetch Content in Controllers:
    public function show($slug)
    {
        $article = \Appdezign\LaraProCms\Facades\LaraProCms::content()
            ->where('type', 'article')
            ->where('slug', $slug)
            ->firstOrFail();
        return view('articles.show', compact('article'));
    }
    
  • Dynamic Routes: Use the lara-pro-cms:routes command to generate routes for all content types:
    php artisan lara-pro-cms:routes
    

3. Media Handling

  • Upload and manage media via the Media Library (Filament-based).
  • Embed media in content:
    Field::make('featured_image')
        ->type('media')
        ->collection('images');
    

4. Localization

  • Support multiple languages via the locale field:
    Field::make('title')
        ->translatable()
        ->label('Title');
    
  • Fetch localized content:
    $article = \Appdezign\LaraProCms\Facades\LaraProCms::content()
        ->where('type', 'article')
        ->locale('nl')
        ->first();
    

5. Extending the Admin Panel

  • Custom Filament Resources: Extend or replace default Filament resources:
    // config/lara-pro-cms.php
    'filament' => [
        'resources' => [
            \Appdezign\LaraProCms\Filament\Resources\ContentTypeResource::class,
            // Override with your custom resource
            \App\Filament\Resources\CustomContentTypeResource::class,
        ],
    ];
    
  • Widgets: Add Filament widgets to the dashboard:
    public function registerWidgets()
    {
        return [
            new \Appdezign\LaraProCms\Filament\Widgets\ContentOverviewWidget(),
            new \App\Filament\Widgets\CustomWidget(),
        ];
    }
    

6. API Integration

  • Expose content via Laravel Sanctum/Passport:
    Route::get('/api/articles', function () {
        return \Appdezign\LaraProCms\Facades\LaraProCms::content()
            ->where('type', 'article')
            ->get();
    });
    
  • Use the api facade for structured responses:
    return \Appdezign\LaraProCms\Facades\LaraProCms::api()->content($article);
    

Integration Tips

  1. Leverage Events: Subscribe to content events (e.g., ContentCreated, ContentUpdated) in EventServiceProvider:

    protected $listen = [
        \Appdezign\LaraProCms\Events\ContentCreated::class => [
            \App\Listeners\SendContentNotification::class,
        ],
    ];
    
  2. Custom Field Types: Create reusable field types by extending \Appdezign\LaraProCms\Fields\Field:

    namespace App\Fields;
    
    use Appdezign\LaraProCms\Fields\Field;
    
    class CustomField extends Field
    {
        public static function make($name)
        {
            return parent::make($name)->type('custom');
        }
    
        public function getView()
        {
            return 'lara-pro-cms::fields.custom';
        }
    }
    
  3. Seeding Content: Use the ContentSeeder to populate initial data:

    php artisan db:seed --class=LaraProCmsSeeder
    

    Or create a custom seeder:

    use Appdezign\LaraProCms\Models\Content;
    
    public function run()
    {
        Content::create([
            'type' => 'article',
            'title' => 'Hello World',
            'slug' => 'hello-world',
            'data' => json_encode(['body' => '<p>Test content</p>']),
        ]);
    }
    
  4. Caching: Cache content queries for performance:

    $article = \Appdezign\LaraProCms\Facades\LaraProCms::content()
        ->where('type', 'article')
        ->remember(60) // Cache for 60 minutes
        ->first();
    

Gotchas and Tips

Pitfalls

  1. Field Data Serialization:

    • Fields are stored as JSON in the data column. Ensure complex data is serializable:
      // Avoid storing unsupported types (e.g., Closures, Resources)
      $field->setData(json_encode($value));
      
  2. Slug Conflicts:

    • Slugs are auto-generated but may conflict. Override the generateSlug method in your content type:
      \Appdezign\LaraProCms\Facades\LaraProCms::extendContentType('article', function ($builder) {
          $builder->setSlugGenerator(function ($title) {
              return Str::slug($title . '-' . uniqid());
          });
      });
      
  3. Filament Permissions:

    • Ensure users have access to the Filament admin panel (/admin). Configure roles in config/filament.php:
      'pages' => [
          'dashboard' => \App\Filament\Pages\Dashboard::class,
          'admin' => \Appdezign\LaraProCms\Filament\Pages\AdminPage::class,
      ],
      
  4. Livewire Conflicts:

    • If using Livewire 4, ensure compatibility by checking the package’s composer.json for constraints. Update Livewire via:
      composer require livewire/livewire:^4.0
      
  5. Media Storage:

    • Verify config/filesystems.php points to the correct disk for media uploads. Defaults to public:
      'disks' => [
          'public' => [
              'driver' => 'local',
              'root' => storage_path('app/public'),
          ],
      ],
      
  6. Tailwind CSS:

    • The package uses Tailwind. Ensure your resources/css/app.css includes Tailwind directives:
      @tailwind base;
      @tailwind components;
      @tailwind
      
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
emuniq/filament-browser-notifications
syriable/filament-translator
hungnm28/livewire-form
wenprise/eloquent
crudly/encrypted
fadion/bouncy
cuci/prototurk-sdk
gos/pubsub-router-bundle
cuci/prototurk-sdk-symfony
clementtalleu/easyadmin-markdown-bundle
codeflextech/permission-manager
karnoweb/livewire-datepicker
sayedenam/sayed-dashboard
milito/query-filter
apiboxsym/user-bundle
apiboxsym/health-check-bundle
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui