1. Go to this page and download the library: Download weble/laravel-playbooks library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
weble / laravel-playbooks example snippets
return [
/*
|--------------------------------------------------------------------------
| Run only in these environments
|--------------------------------------------------------------------------
|
| Do not allow Playbooks to be run in any environment outside of the ones specified here
|
| default: ['local']
*/
'envs' => [
'local'
],
/*
|--------------------------------------------------------------------------
| Raise PHP memory limit
|--------------------------------------------------------------------------
|
| Raise the default memory limit to avoid issues when running large playbooks.
| Set to null to disable this feature.
|
| default: '20148M'
*/
'raise_memory_limit' => '2048M',
/*
|--------------------------------------------------------------------------
| Fresh Migration
|--------------------------------------------------------------------------
|
| Run a migrate:refresh command before every playbook run by default.
| This can be disabled or enabled manually through the
| --no-migration or --migration options
|
| default: true
*/
'migrate_by_default' => true,
/*
|--------------------------------------------------------------------------
| Playbook path
|--------------------------------------------------------------------------
|
| Choose the root directory where new Playbooks should be created and where
| the `php artisan playbook:run` command should scan for available playbooks
| example: 'Console/Playbooks'
|
| default: 'Playbooks'
*/
'path' => 'Playbooks',
];
namespace App\Playbooks;
use App\CarType;
use Weble\LaravelPlaybooks\Playbook;
final class CarTypesPlaybook extends Playbook
{
public function before(): array
{
return [
// List of other playbooks to run before this one
// ie: BasePlaybook::once()
// ie: BasePlaybook::times(3) to run it 3 times
];
}
public function run(): void
{
$this->createCarTypes();
}
private function createCarTypes(): void
{
$types = [
'Economy' => 3,
'Business' => 4,
'Family' => 4,
'Sport' => 2,
'Luxury' => 3,
'Van' => 8,
'Luxury Van' => 6,
];
foreach ($types as $type => $passengers) {
factory(CarType::class)->create([
'title' => [
'it' => $type,
'en' => $type,
],
'subtitle' => [
'it' => 'Adipiscing elit. aute irure dolor',
'en' => 'Adipiscing elit. aute irure dolor',
],
'description' => [
'it' => 'Lorem ipsum dolor sit amet consecte tur adipiscing elit. aute irure dolor in reprehende.',
'en' => 'Lorem ipsum dolor sit amet consecte tur adipiscing elit. aute irure dolor in reprehende.',
],
'max_passengers' => $passengers,
'max_luggage' => $passengers - 1,
]);
}
}
public function after(): array
{
return [
// List of other playbooks to run before this one
// ie: BasePlaybook::once()
// ie: BasePlaybook::times(3) to run it 3 times
];
}
}