Changeset View
Changeset View
Standalone View
Standalone View
src/app/Console/Command.php
- This file was added.
<?php | |||||
namespace App\Console; | |||||
class Command extends \Illuminate\Console\Command | |||||
{ | |||||
/** | |||||
* Find the domain. | |||||
* | |||||
* @param string $domain Domain ID or namespace | |||||
* | |||||
* @return \App\Domain|null | |||||
*/ | |||||
public function getDomain($domain) | |||||
{ | |||||
return $this->getObject(\App\Domain::class, $domain, 'namespace'); | |||||
} | |||||
/** | |||||
* Find an object. | |||||
* | |||||
* @param string $objectClass The name of the class | |||||
* @param string $objectTitle The name of a database field to match. | |||||
* | |||||
* @return mixed | |||||
*/ | |||||
public function getObject($objectClass, $objectIdOrTitle, $objectTitle) | |||||
{ | |||||
$object = $objectClass::find($objectIdOrTitle); | |||||
if (!$object && !empty($objectTitle)) { | |||||
$object = $objectClass::where($objectTitle, $objectIdOrTitle)->first(); | |||||
} | |||||
return $object; | |||||
} | |||||
/** | |||||
* Find the user. | |||||
* | |||||
* @param string $user User ID or email | |||||
* | |||||
* @return \App\User|null | |||||
*/ | |||||
public function getUser($user) | |||||
{ | |||||
return $this->getObject(\App\User::class, $user, 'email'); | |||||
} | |||||
/** | |||||
* Find the wallet. | |||||
* | |||||
* @param string $wallet Wallet ID | |||||
* | |||||
* @return \App\Wallet|null | |||||
*/ | |||||
public function getWallet($wallet) | |||||
{ | |||||
return $this->getObject(\App\Wallet::class, $wallet, null); | |||||
} | |||||
} |