Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F120837374
ObjectCreateCommand.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
1 KB
Referenced Files
None
Subscribers
None
ObjectCreateCommand.php
View Options
<?php
namespace
App\Console
;
/**
* This abstract class provides a means to treat objects in our model using CRUD.
*/
abstract
class
ObjectCreateCommand
extends
ObjectCommand
{
public
function
__construct
()
{
$this
->
description
=
"Create a {$this->objectName}"
;
$this
->
signature
=
sprintf
(
"%s%s:create"
,
$this
->
commandPrefix
?
$this
->
commandPrefix
.
":"
:
""
,
$this
->
objectName
);
$class
=
new
$this
->
objectClass
();
foreach
(
$class
->
getFillable
()
as
$fillable
)
{
$this
->
signature
.=
" {--{$fillable}=}"
;
}
parent
::
__construct
();
}
public
function
getProperties
()
{
if
(!
empty
(
$this
->
properties
))
{
return
$this
->
properties
;
}
$class
=
new
$this
->
objectClass
();
$this
->
properties
=
[];
foreach
(
$class
->
getFillable
()
as
$fillable
)
{
$this
->
properties
[
$fillable
]
=
$this
->
option
(
$fillable
);
}
return
$this
->
properties
;
}
/**
* Execute the console command.
*
* @return mixed
*/
public
function
handle
()
{
$this
->
getProperties
();
$class
=
new
$this
->
objectClass
();
$object
=
$this
->
objectClass
::
create
(
$this
->
properties
);
if
(
$object
)
{
$this
->
cacheRefresh
(
$object
);
$this
->
info
(
$object
->{
$class
->
getKeyName
()});
}
else
{
$this
->
error
(
"Object could not be created."
);
}
return
$object
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Fri, Apr 24, 1:44 PM (1 d, 14 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
18793491
Default Alt Text
ObjectCreateCommand.php (1 KB)
Attached To
Mode
rK kolab
Attached
Detach File
Event Timeline