Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Platform
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Platform
Commits
2d59e539
Unverified
Commit
2d59e539
authored
Sep 15, 2017
by
Nicolas Widart
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Create and register a test pages seeding command
parent
484015d1
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
93 additions
and
0 deletions
+93
-0
CreatePagesCommand.php
Modules/Page/Console/CreatePagesCommand.php
+90
-0
PageServiceProvider.php
Modules/Page/Providers/PageServiceProvider.php
+3
-0
No files found.
Modules/Page/Console/CreatePagesCommand.php
0 → 100644
View file @
2d59e539
<?php
namespace
Modules\Page\Console
;
use
Illuminate\Console\Command
;
use
Modules\Page\Repositories\PageRepository
;
use
Symfony\Component\Console\Input\InputOption
;
use
Symfony\Component\Console\Input\InputArgument
;
class
CreatePagesCommand
extends
Command
{
protected
$name
=
'asgard:create:test-pages'
;
protected
$description
=
'Command description.'
;
/**
* @var PageRepository
*/
private
$page
;
public
function
__construct
(
PageRepository
$page
)
{
parent
::
__construct
();
$this
->
page
=
$page
;
}
/**
* Execute the console command.
*
* @return mixed
*/
public
function
handle
()
{
$total
=
10000
;
$bar
=
$this
->
output
->
createProgressBar
(
$total
);
for
(
$i
=
0
;
$i
<
$total
;
$i
++
)
{
$this
->
createPage
();
$bar
->
advance
();
}
$bar
->
finish
();
}
private
function
createPage
()
{
$faker
=
\Faker\Factory
::
create
();
$this
->
page
->
create
([
'is_home'
=>
0
,
'template'
=>
'default'
,
'en'
=>
[
'title'
=>
$faker
->
name
,
'slug'
=>
$faker
->
slug
,
'body'
=>
$faker
->
paragraph
(),
],
'fr'
=>
[
'title'
=>
$faker
->
name
,
'slug'
=>
$faker
->
slug
,
'body'
=>
$faker
->
paragraph
(),
],
'nl'
=>
[
'title'
=>
$faker
->
name
,
'slug'
=>
$faker
->
slug
,
'body'
=>
$faker
->
paragraph
(),
],
]);
}
/**
* Get the console command arguments.
*
* @return array
*/
protected
function
getArguments
()
{
return
[
//['example', InputArgument::REQUIRED, 'An example argument.'],
];
}
/**
* Get the console command options.
*
* @return array
*/
protected
function
getOptions
()
{
return
[
//['example', null, InputOption::VALUE_OPTIONAL, 'An example option.', null],
];
}
}
Modules/Page/Providers/PageServiceProvider.php
View file @
2d59e539
...
...
@@ -8,6 +8,7 @@ use Modules\Core\Events\BuildingSidebar;
use
Modules\Core\Events\CollectingAssets
;
use
Modules\Core\Traits\CanGetSidebarClassForModule
;
use
Modules\Core\Traits\CanPublishConfiguration
;
use
Modules\Page\Console\CreatePagesCommand
;
use
Modules\Page\Entities\Page
;
use
Modules\Page\Events\Handlers\RegisterPageSidebar
;
use
Modules\Page\Repositories\Cache\CachePageDecorator
;
...
...
@@ -50,6 +51,8 @@ class PageServiceProvider extends ServiceProvider
$this
->
loadMigrationsFrom
(
__DIR__
.
'/../Database/Migrations'
);
$this
->
handleAssets
();
$this
->
commands
(
CreatePagesCommand
::
class
);
}
/**
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment