Changeset View
Changeset View
Standalone View
Standalone View
src/app/Console/Command.php
Show All 21 Lines | class Command extends \Illuminate\Console\Command | ||||
* @param string $objectClass The name of the class | * @param string $objectClass The name of the class | ||||
* @param string $objectIdOrTitle The name of a database field to match. | * @param string $objectIdOrTitle The name of a database field to match. | ||||
* @param string|null $objectTitle An additional database field to match. | * @param string|null $objectTitle An additional database field to match. | ||||
* | * | ||||
* @return mixed | * @return mixed | ||||
*/ | */ | ||||
public function getObject($objectClass, $objectIdOrTitle, $objectTitle) | public function getObject($objectClass, $objectIdOrTitle, $objectTitle) | ||||
{ | { | ||||
if ($this->hasOption('with-deleted') && $this->option('with-deleted')) { | |||||
$object = $objectClass::withTrashed()->find($objectIdOrTitle); | |||||
} else { | |||||
$object = $objectClass::find($objectIdOrTitle); | $object = $objectClass::find($objectIdOrTitle); | ||||
} | |||||
if (!$object && !empty($objectTitle)) { | if (!$object && !empty($objectTitle)) { | ||||
if ($this->hasOption('with-deleted') && $this->option('with-deleted')) { | |||||
$object = $objectClass::withTrashed()->where($objectTitle, $objectIdOrTitle)->first(); | |||||
} else { | |||||
$object = $objectClass::where($objectTitle, $objectIdOrTitle)->first(); | $object = $objectClass::where($objectTitle, $objectIdOrTitle)->first(); | ||||
} | } | ||||
} | |||||
return $object; | return $object; | ||||
} | } | ||||
/** | /** | ||||
* Find the user. | * Find the user. | ||||
* | * | ||||
* @param string $user User ID or email | * @param string $user User ID or email | ||||
▲ Show 20 Lines • Show All 62 Lines • Show Last 20 Lines |