Page MenuHomeDevCentral

No OneTemporary

diff --git a/app/Console/Commands/AccountDump.php b/app/Console/Commands/AccountDump.php
new file mode 100644
index 0000000..17c12a8
--- /dev/null
+++ b/app/Console/Commands/AccountDump.php
@@ -0,0 +1,50 @@
+<?php
+
+namespace AuthGrove\Console\Commands;
+
+use Illuminate\Console\Command;
+use AuthGrove\User as User;
+
+class AccountDump extends Command
+{
+ /**
+ * The name and signature of the console command.
+ *
+ * @var string
+ */
+ protected $signature = 'account:dump';
+
+ /**
+ * The console command description.
+ *
+ * @var string
+ */
+ protected $description = 'Dumps the accounts list.';
+
+ /**
+ * Create a new command instance.
+ *
+ * @return void
+ */
+ public function __construct()
+ {
+ parent::__construct();
+ }
+
+ /**
+ * Execute the console command.
+ *
+ * @return mixed
+ */
+ public function handle()
+ {
+ $attributes = User::getDefaultAttributes();
+ $headers = array_map('\AuthGrove\User::localizeAttribute', $attributes);
+
+ $users = User::all($attributes)->toArray();
+
+ $this->table($headers, $users);
+
+ return;
+ }
+}
diff --git a/app/Console/Commands/AccountInfo.php b/app/Console/Commands/AccountInfo.php
index 4f0a401..d4dfbaf 100644
--- a/app/Console/Commands/AccountInfo.php
+++ b/app/Console/Commands/AccountInfo.php
@@ -1,61 +1,61 @@
<?php
namespace AuthGrove\Console\Commands;
use Illuminate\Console\Command;
use AuthGrove\User;
use AuthGrove\Console\Services\AccountHelpers as AccountHelpers;
class AccountInfo extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'account:info {user}';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Get information about an account.';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
protected function printInformationAttribute ($attribute, $value) {
$line = \Keruald\mb_str_pad(
AccountHelpers::localizeUserAttribute($attribute),
21
);
$line .= $value;
- $this->comment($line);
+ $this->info($line);
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$user = AccountHelpers::findUser($this->argument('user'));
if ($user === null) {
- $this->comment("User not found.");
+ $this->error("User not found.");
return;
}
foreach ($user->getInformation() as $attribute => $value) {
$this->printInformationAttribute($attribute, $value);
}
}
}
diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php
index f9bf9f9..e235c6d 100644
--- a/app/Console/Kernel.php
+++ b/app/Console/Kernel.php
@@ -1,30 +1,31 @@
<?php namespace AuthGrove\Console;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
class Kernel extends ConsoleKernel {
/**
* The Artisan commands provided by your application.
*
* @var array
*/
protected $commands = [
'AuthGrove\Console\Commands\AccountInfo',
+ 'AuthGrove\Console\Commands\AccountDump',
'AuthGrove\Console\Commands\Inspire',
];
/**
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/
protected function schedule(Schedule $schedule)
{
$schedule->command('inspire')
->hourly();
}
}
diff --git a/app/User.php b/app/User.php
index 6105036..972758e 100644
--- a/app/User.php
+++ b/app/User.php
@@ -1,71 +1,91 @@
<?php namespace AuthGrove;
use Illuminate\Auth\Authenticatable;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Auth\Passwords\CanResetPassword;
use AuthGrove\Services\FindableByAttribute;
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract;
class User extends Model implements AuthenticatableContract, CanResetPasswordContract {
use Authenticatable, CanResetPassword, FindableByAttribute;
/**
* The database table used by the model.
*
* @var string
*/
protected $table = 'users';
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = ['username', 'fullname', 'email', 'password'];
/**
* The attributes excluded from the model's JSON form.
*
* @var array
*/
protected $hidden = ['password', 'remember_token'];
/**
* Gets fillable but not hidden attributes, plus create/update time
*
* @return Array
*/
public function getAttributes () {
$attributes = array_diff($this->fillable , $this->hidden);
$attributes[] = 'created_at';
$attributes[] = 'updated_at';
array_unshift($attributes, 'id');
return $attributes;
}
+ /**
+ * Localizes attribute
+ *
+ * @param string $attribute The attribute to localize
+ * @return string The localized name of the attribute
+ */
+ public static function localizeAttribute ($attribute) {
+ return trans("panel.user-attributes.$attribute");
+ }
+
+ /**
+ * Gets default attributes
+ *
+ * @return Array an array of string, each a default attribute of the model
+ */
+ public static function getDefaultAttributes () {
+ $user = new self();
+ return $user->getAttributes();
+ }
+
/**
* Gets non sensible properties
*
* @return Array
*/
public function getInformation () {
$info = [];
$attributes = $this->getAttributes();
foreach ($attributes as $attribute) {
$info[$attribute] = $this->attributes[$attribute];
}
return $info;
}
/**
* Gets the full name of an user, or if not defined, the username.
*/
public function getName () {
if ($this->attributes['fullname'] !== "") {
return $this->attributes['fullname'];
}
return $this->attributes['username'];
}
}

File Metadata

Mime Type
text/x-diff
Expires
Sun, May 3, 04:29 (1 d, 6 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3677612
Default Alt Text
(6 KB)

Event Timeline