1. Go to this page and download the library: Download acadea/boilerplate 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/ */
acadea / boilerplate example snippets
return [
];
return [
'post' => [
'title' => [
// any column type supported by eloquent
// https://laravel.com/docs/8.x/migrations#available-column-types
'type' => 'string',
// attributes are column modifier
// https://laravel.com/docs/8.x/migrations#column-modifiers
'attributes' => [
// put a flat string if no argument to pass to the modifier
'nullable',
// if we need to pass arguments to the modifier
// array key is the modifier method, value should be an array of arguments value to pass to the modifier
'default' => ['some post'],
],
],
'body' => [
'type' => 'mediumText',
'attributes' => ['nullable'],
],
'book_author_id' => [
'type' => 'foreignId',
'foreign' => [
'references' => 'id',
'on' => 'book_authors',
],
],
// will add belongsToMany relationship to model
'tags' => [
'type' => 'pivot',
'pivot' => [
'table' => 'post_tag',
'related_key' => 'post_id',
'foreign_key' => 'tag_id',
]
]
],
// PIVOT TABLE
// add 'pivot:' before table name to create pivot migration
'pivot:post_tag' => [
'post_id' => [
// to set this column as primary key in the pivot table
'primary' => true,
'type' => 'foreignId',
'attributes' => [
'index'
],
'foreign' => [
'references' => 'id',
'on' => 'posts',
],
],
'tag_id' => [
'primary' => true,
'type' => 'foreignId',
'attributes' => [
'index'
],
'foreign' => [
'references' => 'id',
'on' => 'tags',
],
],
],
];