Skip to content

Instantly share code, notes, and snippets.

@crynobone
Last active December 14, 2015 17:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save crynobone/5122585 to your computer and use it in GitHub Desktop.
Save crynobone/5122585 to your computer and use it in GitHub Desktop.
Creating custom installation schema during Installation for Orchestra Platform
php artisan orchestra::toolkit installer
<?php
Event::listen('orchestra.install.schema', function ()
{
/*
| Create a custom schema installation during Orchestra Installation. This
| schema will be available straight away even without activation of any
| extensions.
|
| Schema::create('foo', function ($table)
| {
| $table->increments('id');
| $table->string('name')->default('foobar');
| });
|
*/
Schema::create('posts', function ($table)
{
$table->increments('id');
$table->string('title');
$table->text('content');
$table->integer('user_id')->unsigned();
$table->timestamps();
$table->index('user_id');
});
});
Event::listen('orchestra.install.schema: users', function ($table)
{
/*
| Add custom fields on `users` table, for example you might want to add
| phone number, address or other useful information without the need to
| have additional migrations for `users` table.
|
| $table->string('phone', 20);
|
*/
$table->string('username');
});
Event::listen('orchestra.install: user', function ($user, $input)
{
/*
| For each custom fields implemented in `orchestra.install.schema: users`,
| you might want to add default values for the administrator account.
|
| $user->phone = '0123456789';
|
*/
// set default administrator username as admin
$user->username = 'admin';
});
Event::listen('orchestra.install: acl', function ($acl)
{
/*
| Other than adding custom fields to user, you can also create additional
| roles and create custom acl for it.
|
| Orchestra\Model\Role::create(array('name' => 'Developer'));
| $acl->add_role('Developer');
| $acl->add_action('manage website');
| $acl->allow('Developer', 'manager website');
|
*/
$roles = array('Editor', 'Moderator');
foreach ($roles as $role)
{
Orchestra\Model\Role::create(array('name' => $role));
$acl->add_role($role);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment