Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F117886616
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 all {$this->objectName} objects"
;
$this
->
signature
=
$this
->
commandPrefix
?
$this
->
commandPrefix
.
":"
:
""
;
if
(!
empty
(
$this
->
objectNamePlural
))
{
$this
->
signature
.=
"{$this->objectNamePlural}"
;
}
else
{
$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
Mon, Apr 6, 2:37 AM (2 w, 3 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
22/96/c1f524c668f40b032e4a563178d4
Default Alt Text
ObjectListCommand.php (1 KB)
Attached To
Mode
rK kolab
Attached
Detach File
Event Timeline