Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F120823900
ObjectListCommand.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
ObjectListCommand.php
View Options
<?php
namespace
App\Console
;
use
Illuminate\Database\Eloquent\SoftDeletes
;
/**
* This abstract class provides a means to treat objects in our model using CRUD, with the exception that
* this particular abstract class lists objects.
*/
abstract
class
ObjectListCommand
extends
ObjectCommand
{
public
function
__construct
()
{
$this
->
description
=
"List {$this->objectName}s"
;
$this
->
signature
=
$this
->
commandPrefix
?
$this
->
commandPrefix
.
":"
:
""
;
$this
->
signature
.=
"{$this->objectName}s"
;
$classes
=
class_uses_recursive
(
$this
->
objectClass
);
if
(
in_array
(
SoftDeletes
::
class
,
$classes
))
{
$this
->
signature
.=
" {--with-deleted : Include deleted {$this->objectName}s}"
;
}
$this
->
signature
.=
" {--attr=* : Attributes other than the primary unique key to include}"
;
parent
::
__construct
();
}
/**
* Execute the console command.
*
* @return mixed
*/
public
function
handle
()
{
$classes
=
class_uses_recursive
(
$this
->
objectClass
);
if
(
in_array
(
SoftDeletes
::
class
,
$classes
)
&&
$this
->
option
(
'with-deleted'
))
{
$objects
=
$this
->
objectClass
::
withTrashed
();
}
else
{
$objects
=
new
$this
->
objectClass
();
}
$objects
->
each
(
function
(
$object
)
{
if
(
$object
->
deleted_at
)
{
$this
->
info
(
"{$this->toString($object)} (deleted at {$object->deleted_at}"
);
}
else
{
$this
->
info
(
"{$this->toString($object)}"
);
}
}
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Fri, Apr 24, 10:13 AM (2 d, 4 h ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
d5/e7/2c6835e82ecb8201d419d656419e
Default Alt Text
ObjectListCommand.php (1 KB)
Attached To
Mode
rK kolab
Attached
Detach File
Event Timeline