mirror of
https://github.com/ZorgCC/lumen-generators.git
synced 2024-12-27 06:25:28 +03:00
fixed the duplicate column for the foriegn key bug
This commit is contained in:
parent
27dc508bca
commit
057199cb8b
@ -8,3 +8,4 @@ class Controller extends BaseController
|
|||||||
{
|
{
|
||||||
//
|
//
|
||||||
}
|
}
|
||||||
|
|
||||||
|
43
lumen-test/clean.sh
Executable file
43
lumen-test/clean.sh
Executable file
@ -0,0 +1,43 @@
|
|||||||
|
# models
|
||||||
|
rm app/*.php 2> /dev/null
|
||||||
|
|
||||||
|
# migrations
|
||||||
|
rm database/migrations/*.php 2> /dev/null
|
||||||
|
|
||||||
|
# routes
|
||||||
|
echo "<?php
|
||||||
|
|
||||||
|
\$app->get(\"/\", function () use (\$app) {
|
||||||
|
return \$app->welcome();
|
||||||
|
});" > app/Http/routes.php
|
||||||
|
|
||||||
|
# Controllers
|
||||||
|
rm app/Http/Controllers/*.php 2> /dev/null
|
||||||
|
echo "<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Laravel\Lumen\Routing\Controller as BaseController;
|
||||||
|
|
||||||
|
class Controller extends BaseController
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
" > app/Http/Controllers/Controller.php
|
||||||
|
|
||||||
|
# factories
|
||||||
|
echo "<?php
|
||||||
|
|
||||||
|
\$factory->define(App\User::class, function (\$faker) {
|
||||||
|
return [
|
||||||
|
'name' => \$faker->name,
|
||||||
|
'email' => \$faker->email,
|
||||||
|
'password' => str_random(10),
|
||||||
|
'remember_token' => str_random(10),
|
||||||
|
];
|
||||||
|
});
|
||||||
|
" > database/factories/ModelFactory.php
|
||||||
|
|
||||||
|
# database
|
||||||
|
rm database/database.sqlite 2> /dev/null
|
||||||
|
touch database/database.sqlite
|
@ -1,23 +0,0 @@
|
|||||||
---
|
|
||||||
Post:
|
|
||||||
belongsToMany: tags
|
|
||||||
add: timestamps softDeletes
|
|
||||||
fields:
|
|
||||||
title:
|
|
||||||
schema: string
|
|
||||||
rules: required
|
|
||||||
tags: fillable
|
|
||||||
content:
|
|
||||||
schema: text nullable
|
|
||||||
tags: fillable
|
|
||||||
published_at:
|
|
||||||
schema: date
|
|
||||||
rules: date
|
|
||||||
tags: date fillable
|
|
||||||
Tag:
|
|
||||||
belongsToMany: posts
|
|
||||||
fields:
|
|
||||||
name:
|
|
||||||
schema: string unique
|
|
||||||
rules: required
|
|
||||||
tags: fillable
|
|
@ -36,7 +36,7 @@ class ResourcesCommand extends BaseCommand {
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->call('migrate');
|
// $this->call('migrate'); // actually needed for pivot seeders !
|
||||||
|
|
||||||
$this->pivotTables = array_map(
|
$this->pivotTables = array_map(
|
||||||
'unserialize',
|
'unserialize',
|
||||||
@ -72,25 +72,6 @@ class ResourcesCommand extends BaseCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($i['belongsTo']){
|
|
||||||
$relations = $this->getArgumentParser('relations')->parse($i['belongsTo']);
|
|
||||||
foreach ($relations as $relation){
|
|
||||||
$foreignName = '';
|
|
||||||
|
|
||||||
if(! $relation['model']){
|
|
||||||
$foreignName = snake_case($relation['name']) . '_id';
|
|
||||||
} else {
|
|
||||||
$names = array_reverse(explode("\\", $relation['model']));
|
|
||||||
$foreignName = snake_case($names[0]) . '_id';
|
|
||||||
}
|
|
||||||
|
|
||||||
$i['fields'][$foreignName] = [
|
|
||||||
'schema' => 'integer',
|
|
||||||
'tags' => 'key'
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if($i['belongsToMany']){
|
if($i['belongsToMany']){
|
||||||
$relations = $this->getArgumentParser('relations')->parse($i['belongsToMany']);
|
$relations = $this->getArgumentParser('relations')->parse($i['belongsToMany']);
|
||||||
foreach ($relations as $relation){
|
foreach ($relations as $relation){
|
||||||
|
Loading…
Reference in New Issue
Block a user