Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F120837872
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"
;
$classes
=
class_uses_recursive
(
$this
->
objectClass
);
$this
->
signature
=
$this
->
commandPrefix
?
$this
->
commandPrefix
.
":"
:
""
;
$this
->
signature
.=
"{$this->objectName}s"
;
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, 1:51 PM (3 d, 23 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
18722484
Default Alt Text
ObjectListCommand.php (1 KB)
Attached To
Mode
rK kolab
Attached
Detach File
Event Timeline