This forum has moved to a new location and is in read-only mode. Please visit to access the new location.


Oh man, this is gonna come across as a rant.

  1. Building Plugins - can we have a more thorough example, from start to finish, no skipping steps, no linking all over the place that shows a complete example of building a plugin with a simple database? Yes, builder plugin is good to get you started, but even there, the docs are barely enough to cover everything that's happening. I made numerous wrong turns following the docs with builder. More thorough example needed - with database.

  2. Connect my component to a database. I want to connect to my custom table to return records. Can't find a single line of code anywhere that shows how to include the database in my component. I get an exception: "Class 'lkflabs\Calendar\Components\Db' not found". ok, so i have to include a database library. In the documentation about October and database, all sorts of info on database functions available, but nothing on how to actually include a library if you need to.

The command I want to execute looks like: $events_arr = Db::table('lkflabs_calendar_events')->get();

But maybe there's a way to get data from my custom table already, can't find that information though.

thanks for any help.


I'll start with 2.

use Db;

public function getEvents()
    return $events_arr = Db::table('lkflabs_calendar_events')->get();

Note that if you created a model, you can use the Eloquent model to make your queries:


Last updated


For 1. I don't really have time to write an in depth tutorial, but there are so many plugins out there that do this... just look at the RainLab plugins and you should have a good start.

One thing that helps is to use php artisan console commands to do the bulk of the work, and then you complete the rest manually.

start by creating plugin scaffolding:

php artisan create:plugin author.plugin

Then create a model:

php artisan create:model author.plugin myModel

Then create a controller:

php artisan create:controller author.plugin myController

And a component:

php artisan create:component author.plugin myComponent

Once you know all the db fields you'll need for your model, create the migration file in author/plugin/updates/create_tables.php

<?php namespace Author\Plugin\Updates;

use Schema;
use October\Rain\Database\Schema\Blueprint;
use October\Rain\Database\Updates\Migration;

class CreateTables extends Migration
    public function up()
        Schema::create('author_plugin_mymodels', function (Blueprint $table) {
            $table->engine = 'InnoDB';

    public function down()

and add this to your updates/version.yaml file:

    - My Initial Version
    - create_tables.php

Once this is done, use php artisan october:up to run the migration (thus, creating the database table)

If you forget some fields, just update your create_tables.php migration file and run php artisan plugin:refresh (note that this will destroy the table and recreate it from scratch)

1-3 of 3

You cannot edit posts or make replies: the forum has moved to