repo stringlengths 7 63 | file_url stringlengths 81 284 | file_path stringlengths 5 200 | content stringlengths 0 32.8k | language stringclasses 1
value | license stringclasses 7
values | commit_sha stringlengths 40 40 | retrieved_at stringdate 2026-01-04 15:02:33 2026-01-05 05:24:06 | truncated bool 2
classes |
|---|---|---|---|---|---|---|---|---|
z-song/laravel-admin | https://github.com/z-song/laravel-admin/blob/67c441eb78ecc5437e59775d89770cd9c2cb1e05/src/Form/Field/CanCascadeFields.php | src/Form/Field/CanCascadeFields.php | <?php
namespace Encore\Admin\Form\Field;
use Encore\Admin\Admin;
use Encore\Admin\Form;
use Illuminate\Support\Arr;
/**
* @property Form $form
*/
trait CanCascadeFields
{
/**
* @var array
*/
protected $conditions = [];
/**
* @param $operator
* @param $value
* @param $closure
*
* @return $this
*/
public function when($operator, $value, $closure = null)
{
if (func_num_args() == 2) {
$closure = $value;
$value = $operator;
$operator = '=';
}
$this->formatValues($operator, $value);
$this->addDependents($operator, $value, $closure);
return $this;
}
/**
* @param string $operator
* @param mixed $value
*/
protected function formatValues(string $operator, &$value)
{
if (in_array($operator, ['in', 'notIn'])) {
$value = Arr::wrap($value);
}
if (is_array($value)) {
$value = array_map('strval', $value);
} else {
$value = strval($value);
}
}
/**
* @param string $operator
* @param mixed $value
* @param \Closure $closure
*/
protected function addDependents(string $operator, $value, \Closure $closure)
{
$this->conditions[] = compact('operator', 'value', 'closure');
$this->form->cascadeGroup($closure, [
'column' => $this->column(),
'index' => count($this->conditions) - 1,
'class' => $this->getCascadeClass($value),
]);
}
/**
* {@inheritdoc}
*/
public function fill($data)
{
parent::fill($data);
$this->applyCascadeConditions();
}
/**
* @param mixed $value
*
* @return string
*/
protected function getCascadeClass($value)
{
if (is_array($value)) {
$value = implode('-', $value);
}
return sprintf('cascade-%s-%s', $this->getElementClassString(), bin2hex($value));
}
/**
* Apply conditions to dependents fields.
*
* @return void
*/
protected function applyCascadeConditions()
{
if ($this->form) {
$this->form->fields()
->filter(function (Form\Field $field) {
return $field instanceof CascadeGroup
&& $field->dependsOn($this)
&& $this->hitsCondition($field);
})->each->visiable();
}
}
/**
* @param CascadeGroup $group
*
* @throws \Exception
*
* @return bool
*/
protected function hitsCondition(CascadeGroup $group)
{
$condition = $this->conditions[$group->index()];
extract($condition);
$old = old($this->column(), $this->value());
switch ($operator) {
case '=':
return $old == $value;
case '>':
return $old > $value;
case '<':
return $old < $value;
case '>=':
return $old >= $value;
case '<=':
return $old <= $value;
case '!=':
return $old != $value;
case 'in':
return in_array($old, $value);
case 'notIn':
return !in_array($old, $value);
case 'has':
return in_array($value, $old);
case 'oneIn':
return count(array_intersect($value, $old)) >= 1;
case 'oneNotIn':
return count(array_intersect($value, $old)) == 0;
default:
throw new \Exception("Operator [$operator] not support.");
}
}
/**
* Js Value.
*/
protected function getValueByJs()
{
return addslashes(old($this->column(), $this->value()));
}
/**
* Add cascade scripts to contents.
*
* @return void
*/
protected function addCascadeScript()
{
if (empty($this->conditions)) {
return;
}
$cascadeGroups = collect($this->conditions)->map(function ($condition) {
return [
'class' => $this->getCascadeClass($condition['value']),
'operator' => $condition['operator'],
'value' => $condition['value'],
];
})->toJson();
$script = <<<SCRIPT
;(function () {
var operator_table = {
'=': function(a, b) {
if ($.isArray(a) && $.isArray(b)) {
return $(a).not(b).length === 0 && $(b).not(a).length === 0;
}
return a == b;
},
'>': function(a, b) { return a > b; },
'<': function(a, b) { return a < b; },
'>=': function(a, b) { return a >= b; },
'<=': function(a, b) { return a <= b; },
'!=': function(a, b) {
if ($.isArray(a) && $.isArray(b)) {
return !($(a).not(b).length === 0 && $(b).not(a).length === 0);
}
return a != b;
},
'in': function(a, b) { return $.inArray(a, b) != -1; },
'notIn': function(a, b) { return $.inArray(a, b) == -1; },
'has': function(a, b) { return $.inArray(b, a) != -1; },
'oneIn': function(a, b) { return a.filter(v => b.includes(v)).length >= 1; },
'oneNotIn': function(a, b) { return a.filter(v => b.includes(v)).length == 0; },
};
var cascade_groups = {$cascadeGroups};
cascade_groups.forEach(function (event) {
var default_value = '{$this->getValueByJs()}' + '';
var class_name = event.class;
if(default_value == event.value) {
$('.'+class_name+'').removeClass('hide');
}
});
$('{$this->getElementClassSelector()}').on('{$this->cascadeEvent}', function (e) {
{$this->getFormFrontValue()}
cascade_groups.forEach(function (event) {
var group = $('div.cascade-group.'+event.class);
if( operator_table[event.operator](checked, event.value) ) {
group.removeClass('hide');
} else {
group.addClass('hide');
}
});
})
})();
SCRIPT;
Admin::script($script);
}
/**
* @return string
*/
protected function getFormFrontValue()
{
switch (get_class($this)) {
case Radio::class:
case RadioButton::class:
case RadioCard::class:
case Select::class:
case BelongsTo::class:
case BelongsToMany::class:
case MultipleSelect::class:
return 'var checked = $(this).val();';
case Checkbox::class:
case CheckboxButton::class:
case CheckboxCard::class:
return <<<SCRIPT
var checked = $('{$this->getElementClassSelector()}:checked').map(function(){
return $(this).val();
}).get();
SCRIPT;
default:
throw new \InvalidArgumentException('Invalid form field type');
}
}
}
| php | MIT | 67c441eb78ecc5437e59775d89770cd9c2cb1e05 | 2026-01-04T15:05:15.717211Z | false |
z-song/laravel-admin | https://github.com/z-song/laravel-admin/blob/67c441eb78ecc5437e59775d89770cd9c2cb1e05/src/Auth/Permission.php | src/Auth/Permission.php | <?php
namespace Encore\Admin\Auth;
use Encore\Admin\Facades\Admin;
use Encore\Admin\Middleware\Pjax;
class Permission
{
/**
* Check permission.
*
* @param $permission
*
* @return true
*/
public static function check($permission)
{
if (static::isAdministrator()) {
return true;
}
if (is_array($permission)) {
collect($permission)->each(function ($permission) {
call_user_func([self::class, 'check'], $permission);
});
return;
}
if (Admin::user()->cannot($permission)) {
static::error();
}
}
/**
* Roles allowed to access.
*
* @param $roles
*
* @return true
*/
public static function allow($roles)
{
if (static::isAdministrator()) {
return true;
}
if (!Admin::user()->inRoles($roles)) {
static::error();
}
}
/**
* Don't check permission.
*
* @return bool
*/
public static function free()
{
return true;
}
/**
* Roles denied to access.
*
* @param $roles
*
* @return true
*/
public static function deny($roles)
{
if (static::isAdministrator()) {
return true;
}
if (Admin::user()->inRoles($roles)) {
static::error();
}
}
/**
* Send error response page.
*/
public static function error()
{
$response = response(Admin::content()->withError(trans('admin.deny')));
if (!request()->pjax() && request()->ajax()) {
abort(403, trans('admin.deny'));
}
Pjax::respond($response);
}
/**
* If current user is administrator.
*
* @return mixed
*/
public static function isAdministrator()
{
return Admin::user()->isRole('administrator');
}
}
| php | MIT | 67c441eb78ecc5437e59775d89770cd9c2cb1e05 | 2026-01-04T15:05:15.717211Z | false |
z-song/laravel-admin | https://github.com/z-song/laravel-admin/blob/67c441eb78ecc5437e59775d89770cd9c2cb1e05/src/Auth/Database/OperationLog.php | src/Auth/Database/OperationLog.php | <?php
namespace Encore\Admin\Auth\Database;
use Encore\Admin\Traits\DefaultDatetimeFormat;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class OperationLog extends Model
{
use DefaultDatetimeFormat;
protected $fillable = ['user_id', 'path', 'method', 'ip', 'input'];
public static $methodColors = [
'GET' => 'green',
'POST' => 'yellow',
'PUT' => 'blue',
'DELETE' => 'red',
];
public static $methods = [
'GET', 'POST', 'PUT', 'DELETE', 'OPTIONS', 'PATCH',
'LINK', 'UNLINK', 'COPY', 'HEAD', 'PURGE',
];
/**
* Create a new Eloquent model instance.
*
* @param array $attributes
*/
public function __construct(array $attributes = [])
{
$connection = config('admin.database.connection') ?: config('database.default');
$this->setConnection($connection);
$this->setTable(config('admin.database.operation_log_table'));
parent::__construct($attributes);
}
/**
* Log belongs to users.
*
* @return BelongsTo
*/
public function user(): BelongsTo
{
return $this->belongsTo(config('admin.database.users_model'));
}
}
| php | MIT | 67c441eb78ecc5437e59775d89770cd9c2cb1e05 | 2026-01-04T15:05:15.717211Z | false |
z-song/laravel-admin | https://github.com/z-song/laravel-admin/blob/67c441eb78ecc5437e59775d89770cd9c2cb1e05/src/Auth/Database/Administrator.php | src/Auth/Database/Administrator.php | <?php
namespace Encore\Admin\Auth\Database;
use Encore\Admin\Traits\DefaultDatetimeFormat;
use Illuminate\Auth\Authenticatable;
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Support\Facades\Storage;
/**
* Class Administrator.
*
* @property Role[] $roles
*/
class Administrator extends Model implements AuthenticatableContract
{
use Authenticatable;
use HasPermissions;
use DefaultDatetimeFormat;
protected $fillable = ['username', 'password', 'name', 'avatar'];
/**
* Create a new Eloquent model instance.
*
* @param array $attributes
*/
public function __construct(array $attributes = [])
{
$connection = config('admin.database.connection') ?: config('database.default');
$this->setConnection($connection);
$this->setTable(config('admin.database.users_table'));
parent::__construct($attributes);
}
/**
* Get avatar attribute.
*
* @param string $avatar
*
* @return string
*/
public function getAvatarAttribute($avatar)
{
if ($avatar && url()->isValidUrl($avatar)) {
return $avatar;
}
$disk = config('admin.upload.disk');
if ($avatar && array_key_exists($disk, config('filesystems.disks'))) {
return Storage::disk(config('admin.upload.disk'))->url($avatar);
}
$default = config('admin.default_avatar') ?: '/vendor/laravel-admin/AdminLTE/dist/img/user2-160x160.jpg';
return admin_asset($default);
}
/**
* A user has and belongs to many roles.
*
* @return BelongsToMany
*/
public function roles(): BelongsToMany
{
$pivotTable = config('admin.database.role_users_table');
$relatedModel = config('admin.database.roles_model');
return $this->belongsToMany($relatedModel, $pivotTable, 'user_id', 'role_id');
}
/**
* A User has and belongs to many permissions.
*
* @return BelongsToMany
*/
public function permissions(): BelongsToMany
{
$pivotTable = config('admin.database.user_permissions_table');
$relatedModel = config('admin.database.permissions_model');
return $this->belongsToMany($relatedModel, $pivotTable, 'user_id', 'permission_id');
}
}
| php | MIT | 67c441eb78ecc5437e59775d89770cd9c2cb1e05 | 2026-01-04T15:05:15.717211Z | false |
z-song/laravel-admin | https://github.com/z-song/laravel-admin/blob/67c441eb78ecc5437e59775d89770cd9c2cb1e05/src/Auth/Database/Menu.php | src/Auth/Database/Menu.php | <?php
namespace Encore\Admin\Auth\Database;
use Encore\Admin\Traits\DefaultDatetimeFormat;
use Encore\Admin\Traits\ModelTree;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Support\Facades\DB;
/**
* Class Menu.
*
* @property int $id
*
* @method where($parent_id, $id)
*/
class Menu extends Model
{
use DefaultDatetimeFormat;
use ModelTree {
ModelTree::boot as treeBoot;
}
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = ['parent_id', 'order', 'title', 'icon', 'uri', 'permission'];
/**
* Create a new Eloquent model instance.
*
* @param array $attributes
*/
public function __construct(array $attributes = [])
{
$connection = config('admin.database.connection') ?: config('database.default');
$this->setConnection($connection);
$this->setTable(config('admin.database.menu_table'));
parent::__construct($attributes);
}
/**
* A Menu belongs to many roles.
*
* @return BelongsToMany
*/
public function roles(): BelongsToMany
{
$pivotTable = config('admin.database.role_menu_table');
$relatedModel = config('admin.database.roles_model');
return $this->belongsToMany($relatedModel, $pivotTable, 'menu_id', 'role_id');
}
/**
* @return array
*/
public function allNodes(): array
{
$connection = config('admin.database.connection') ?: config('database.default');
$orderColumn = DB::connection($connection)->getQueryGrammar()->wrap($this->orderColumn);
$byOrder = 'ROOT ASC,'.$orderColumn;
$query = static::query();
if (config('admin.check_menu_roles') !== false) {
$query->with('roles');
}
return $query->selectRaw('*, '.$orderColumn.' ROOT')->orderByRaw($byOrder)->get()->toArray();
}
/**
* determine if enable menu bind permission.
*
* @return bool
*/
public function withPermission()
{
return (bool) config('admin.menu_bind_permission');
}
/**
* Detach models from the relationship.
*
* @return void
*/
protected static function boot()
{
static::treeBoot();
static::deleting(function ($model) {
$model->roles()->detach();
});
}
}
| php | MIT | 67c441eb78ecc5437e59775d89770cd9c2cb1e05 | 2026-01-04T15:05:15.717211Z | false |
z-song/laravel-admin | https://github.com/z-song/laravel-admin/blob/67c441eb78ecc5437e59775d89770cd9c2cb1e05/src/Auth/Database/AdminTablesSeeder.php | src/Auth/Database/AdminTablesSeeder.php | <?php
namespace Encore\Admin\Auth\Database;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\Hash;
class AdminTablesSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
// create a user.
Administrator::truncate();
Administrator::create([
'username' => 'admin',
'password' => Hash::make('admin'),
'name' => 'Administrator',
]);
// create a role.
Role::truncate();
Role::create([
'name' => 'Administrator',
'slug' => 'administrator',
]);
// add role to user.
Administrator::first()->roles()->save(Role::first());
//create a permission
Permission::truncate();
Permission::insert([
[
'name' => 'All permission',
'slug' => '*',
'http_method' => '',
'http_path' => '*',
],
[
'name' => 'Dashboard',
'slug' => 'dashboard',
'http_method' => 'GET',
'http_path' => '/',
],
[
'name' => 'Login',
'slug' => 'auth.login',
'http_method' => '',
'http_path' => "/auth/login\r\n/auth/logout",
],
[
'name' => 'User setting',
'slug' => 'auth.setting',
'http_method' => 'GET,PUT',
'http_path' => '/auth/setting',
],
[
'name' => 'Auth management',
'slug' => 'auth.management',
'http_method' => '',
'http_path' => "/auth/roles\r\n/auth/permissions\r\n/auth/menu\r\n/auth/logs",
],
]);
Role::first()->permissions()->save(Permission::first());
// add default menus.
Menu::truncate();
Menu::insert([
[
'parent_id' => 0,
'order' => 1,
'title' => 'Dashboard',
'icon' => 'fa-bar-chart',
'uri' => '/',
],
[
'parent_id' => 0,
'order' => 2,
'title' => 'Admin',
'icon' => 'fa-tasks',
'uri' => '',
],
[
'parent_id' => 2,
'order' => 3,
'title' => 'Users',
'icon' => 'fa-users',
'uri' => 'auth/users',
],
[
'parent_id' => 2,
'order' => 4,
'title' => 'Roles',
'icon' => 'fa-user',
'uri' => 'auth/roles',
],
[
'parent_id' => 2,
'order' => 5,
'title' => 'Permission',
'icon' => 'fa-ban',
'uri' => 'auth/permissions',
],
[
'parent_id' => 2,
'order' => 6,
'title' => 'Menu',
'icon' => 'fa-bars',
'uri' => 'auth/menu',
],
[
'parent_id' => 2,
'order' => 7,
'title' => 'Operation log',
'icon' => 'fa-history',
'uri' => 'auth/logs',
],
]);
// add role to menu.
Menu::find(2)->roles()->save(Role::first());
}
}
| php | MIT | 67c441eb78ecc5437e59775d89770cd9c2cb1e05 | 2026-01-04T15:05:15.717211Z | false |
z-song/laravel-admin | https://github.com/z-song/laravel-admin/blob/67c441eb78ecc5437e59775d89770cd9c2cb1e05/src/Auth/Database/Role.php | src/Auth/Database/Role.php | <?php
namespace Encore\Admin\Auth\Database;
use Encore\Admin\Traits\DefaultDatetimeFormat;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
class Role extends Model
{
use DefaultDatetimeFormat;
protected $fillable = ['name', 'slug'];
/**
* Create a new Eloquent model instance.
*
* @param array $attributes
*/
public function __construct(array $attributes = [])
{
$connection = config('admin.database.connection') ?: config('database.default');
$this->setConnection($connection);
$this->setTable(config('admin.database.roles_table'));
parent::__construct($attributes);
}
/**
* A role belongs to many users.
*
* @return BelongsToMany
*/
public function administrators(): BelongsToMany
{
$pivotTable = config('admin.database.role_users_table');
$relatedModel = config('admin.database.users_model');
return $this->belongsToMany($relatedModel, $pivotTable, 'role_id', 'user_id');
}
/**
* A role belongs to many permissions.
*
* @return BelongsToMany
*/
public function permissions(): BelongsToMany
{
$pivotTable = config('admin.database.role_permissions_table');
$relatedModel = config('admin.database.permissions_model');
return $this->belongsToMany($relatedModel, $pivotTable, 'role_id', 'permission_id');
}
/**
* A role belongs to many menus.
*
* @return BelongsToMany
*/
public function menus(): BelongsToMany
{
$pivotTable = config('admin.database.role_menu_table');
$relatedModel = config('admin.database.menu_model');
return $this->belongsToMany($relatedModel, $pivotTable, 'role_id', 'menu_id');
}
/**
* Check user has permission.
*
* @param $permission
*
* @return bool
*/
public function can(string $permission): bool
{
return $this->permissions()->where('slug', $permission)->exists();
}
/**
* Check user has no permission.
*
* @param $permission
*
* @return bool
*/
public function cannot(string $permission): bool
{
return !$this->can($permission);
}
/**
* Detach models from the relationship.
*
* @return void
*/
protected static function boot()
{
parent::boot();
static::deleting(function ($model) {
$model->administrators()->detach();
$model->permissions()->detach();
});
}
}
| php | MIT | 67c441eb78ecc5437e59775d89770cd9c2cb1e05 | 2026-01-04T15:05:15.717211Z | false |
z-song/laravel-admin | https://github.com/z-song/laravel-admin/blob/67c441eb78ecc5437e59775d89770cd9c2cb1e05/src/Auth/Database/HasPermissions.php | src/Auth/Database/HasPermissions.php | <?php
namespace Encore\Admin\Auth\Database;
use Illuminate\Support\Collection;
trait HasPermissions
{
/**
* Get all permissions of user.
*
* @return mixed
*/
public function allPermissions(): Collection
{
return $this->roles()->with('permissions')->get()->pluck('permissions')->flatten()->merge($this->permissions);
}
/**
* Check if user has permission.
*
* @param $ability
* @param array $arguments
*
* @return bool
*/
public function can($ability, $arguments = []): bool
{
if (empty($ability)) {
return true;
}
if ($this->isAdministrator()) {
return true;
}
if ($this->permissions->pluck('slug')->contains($ability)) {
return true;
}
return $this->roles->pluck('permissions')->flatten()->pluck('slug')->contains($ability);
}
/**
* Check if user has no permission.
*
* @param $permission
*
* @return bool
*/
public function cannot(string $permission): bool
{
return !$this->can($permission);
}
/**
* Check if user is administrator.
*
* @return mixed
*/
public function isAdministrator(): bool
{
return $this->isRole('administrator');
}
/**
* Check if user is $role.
*
* @param string $role
*
* @return mixed
*/
public function isRole(string $role): bool
{
return $this->roles->pluck('slug')->contains($role);
}
/**
* Check if user in $roles.
*
* @param array $roles
*
* @return mixed
*/
public function inRoles(array $roles = []): bool
{
return $this->roles->pluck('slug')->intersect($roles)->isNotEmpty();
}
/**
* If visible for roles.
*
* @param $roles
*
* @return bool
*/
public function visible(array $roles = []): bool
{
if (empty($roles)) {
return true;
}
$roles = array_column($roles, 'slug');
return $this->inRoles($roles) || $this->isAdministrator();
}
/**
* Detach models from the relationship.
*
* @return void
*/
protected static function bootHasPermissions()
{
static::deleting(function ($model) {
$model->roles()->detach();
$model->permissions()->detach();
});
}
}
| php | MIT | 67c441eb78ecc5437e59775d89770cd9c2cb1e05 | 2026-01-04T15:05:15.717211Z | false |
z-song/laravel-admin | https://github.com/z-song/laravel-admin/blob/67c441eb78ecc5437e59775d89770cd9c2cb1e05/src/Auth/Database/Permission.php | src/Auth/Database/Permission.php | <?php
namespace Encore\Admin\Auth\Database;
use Encore\Admin\Traits\DefaultDatetimeFormat;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Http\Request;
use Illuminate\Support\Str;
class Permission extends Model
{
use DefaultDatetimeFormat;
/**
* @var array
*/
protected $fillable = ['name', 'slug', 'http_method', 'http_path'];
/**
* @var array
*/
public static $httpMethods = [
'GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'OPTIONS', 'HEAD',
];
/**
* Create a new Eloquent model instance.
*
* @param array $attributes
*/
public function __construct(array $attributes = [])
{
$connection = config('admin.database.connection') ?: config('database.default');
$this->setConnection($connection);
$this->setTable(config('admin.database.permissions_table'));
parent::__construct($attributes);
}
/**
* Permission belongs to many roles.
*
* @return BelongsToMany
*/
public function roles(): BelongsToMany
{
$pivotTable = config('admin.database.role_permissions_table');
$relatedModel = config('admin.database.roles_model');
return $this->belongsToMany($relatedModel, $pivotTable, 'permission_id', 'role_id');
}
/**
* If request should pass through the current permission.
*
* @param Request $request
*
* @return bool
*/
public function shouldPassThrough(Request $request): bool
{
if (empty($this->http_method) && empty($this->http_path)) {
return true;
}
$method = $this->http_method;
$matches = array_map(function ($path) use ($method) {
$path = trim(config('admin.route.prefix'), '/').$path;
if (Str::contains($path, ':')) {
list($method, $path) = explode(':', $path);
$method = explode(',', $method);
}
return compact('method', 'path');
}, explode("\n", $this->http_path));
foreach ($matches as $match) {
if ($this->matchRequest($match, $request)) {
return true;
}
}
return false;
}
/**
* filter \r.
*
* @param string $path
*
* @return mixed
*/
public function getHttpPathAttribute($path)
{
return str_replace("\r\n", "\n", $path);
}
/**
* If a request match the specific HTTP method and path.
*
* @param array $match
* @param Request $request
*
* @return bool
*/
protected function matchRequest(array $match, Request $request): bool
{
if ($match['path'] == '/') {
$path = '/';
} else {
$path = trim($match['path'], '/');
}
if (!$request->is($path)) {
return false;
}
$method = collect($match['method'])->filter()->map(function ($method) {
return strtoupper($method);
});
return $method->isEmpty() || $method->contains($request->method());
}
/**
* @param $method
*/
public function setHttpMethodAttribute($method)
{
if (is_array($method)) {
$this->attributes['http_method'] = implode(',', $method);
}
}
/**
* @param $method
*
* @return array
*/
public function getHttpMethodAttribute($method)
{
if (is_string($method)) {
return array_filter(explode(',', $method));
}
return $method;
}
/**
* Detach models from the relationship.
*
* @return void
*/
protected static function boot()
{
parent::boot();
static::deleting(function ($model) {
$model->roles()->detach();
});
}
}
| php | MIT | 67c441eb78ecc5437e59775d89770cd9c2cb1e05 | 2026-01-04T15:05:15.717211Z | false |
z-song/laravel-admin | https://github.com/z-song/laravel-admin/blob/67c441eb78ecc5437e59775d89770cd9c2cb1e05/src/Facades/Admin.php | src/Facades/Admin.php | <?php
namespace Encore\Admin\Facades;
use Illuminate\Support\Facades\Facade;
/**
* Class Admin.
*
* @method static \Encore\Admin\Grid grid($model, \Closure $callable)
* @method static \Encore\Admin\Form form($model, \Closure $callable)
* @method static \Encore\Admin\Show show($model, $callable = null)
* @method static \Encore\Admin\Tree tree($model, \Closure $callable = null)
* @method static \Encore\Admin\Layout\Content content(\Closure $callable = null)
* @method static \Illuminate\Contracts\View\Factory|\Illuminate\View\View|void css($css = null)
* @method static \Illuminate\Contracts\View\Factory|\Illuminate\View\View|void js($js = null)
* @method static \Illuminate\Contracts\View\Factory|\Illuminate\View\View|void headerJs($js = null)
* @method static \Illuminate\Contracts\View\Factory|\Illuminate\View\View|void script($script = '')
* @method static \Illuminate\Contracts\View\Factory|\Illuminate\View\View|void style($style = '')
* @method static \Illuminate\Contracts\Auth\Authenticatable|null user()
* @method static \Illuminate\Contracts\Auth\Guard|\Illuminate\Contracts\Auth\StatefulGuard guard()
* @method static string title()
* @method static void navbar(\Closure $builder = null)
* @method static void registerAuthRoutes()
* @method static void extend($name, $class)
* @method static void disablePjax()
* @method static void booting(\Closure $builder)
* @method static void booted(\Closure $builder)
* @method static void bootstrap()
* @method static void routes()
*
* @see \Encore\Admin\Admin
*/
class Admin extends Facade
{
protected static function getFacadeAccessor()
{
return \Encore\Admin\Admin::class;
}
}
| php | MIT | 67c441eb78ecc5437e59775d89770cd9c2cb1e05 | 2026-01-04T15:05:15.717211Z | false |
z-song/laravel-admin | https://github.com/z-song/laravel-admin/blob/67c441eb78ecc5437e59775d89770cd9c2cb1e05/src/Console/ImportCommand.php | src/Console/ImportCommand.php | <?php
namespace Encore\Admin\Console;
use Encore\Admin\Admin;
use Illuminate\Console\Command;
use Illuminate\Support\Arr;
class ImportCommand extends Command
{
/**
* The console command name.
*
* @var string
*/
protected $signature = 'admin:import {extension?}';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Import a Laravel-admin extension';
/**
* Execute the console command.
*
* @return void
*/
public function handle()
{
$extension = $this->argument('extension');
if (empty($extension) || !Arr::has(Admin::$extensions, $extension)) {
$extension = $this->choice('Please choose a extension to import', array_keys(Admin::$extensions));
}
$className = Arr::get(Admin::$extensions, $extension);
if (!class_exists($className) || !method_exists($className, 'import')) {
$this->error("Invalid Extension [$className]");
return;
}
call_user_func([$className, 'import'], $this);
$this->info("Extension [$className] imported");
}
}
| php | MIT | 67c441eb78ecc5437e59775d89770cd9c2cb1e05 | 2026-01-04T15:05:15.717211Z | false |
z-song/laravel-admin | https://github.com/z-song/laravel-admin/blob/67c441eb78ecc5437e59775d89770cd9c2cb1e05/src/Console/ResetPasswordCommand.php | src/Console/ResetPasswordCommand.php | <?php
namespace Encore\Admin\Console;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Hash;
class ResetPasswordCommand extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'admin:reset-password';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Reset password for a specific admin user';
/**
* Execute the console command.
*/
public function handle()
{
$userModel = config('admin.database.users_model');
askForUserName:
$username = $this->ask('Please enter a username who needs to reset his password');
$user = $userModel::query()->where('username', $username)->first();
if (is_null($user)) {
$this->error('The user you entered is not exists');
goto askForUserName;
}
enterPassword:
$password = $this->secret('Please enter a password');
if ($password !== $this->secret('Please confirm the password')) {
$this->error('The passwords entered twice do not match, please re-enter');
goto enterPassword;
}
$user->password = Hash::make($password);
$user->save();
$this->info('User password reset successfully.');
}
}
| php | MIT | 67c441eb78ecc5437e59775d89770cd9c2cb1e05 | 2026-01-04T15:05:15.717211Z | false |
z-song/laravel-admin | https://github.com/z-song/laravel-admin/blob/67c441eb78ecc5437e59775d89770cd9c2cb1e05/src/Console/GenerateMenuCommand.php | src/Console/GenerateMenuCommand.php | <?php
namespace Encore\Admin\Console;
use Encore\Admin\Auth\Database\Menu;
use Illuminate\Console\Command;
use Illuminate\Routing\Route;
use Illuminate\Routing\Router;
use Illuminate\Support\Str;
class GenerateMenuCommand extends Command
{
/**
* @var Router
*/
protected $router;
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'admin:generate-menu {--dry-run : Dry run}';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Generate menu items based on registered routes.';
/**
* Create a new command instance.
*
* @param Router $router
*/
public function __construct(Router $router)
{
parent::__construct();
$this->router = $router;
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$prefix = config('admin.route.prefix');
$routes = collect($this->router->getRoutes())->filter(function (Route $route) use ($prefix) {
$uri = $route->uri();
// built-in, parameterized and no-GET are ignored
return Str::startsWith($uri, "{$prefix}/")
&& !Str::startsWith($uri, "{$prefix}/auth/")
&& !Str::endsWith($uri, '/create')
&& !Str::contains($uri, '{')
&& in_array('GET', $route->methods())
&& !in_array(substr($route->uri(), strlen("{$prefix}/")), config('admin.menu_exclude'));
})
->map(function (Route $route) use ($prefix) {
$uri = substr($route->uri(), strlen("{$prefix}/"));
return [
'title' => Str::ucfirst(
Str::snake(str_replace('/', ' ', $uri), ' ')
),
'uri' => $uri,
];
})
->pluck('title', 'uri');
$menus = Menu::all()->pluck('title', 'uri');
// exclude exist ones
$news = $routes->diffKeys($menus)->map(function ($item, $key) {
return [
'title' => $item,
'uri' => $key,
'order' => 10,
'icon' => 'fa-list',
];
})->values()->toArray();
if (!$news) {
$this->error('No newly registered routes found.');
} else {
if ($this->hasOption('dry-run') && $this->option('dry-run')) {
$this->line('<info>The following menu items will be created</info>: ');
$this->table(['Title', 'Uri'], array_map(function ($item) {
return [
$item['title'],
$item['uri'],
];
}, $news));
} else {
Menu::insert($news);
$this->line('<info>Done!</info>');
}
}
}
}
| php | MIT | 67c441eb78ecc5437e59775d89770cd9c2cb1e05 | 2026-01-04T15:05:15.717211Z | false |
z-song/laravel-admin | https://github.com/z-song/laravel-admin/blob/67c441eb78ecc5437e59775d89770cd9c2cb1e05/src/Console/MakeCommand.php | src/Console/MakeCommand.php | <?php
namespace Encore\Admin\Console;
use Illuminate\Console\GeneratorCommand;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Str;
class MakeCommand extends GeneratorCommand
{
/**
* The console command name.
*
* @var string
*/
protected $signature = 'admin:make {name}
{--model=}
{--title=}
{--stub= : Path to the custom stub file. }
{--namespace=}
{--O|output}';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Make admin controller';
/**
* @var ResourceGenerator
*/
protected $generator;
/**
* @var string
*/
protected $controllerName;
/**
* @var string
*/
protected $modelName;
/**
* Execute the console command.
*
* @return void
*/
public function handle()
{
$this->modelName = $this->getModelName();
$this->controllerName = $this->getControllerName();
if (!$this->modelExists()) {
$this->error('Model does not exists !');
return false;
}
$stub = $this->option('stub');
if ($stub and !is_file($stub)) {
$this->error('The stub file dose not exist.');
return false;
}
$this->generator = new ResourceGenerator($this->modelName);
if ($this->option('output')) {
return $this->output($this->modelName);
}
if (parent::handle() !== false) {
$path = Str::plural(Str::kebab(class_basename($this->modelName)));
$this->line('');
$this->comment('Add the following route to app/Admin/routes.php:');
$this->line('');
$this->info(" \$router->resource('{$path}', {$this->controllerName}::class);");
$this->line('');
}
}
/**
* @return array|string|null
*/
protected function getControllerName()
{
return $this->argument('name');
}
/**
* @return array|string|null
*/
protected function getModelName()
{
return $this->option('model');
}
/**
* @throws \ReflectionException
*
* @return array|bool|string|null
*/
protected function getTitle()
{
if ($title = $this->option('title')) {
return $title;
}
return __((new \ReflectionClass($this->modelName))->getShortName());
}
/**
* @param string $modelName
*/
protected function output($modelName)
{
$this->alert("laravel-admin controller code for model [{$modelName}]");
$this->info($this->generator->generateGrid());
$this->info($this->generator->generateShow());
$this->info($this->generator->generateForm());
}
/**
* Determine if the model is exists.
*
* @return bool
*/
protected function modelExists()
{
if (empty($this->modelName)) {
return true;
}
return class_exists($this->modelName) && is_subclass_of($this->modelName, Model::class);
}
/**
* Replace the class name for the given stub.
*
* @param string $stub
* @param string $name
*
* @return string
*/
protected function replaceClass($stub, $name)
{
$stub = parent::replaceClass($stub, $name);
return str_replace(
[
'DummyModelNamespace',
'DummyTitle',
'DummyModel',
'DummyGrid',
'DummyShow',
'DummyForm',
],
[
$this->modelName,
$this->getTitle(),
class_basename($this->modelName),
$this->indentCodes($this->generator->generateGrid()),
$this->indentCodes($this->generator->generateShow()),
$this->indentCodes($this->generator->generateForm()),
],
$stub
);
}
/**
* @param string $code
*
* @return string
*/
protected function indentCodes($code)
{
$indent = str_repeat(' ', 8);
return rtrim($indent.preg_replace("/\r\n/", "\r\n{$indent}", $code));
}
/**
* Get the stub file for the generator.
*
* @return string
*/
protected function getStub()
{
if ($stub = $this->option('stub')) {
return $stub;
}
if ($this->modelName) {
return __DIR__.'/stubs/controller.stub';
}
return __DIR__.'/stubs/blank.stub';
}
/**
* Get the default namespace for the class.
*
* @param string $rootNamespace
*
* @return string
*/
protected function getDefaultNamespace($rootNamespace)
{
if ($namespace = $this->option('namespace')) {
return $namespace;
}
return config('admin.route.namespace');
}
/**
* Get the desired class name from the input.
*
* @return string
*/
protected function getNameInput()
{
$this->type = $this->qualifyClass($this->controllerName);
return $this->controllerName;
}
}
| php | MIT | 67c441eb78ecc5437e59775d89770cd9c2cb1e05 | 2026-01-04T15:05:15.717211Z | false |
z-song/laravel-admin | https://github.com/z-song/laravel-admin/blob/67c441eb78ecc5437e59775d89770cd9c2cb1e05/src/Console/ResourceGenerator.php | src/Console/ResourceGenerator.php | <?php
namespace Encore\Admin\Console;
use Illuminate\Database\Eloquent\Model;
class ResourceGenerator
{
/**
* @var Model
*/
protected $model;
/**
* @var array
*/
protected $formats = [
'form_field' => "\$form->%s('%s', __('%s'))",
'show_field' => "\$show->field('%s', __('%s'))",
'grid_column' => "\$grid->column('%s', __('%s'))",
];
/**
* @var array
*/
private $doctrineTypeMapping = [
'string' => [
'enum', 'geometry', 'geometrycollection', 'linestring',
'polygon', 'multilinestring', 'multipoint', 'multipolygon',
'point',
],
];
/**
* @var array
*/
protected $fieldTypeMapping = [
'ip' => 'ip',
'email' => 'email|mail',
'password' => 'password|pwd',
'url' => 'url|link|src|href',
'mobile' => 'mobile|phone',
'color' => 'color|rgb',
'image' => 'image|img|avatar|pic|picture|cover',
'file' => 'file|attachment',
];
/**
* ResourceGenerator constructor.
*
* @param mixed $model
*/
public function __construct($model)
{
$this->model = $this->getModel($model);
}
/**
* @param mixed $model
*
* @return mixed
*/
protected function getModel($model)
{
if ($model instanceof Model) {
return $model;
}
if (!class_exists($model) || !is_string($model) || !is_subclass_of($model, Model::class)) {
throw new \InvalidArgumentException("Invalid model [$model] !");
}
return new $model();
}
/**
* @return string
*/
public function generateForm()
{
$reservedColumns = $this->getReservedColumns();
$output = '';
foreach ($this->getTableColumns() as $column) {
$name = $column->getName();
if (in_array($name, $reservedColumns)) {
continue;
}
$type = $column->getType()->getName();
$default = $column->getDefault();
$defaultValue = '';
// set column fieldType and defaultValue
switch ($type) {
case 'boolean':
case 'bool':
$fieldType = 'switch';
break;
case 'json':
case 'array':
case 'object':
$fieldType = 'text';
break;
case 'string':
$fieldType = 'text';
foreach ($this->fieldTypeMapping as $type => $regex) {
if (preg_match("/^($regex)$/i", $name) !== 0) {
$fieldType = $type;
break;
}
}
$defaultValue = "'{$default}'";
break;
case 'integer':
case 'bigint':
case 'smallint':
case 'timestamp':
$fieldType = 'number';
break;
case 'decimal':
case 'float':
case 'real':
$fieldType = 'decimal';
break;
case 'datetime':
$fieldType = 'datetime';
$defaultValue = "date('Y-m-d H:i:s')";
break;
case 'date':
$fieldType = 'date';
$defaultValue = "date('Y-m-d')";
break;
case 'time':
$fieldType = 'time';
$defaultValue = "date('H:i:s')";
break;
case 'text':
case 'blob':
$fieldType = 'textarea';
break;
default:
$fieldType = 'text';
$defaultValue = "'{$default}'";
}
$defaultValue = $defaultValue ?: $default;
$label = $this->formatLabel($name);
$output .= sprintf($this->formats['form_field'], $fieldType, $name, $label);
if (trim($defaultValue, "'\"")) {
$output .= "->default({$defaultValue})";
}
$output .= ";\r\n";
}
return $output;
}
public function generateShow()
{
$output = '';
foreach ($this->getTableColumns() as $column) {
$name = $column->getName();
// set column label
$label = $this->formatLabel($name);
$output .= sprintf($this->formats['show_field'], $name, $label);
$output .= ";\r\n";
}
return $output;
}
public function generateGrid()
{
$output = '';
foreach ($this->getTableColumns() as $column) {
$name = $column->getName();
$label = $this->formatLabel($name);
$output .= sprintf($this->formats['grid_column'], $name, $label);
$output .= ";\r\n";
}
return $output;
}
protected function getReservedColumns()
{
return [
$this->model->getKeyName(),
$this->model->getCreatedAtColumn(),
$this->model->getUpdatedAtColumn(),
'deleted_at',
];
}
/**
* Get columns of a giving model.
*
* @throws \Exception
*
* @return \Doctrine\DBAL\Schema\Column[]
*/
protected function getTableColumns()
{
if (!$this->model->getConnection()->isDoctrineAvailable()) {
throw new \Exception(
'You need to require doctrine/dbal: ~2.3 in your own composer.json to get database columns. '
);
}
$table = $this->model->getConnection()->getTablePrefix().$this->model->getTable();
/** @var \Doctrine\DBAL\Schema\MySqlSchemaManager $schema */
$schema = $this->model->getConnection()->getDoctrineSchemaManager($table);
// custom mapping the types that doctrine/dbal does not support
$databasePlatform = $schema->getDatabasePlatform();
foreach ($this->doctrineTypeMapping as $doctrineType => $dbTypes) {
foreach ($dbTypes as $dbType) {
$databasePlatform->registerDoctrineTypeMapping($dbType, $doctrineType);
}
}
$database = null;
if (strpos($table, '.')) {
list($database, $table) = explode('.', $table);
}
return $schema->listTableColumns($table, $database);
}
/**
* Format label.
*
* @param string $value
*
* @return string
*/
protected function formatLabel($value)
{
return ucfirst(str_replace(['-', '_'], ' ', $value));
}
}
| php | MIT | 67c441eb78ecc5437e59775d89770cd9c2cb1e05 | 2026-01-04T15:05:15.717211Z | false |
z-song/laravel-admin | https://github.com/z-song/laravel-admin/blob/67c441eb78ecc5437e59775d89770cd9c2cb1e05/src/Console/ConfigCommand.php | src/Console/ConfigCommand.php | <?php
namespace Encore\Admin\Console;
use Illuminate\Console\Command;
use Illuminate\Support\Arr;
class ConfigCommand extends Command
{
/**
* The console command name.
*
* @var string
*/
protected $signature = 'admin:config {path?}';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Compare the difference between the admin config file and the original';
/**
* {@inheritdoc}
*/
public function handle()
{
$path = $this->argument('path') ?: 'config/admin.php';
$current = require $path;
$original = require __DIR__.'/../../config/admin.php';
$added = $this->diff($current, $original);
$removed = $this->diff($original, $current);
if ($added->isEmpty() && $removed->isEmpty()) {
$this->info('Configuration items have not been modified');
return;
}
$this->line("The admin config file `$path`:");
$this->printDiff('Added', $added);
$this->printDiff('Removed', $removed, true);
$this->line('');
$this->comment('Please open `vendor/encore/laravel-admin/config/admin.php` to check the difference');
}
protected function diff(array $from, array $to)
{
return collect(Arr::dot($from))
->keys()
->reject(function ($key) use ($to) {
return Arr::has($to, $key);
});
}
protected function printDiff($title, $diff, $error = false)
{
if ($diff->isEmpty()) {
return;
}
$this->line('');
$this->comment("{$title}:");
$diff->each(function ($key) use ($error) {
if ($error) {
$this->error(" {$key}");
} else {
$this->info(" {$key}");
}
});
}
}
| php | MIT | 67c441eb78ecc5437e59775d89770cd9c2cb1e05 | 2026-01-04T15:05:15.717211Z | false |
z-song/laravel-admin | https://github.com/z-song/laravel-admin/blob/67c441eb78ecc5437e59775d89770cd9c2cb1e05/src/Console/CreateUserCommand.php | src/Console/CreateUserCommand.php | <?php
namespace Encore\Admin\Console;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Hash;
class CreateUserCommand extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'admin:create-user';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Create a admin user';
/**
* Execute the console command.
*/
public function handle()
{
$userModel = config('admin.database.users_model');
$roleModel = config('admin.database.roles_model');
$username = $this->ask('Please enter a username to login');
$password = Hash::make($this->secret('Please enter a password to login'));
$name = $this->ask('Please enter a name to display');
$roles = $roleModel::all();
/** @var array $selected */
$selectedOption = $roles->pluck('name')->toArray();
if (empty($selectedOption)) {
$selected = $this->choice('Please choose a role for the user', $selectedOption, null, null, true);
$roles = $roles->filter(function ($role) use ($selected) {
return in_array($role->name, $selected);
});
}
$user = new $userModel(compact('username', 'password', 'name'));
$user->save();
if (isset($roles)) {
$user->roles()->attach($roles);
}
$this->info("User [$name] created successfully.");
}
}
| php | MIT | 67c441eb78ecc5437e59775d89770cd9c2cb1e05 | 2026-01-04T15:05:15.717211Z | false |
z-song/laravel-admin | https://github.com/z-song/laravel-admin/blob/67c441eb78ecc5437e59775d89770cd9c2cb1e05/src/Console/ActionCommand.php | src/Console/ActionCommand.php | <?php
namespace Encore\Admin\Console;
use Illuminate\Console\GeneratorCommand;
use Illuminate\Support\Str;
class ActionCommand extends GeneratorCommand
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'admin:action {name}
{--grid-batch}
{--grid-row}
{--form}
{--dialog}
{--name=}
{--namespace=}';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Make a admin action';
/**
* Replace the class name for the given stub.
*
* @param string $stub
* @param string $name
*
* @return string
*/
protected function replaceClass($stub, $name)
{
$stub = parent::replaceClass($stub, $name);
return str_replace(
[
'DummyName',
'DummySelector',
'DummyInteractor',
],
[
$this->option('name'),
Str::kebab(class_basename($this->argument('name'))),
$this->generateInteractor(),
],
$stub
);
}
protected function generateInteractor()
{
if ($this->option('form')) {
return <<<'CODE'
public function form()
{
$this->text('name')->rules('required');
$this->email('email')->rules('email');
$this->datetime('created_at');
}
CODE;
} elseif ($this->option('dialog')) {
return <<<'CODE'
public function dialog()
{
$this->confirm('Confirm message...');
}
CODE;
}
return '';
}
/**
* Get the stub file for the generator.
*
* @return string
*/
public function getStub()
{
if ($this->option('grid-batch')) {
return __DIR__.'/stubs/grid-batch-action.stub';
}
if ($this->option('grid-row')) {
return __DIR__.'/stubs/grid-row-action.stub';
}
return __DIR__.'/stubs/action.stub';
}
/**
* Get the default namespace for the class.
*
* @param string $rootNamespace
*
* @return string
*/
protected function getDefaultNamespace($rootNamespace)
{
if ($namespace = $this->option('namespace')) {
return $namespace;
}
$segments = explode('\\', config('admin.route.namespace'));
array_pop($segments);
array_push($segments, 'Actions');
return implode('\\', $segments);
}
/**
* Get the desired class name from the input.
*
* @return string
*/
protected function getNameInput()
{
$name = trim($this->argument('name'));
$this->type = $this->qualifyClass($name);
return $name;
}
}
| php | MIT | 67c441eb78ecc5437e59775d89770cd9c2cb1e05 | 2026-01-04T15:05:15.717211Z | false |
z-song/laravel-admin | https://github.com/z-song/laravel-admin/blob/67c441eb78ecc5437e59775d89770cd9c2cb1e05/src/Console/InstallCommand.php | src/Console/InstallCommand.php | <?php
namespace Encore\Admin\Console;
use Illuminate\Console\Command;
class InstallCommand extends Command
{
/**
* The console command name.
*
* @var string
*/
protected $signature = 'admin:install';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Install the admin package';
/**
* Install directory.
*
* @var string
*/
protected $directory = '';
/**
* Execute the console command.
*
* @return void
*/
public function handle()
{
$this->initDatabase();
$this->initAdminDirectory();
}
/**
* Create tables and seed it.
*
* @return void
*/
public function initDatabase()
{
$this->call('migrate');
$userModel = config('admin.database.users_model');
if ($userModel::count() == 0) {
$this->call('db:seed', ['--class' => \Encore\Admin\Auth\Database\AdminTablesSeeder::class]);
}
}
/**
* Initialize the admAin directory.
*
* @return void
*/
protected function initAdminDirectory()
{
$this->directory = config('admin.directory');
if (is_dir($this->directory)) {
$this->line("<error>{$this->directory} directory already exists !</error> ");
return;
}
$this->makeDir('/');
$this->line('<info>Admin directory was created:</info> '.str_replace(base_path(), '', $this->directory));
$this->makeDir('Controllers');
$this->createHomeController();
$this->createAuthController();
$this->createExampleController();
$this->createBootstrapFile();
$this->createRoutesFile();
}
/**
* Create HomeController.
*
* @return void
*/
public function createHomeController()
{
$homeController = $this->directory.'/Controllers/HomeController.php';
$contents = $this->getStub('HomeController');
$this->laravel['files']->put(
$homeController,
str_replace('DummyNamespace', config('admin.route.namespace'), $contents)
);
$this->line('<info>HomeController file was created:</info> '.str_replace(base_path(), '', $homeController));
}
/**
* Create AuthController.
*
* @return void
*/
public function createAuthController()
{
$authController = $this->directory.'/Controllers/AuthController.php';
$contents = $this->getStub('AuthController');
$this->laravel['files']->put(
$authController,
str_replace('DummyNamespace', config('admin.route.namespace'), $contents)
);
$this->line('<info>AuthController file was created:</info> '.str_replace(base_path(), '', $authController));
}
/**
* Create HomeController.
*
* @return void
*/
public function createExampleController()
{
$exampleController = $this->directory.'/Controllers/ExampleController.php';
$contents = $this->getStub('ExampleController');
$this->laravel['files']->put(
$exampleController,
str_replace('DummyNamespace', config('admin.route.namespace'), $contents)
);
$this->line('<info>ExampleController file was created:</info> '.str_replace(base_path(), '', $exampleController));
}
/**
* Create routes file.
*
* @return void
*/
protected function createBootstrapFile()
{
$file = $this->directory.'/bootstrap.php';
$contents = $this->getStub('bootstrap');
$this->laravel['files']->put($file, $contents);
$this->line('<info>Bootstrap file was created:</info> '.str_replace(base_path(), '', $file));
}
/**
* Create routes file.
*
* @return void
*/
protected function createRoutesFile()
{
$file = $this->directory.'/routes.php';
$contents = $this->getStub('routes');
$this->laravel['files']->put($file, str_replace('DummyNamespace', config('admin.route.namespace'), $contents));
$this->line('<info>Routes file was created:</info> '.str_replace(base_path(), '', $file));
}
/**
* Get stub contents.
*
* @param $name
*
* @return string
*/
protected function getStub($name)
{
return $this->laravel['files']->get(__DIR__."/stubs/$name.stub");
}
/**
* Make new directory.
*
* @param string $path
*/
protected function makeDir($path = '')
{
$this->laravel['files']->makeDirectory("{$this->directory}/$path", 0755, true, true);
}
}
| php | MIT | 67c441eb78ecc5437e59775d89770cd9c2cb1e05 | 2026-01-04T15:05:15.717211Z | false |
z-song/laravel-admin | https://github.com/z-song/laravel-admin/blob/67c441eb78ecc5437e59775d89770cd9c2cb1e05/src/Console/PermissionCommand.php | src/Console/PermissionCommand.php | <?php
namespace Encore\Admin\Console;
use Encore\Admin\Auth\Database\Permission;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Str;
class PermissionCommand extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'admin:permissions {--tables=}';
/**
* The console command description.
*
* @var string
*/
protected $description = 'generate admin permission base on table name';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$all_tables = $this->getAllTables();
$tables = $this->option('tables') ? explode(',', $this->option('tables')) : [];
if (empty($tables)) {
$ignore_tables = $this->getIgnoreTables();
$tables = array_diff($all_tables, $ignore_tables);
} else {
$tables = array_intersect($all_tables, $tables);
}
if (empty($tables)) {
$this->info('table is not existed');
return;
}
$permissions = $this->getPermissions();
foreach ($tables as $table) {
foreach ($permissions as $permission => $permission_lang) {
$http_method = $this->generateHttpMethod($permission);
$http_path = $this->generateHttpPath($table, $permission);
$slug = $this->generateSlug($table, $permission);
$name = $this->generateName($table, $permission_lang);
$exists = Permission::where('slug', $slug)->exists();
if (!$exists) {
Permission::create([
'name' => $name,
'slug' => $slug,
'http_method' => $http_method,
'http_path' => $http_path,
]);
$this->info("$slug is generated");
} else {
$this->warn("$slug is existed");
}
}
}
}
private function getAllTables()
{
return array_map('current', DB::select('SHOW TABLES'));
}
private function getIgnoreTables()
{
return [
config('admin.database.users_table'),
config('admin.database.roles_table'),
config('admin.database.permissions_table'),
config('admin.database.menu_table'),
config('admin.database.operation_log_table'),
config('admin.database.user_permissions_table'),
config('admin.database.role_users_table'),
config('admin.database.role_permissions_table'),
config('admin.database.role_menu_table'),
];
}
private function getPermissions()
{
return [
'list' => __('admin.list'),
'view' => __('admin.view'),
'create' => __('admin.create'),
'edit' => __('admin.edit'),
'delete' => __('admin.delete'),
'export' => __('admin.export'),
'filter' => __('admin.filter'),
];
}
private function generateHttpMethod($permission)
{
switch ($permission) {
case 'create':
$http_method = ['POST'];
break;
case 'edit':
$http_method = ['PUT', 'PATCH'];
break;
case 'delete':
$http_method = ['DELETE'];
break;
default:
$http_method = ['GET'];
}
return $http_method;
}
private function generateHttpPath($table, $permission)
{
$resource = Str::kebab(Str::camel($table));
switch ($permission) {
case 'create':
case 'list':
case 'filter':
$http_path = '/'.$resource;
break;
case 'edit':
case 'delete':
case 'view':
$http_path = '/'.$resource.'/*';
break;
default:
$http_path = '';
}
return $http_path;
}
private function generateSlug($table, $permission)
{
return Str::kebab(Str::camel($table)).'.'.$permission;
}
private function generateName($table, $permission_lang)
{
return Str::upper(Str::kebab(Str::camel($table))).$permission_lang;
}
}
| php | MIT | 67c441eb78ecc5437e59775d89770cd9c2cb1e05 | 2026-01-04T15:05:15.717211Z | false |
z-song/laravel-admin | https://github.com/z-song/laravel-admin/blob/67c441eb78ecc5437e59775d89770cd9c2cb1e05/src/Console/AdminCommand.php | src/Console/AdminCommand.php | <?php
namespace Encore\Admin\Console;
use Encore\Admin\Admin;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Str;
class AdminCommand extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'admin';
/**
* The console command description.
*
* @var string
*/
protected $description = 'List all admin commands';
/**
* @var string
*/
public static $logo = <<<LOGO
__ __ __ _
/ / ____ __________ __ _____ / / ____ _____/ /___ ___ (_)___
/ / / __ `/ ___/ __ `/ | / / _ \/ /_____/ __ `/ __ / __ `__ \/ / __ \
/ /___/ /_/ / / / /_/ /| |/ / __/ /_____/ /_/ / /_/ / / / / / / / / / /
/_____/\__,_/_/ \__,_/ |___/\___/_/ \__,_/\__,_/_/ /_/ /_/_/_/ /_/
LOGO;
/**
* Execute the console command.
*/
public function handle()
{
$this->line(static::$logo);
$this->line(Admin::getLongVersion());
$this->comment('');
$this->comment('Available commands:');
$this->listAdminCommands();
}
/**
* List all admin commands.
*
* @return void
*/
protected function listAdminCommands()
{
$commands = collect(Artisan::all())->mapWithKeys(function ($command, $key) {
if (Str::startsWith($key, 'admin:')) {
return [$key => $command];
}
return [];
})->toArray();
$width = $this->getColumnWidth($commands);
/** @var Command $command */
foreach ($commands as $command) {
$this->line(sprintf(" %-{$width}s %s", $command->getName(), $command->getDescription()));
}
}
/**
* @param (Command|string)[] $commands
*
* @return int
*/
private function getColumnWidth(array $commands)
{
$widths = [];
foreach ($commands as $command) {
$widths[] = static::strlen($command->getName());
foreach ($command->getAliases() as $alias) {
$widths[] = static::strlen($alias);
}
}
return $widths ? max($widths) + 2 : 0;
}
/**
* Returns the length of a string, using mb_strwidth if it is available.
*
* @param string $string The string to check its length
*
* @return int The length of the string
*/
public static function strlen($string)
{
if (false === $encoding = mb_detect_encoding($string, null, true)) {
return strlen($string);
}
return mb_strwidth($string, $encoding);
}
}
| php | MIT | 67c441eb78ecc5437e59775d89770cd9c2cb1e05 | 2026-01-04T15:05:15.717211Z | false |
z-song/laravel-admin | https://github.com/z-song/laravel-admin/blob/67c441eb78ecc5437e59775d89770cd9c2cb1e05/src/Console/ControllerCommand.php | src/Console/ControllerCommand.php | <?php
namespace Encore\Admin\Console;
class ControllerCommand extends MakeCommand
{
/**
* The console command name.
*
* @var string
*/
protected $signature = 'admin:controller {model}
{--title=}
{--stub= : Path to the custom stub file. }
{--namespace=}
{--O|output}';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Make admin controller from giving model';
/**
* @return array|string|null
*/
protected function getModelName()
{
return $this->argument('model');
}
/**
* @throws \ReflectionException
*
* @return string
*/
protected function getControllerName()
{
$name = (new \ReflectionClass($this->modelName))->getShortName();
return $name.'Controller';
}
}
| php | MIT | 67c441eb78ecc5437e59775d89770cd9c2cb1e05 | 2026-01-04T15:05:15.717211Z | false |
z-song/laravel-admin | https://github.com/z-song/laravel-admin/blob/67c441eb78ecc5437e59775d89770cd9c2cb1e05/src/Console/MenuCommand.php | src/Console/MenuCommand.php | <?php
namespace Encore\Admin\Console;
use Encore\Admin\Facades\Admin;
use Illuminate\Console\Command;
class MenuCommand extends Command
{
/**
* The console command name.
*
* @var string
*/
protected $signature = 'admin:menu';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Show the admin menu';
/**
* Execute the console command.
*
* @return void
*/
public function handle()
{
$menu = Admin::menu();
echo json_encode($menu, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE), "\r\n";
}
}
| php | MIT | 67c441eb78ecc5437e59775d89770cd9c2cb1e05 | 2026-01-04T15:05:15.717211Z | false |
z-song/laravel-admin | https://github.com/z-song/laravel-admin/blob/67c441eb78ecc5437e59775d89770cd9c2cb1e05/src/Console/ExtendCommand.php | src/Console/ExtendCommand.php | <?php
namespace Encore\Admin\Console;
use Illuminate\Console\Command;
use Illuminate\Filesystem\Filesystem;
use Illuminate\Support\Str;
class ExtendCommand extends Command
{
/**
* The console command name.
*
* @var string
*/
protected $signature = 'admin:extend {extension} {--namespace=}';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Build a Laravel-admin extension';
/**
* @var string
*/
protected $basePath = '';
/**
* @var Filesystem
*/
protected $filesystem;
/**
* @var string
*/
protected $namespace;
/**
* @var string
*/
protected $className;
/**
* @var string
*/
protected $package;
/**
* @var string
*/
protected $extensionDir;
/**
* @var array
*/
protected $dirs = [
'database/migrations',
'database/seeds',
'resources/assets',
'resources/views',
'src/Http/Controllers',
'routes',
];
/**
* Execute the console command.
*
* @return void
*/
public function handle(Filesystem $filesystem)
{
$this->filesystem = $filesystem;
$this->extensionDir = config('admin.extension_dir');
InputExtensionDir:
if (empty($this->extensionDir)) {
$this->extensionDir = $this->ask('Please input a directory to store your extension:');
}
if (!file_exists($this->extensionDir)) {
$this->makeDir();
}
$this->package = $this->argument('extension');
InputExtensionName:
if (!$this->validateExtensionName($this->package)) {
$this->package = $this->ask("[$this->package] is not a valid package name, please input a name like (<vendor>/<name>)");
goto InputExtensionName;
}
$this->makeDirs();
$this->makeFiles();
$this->info("The extension scaffolding generated successfully. \r\n");
$this->showTree();
}
/**
* Show extension scaffolding with tree structure.
*/
protected function showTree()
{
$tree = <<<TREE
{$this->extensionPath()}
├── LICENSE
├── README.md
├── composer.json
├── database
│ ├── migrations
│ └── seeds
├── resources
│ ├── assets
│ └── views
│ └── index.blade.php
├── routes
│ └── web.php
└── src
├── {$this->className}.php
├── {$this->className}ServiceProvider.php
└── Http
└── Controllers
└── {$this->className}Controller.php
TREE;
$this->info($tree);
}
/**
* Make extension files.
*/
protected function makeFiles()
{
$this->namespace = $this->getRootNameSpace();
$this->className = $this->getClassName();
// copy files
$this->copy([
__DIR__.'/stubs/extension/view.stub' => 'resources/views/index.blade.php',
__DIR__.'/stubs/extension/.gitignore.stub' => '.gitignore',
__DIR__.'/stubs/extension/README.md.stub' => 'README.md',
__DIR__.'/stubs/extension/LICENSE.stub' => 'LICENSE',
]);
// make composer.json
$composerContents = str_replace(
[':package', ':namespace', ':class_name'],
[$this->package, str_replace('\\', '\\\\', $this->namespace).'\\\\', $this->className],
file_get_contents(__DIR__.'/stubs/extension/composer.json.stub')
);
$this->putFile('composer.json', $composerContents);
// make class
$classContents = str_replace(
[':namespace', ':class_name', ':title', ':path', ':base_package'],
[$this->namespace, $this->className, Str::title($this->className), basename($this->package), basename($this->package)],
file_get_contents(__DIR__.'/stubs/extension/extension.stub')
);
$this->putFile("src/{$this->className}.php", $classContents);
// make service provider
$providerContents = str_replace(
[':namespace', ':class_name', ':base_package', ':package'],
[$this->namespace, $this->className, basename($this->package), $this->package],
file_get_contents(__DIR__.'/stubs/extension/service-provider.stub')
);
$this->putFile("src/{$this->className}ServiceProvider.php", $providerContents);
// make controller
$controllerContent = str_replace(
[':namespace', ':class_name', ':base_package'],
[$this->namespace, $this->className, basename($this->package)],
file_get_contents(__DIR__.'/stubs/extension/controller.stub')
);
$this->putFile("src/Http/Controllers/{$this->className}Controller.php", $controllerContent);
// make routes
$routesContent = str_replace(
[':namespace', ':class_name', ':path'],
[$this->namespace, $this->className, basename($this->package)],
file_get_contents(__DIR__.'/stubs/extension/routes.stub')
);
$this->putFile('routes/web.php', $routesContent);
}
/**
* Get root namespace for this package.
*
* @return array|null|string
*/
protected function getRootNameSpace()
{
if (!$namespace = $this->option('namespace')) {
list($vendor, $name) = explode('/', $this->package);
$default = str_replace(['-', '-'], '', Str::title($vendor).'\\'.Str::title($name));
$namespace = $this->ask('Root namespace', $default);
}
return $namespace;
}
/**
* Get extension class name.
*
* @return string
*/
protected function getClassName()
{
return class_basename($this->namespace);
}
/**
* Create package dirs.
*/
protected function makeDirs()
{
$this->basePath = rtrim($this->extensionDir, '/').'/'.ltrim($this->package, '/');
$this->makeDir($this->dirs);
}
/**
* Validate extension name.
*
* @param string $name
*
* @return int
*/
protected function validateExtensionName($name)
{
return preg_match('/^[\w\-_]+\/[\w\-_]+$/', $name);
}
/**
* Extension path.
*
* @param string $path
*
* @return string
*/
protected function extensionPath($path = '')
{
$path = rtrim($path, '/');
if (empty($path)) {
return rtrim($this->basePath, '/');
}
return rtrim($this->basePath, '/').'/'.ltrim($path, '/');
}
/**
* Put contents to file.
*
* @param string $to
* @param string $content
*/
protected function putFile($to, $content)
{
$to = $this->extensionPath($to);
$this->filesystem->put($to, $content);
}
/**
* Copy files to extension path.
*
* @param string|array $from
* @param string|null $to
*/
protected function copy($from, $to = null)
{
if (is_array($from) && is_null($to)) {
foreach ($from as $key => $value) {
$this->copy($key, $value);
}
return;
}
if (!file_exists($from)) {
return;
}
$to = $this->extensionPath($to);
$this->filesystem->copy($from, $to);
}
/**
* Make new directory.
*
* @param array|string $paths
*/
protected function makeDir($paths = '')
{
foreach ((array) $paths as $path) {
$path = $this->extensionPath($path);
$this->filesystem->makeDirectory($path, 0755, true, true);
}
}
}
| php | MIT | 67c441eb78ecc5437e59775d89770cd9c2cb1e05 | 2026-01-04T15:05:15.717211Z | false |
z-song/laravel-admin | https://github.com/z-song/laravel-admin/blob/67c441eb78ecc5437e59775d89770cd9c2cb1e05/src/Console/MinifyCommand.php | src/Console/MinifyCommand.php | <?php
namespace Encore\Admin\Console;
use Encore\Admin\Admin;
use Encore\Admin\Facades\Admin as AdminFacade;
use Illuminate\Console\Command;
use Illuminate\Support\Str;
use MatthiasMullie\Minify;
class MinifyCommand extends Command
{
/**
* The console command name.
*
* @var string
*/
protected $signature = 'admin:minify {--clear}';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Minify the CSS and JS';
/**
* @var array
*/
protected $assets = [
'css' => [],
'js' => [],
];
/**
* @var array
*/
protected $excepts = [];
/**
* Execute the console command.
*/
public function handle()
{
if (!class_exists(Minify\Minify::class)) {
$this->error('To use `admin:minify` command, please install [matthiasmullie/minify] first.');
return;
}
if ($this->option('clear')) {
return $this->clearMinifiedFiles();
}
AdminFacade::bootstrap();
$this->loadExcepts();
$this->minifyCSS();
$this->minifyJS();
$this->generateManifest();
$this->comment('JS and CSS are successfully minified:');
$this->line(' '.Admin::$min['js']);
$this->line(' '.Admin::$min['css']);
$this->line('');
$this->comment('Manifest successfully generated:');
$this->line(' '.Admin::$manifest);
}
protected function loadExcepts()
{
$excepts = config('admin.minify_assets.excepts', []);
$this->excepts = array_merge($excepts, Admin::$minifyIgnores);
}
protected function clearMinifiedFiles()
{
@unlink(public_path(Admin::$manifest));
@unlink(public_path(Admin::$min['js']));
@unlink(public_path(Admin::$min['css']));
$this->comment('Following files are cleared:');
$this->line(' '.Admin::$min['js']);
$this->line(' '.Admin::$min['css']);
$this->line(' '.Admin::$manifest);
}
protected function minifyCSS()
{
$css = collect(array_merge(Admin::$css, Admin::baseCss()))
->unique()->map(function ($css) {
if (url()->isValidUrl($css)) {
$this->assets['css'][] = $css;
return;
}
if (in_array($css, $this->excepts)) {
$this->assets['css'][] = $css;
return;
}
if (Str::contains($css, '?')) {
$css = substr($css, 0, strpos($css, '?'));
}
return public_path($css);
})->filter();
$minifier = new Minify\CSS();
$minifier->add(...$css);
$minifier->minify(public_path(Admin::$min['css']));
}
protected function minifyJS()
{
$js = collect(array_merge(Admin::$js, Admin::baseJs()))
->unique()->map(function ($js) {
if (url()->isValidUrl($js)) {
$this->assets['js'][] = $js;
return;
}
if (in_array($js, $this->excepts)) {
$this->assets['js'][] = $js;
return;
}
if (Str::contains($js, '?')) {
$js = substr($js, 0, strpos($js, '?'));
}
return public_path($js);
})->filter();
$minifier = new Minify\JS();
$minifier->add(...$js);
$minifier->minify(public_path(Admin::$min['js']));
}
protected function generateManifest()
{
$min = collect(Admin::$min)->mapWithKeys(function ($path, $type) {
return [$type => sprintf('%s?id=%s', $path, md5(uniqid()))];
});
array_unshift($this->assets['css'], $min['css']);
array_unshift($this->assets['js'], $min['js']);
$json = json_encode($this->assets, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
file_put_contents(public_path(Admin::$manifest), $json);
}
}
| php | MIT | 67c441eb78ecc5437e59775d89770cd9c2cb1e05 | 2026-01-04T15:05:15.717211Z | false |
z-song/laravel-admin | https://github.com/z-song/laravel-admin/blob/67c441eb78ecc5437e59775d89770cd9c2cb1e05/src/Console/FormCommand.php | src/Console/FormCommand.php | <?php
namespace Encore\Admin\Console;
use Illuminate\Console\GeneratorCommand;
class FormCommand extends GeneratorCommand
{
/**
* The console command name.
*
* @var string
*/
protected $signature = 'admin:form {name}
{--title=}
{--step}
{--namespace=}';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Make admin form widget';
/**
* Replace the class name for the given stub.
*
* @param string $stub
* @param string $name
*
* @return string
*/
protected function replaceClass($stub, $name)
{
$stub = parent::replaceClass($stub, $name);
return str_replace('DummyTitle', $this->option('title'), $stub);
}
/**
* Get the stub file for the generator.
*
* @return string
*/
protected function getStub()
{
if ($this->option('step')) {
return __DIR__.'/stubs/step-form.stub';
}
return __DIR__.'/stubs/form.stub';
}
/**
* Get the default namespace for the class.
*
* @param string $rootNamespace
*
* @return string
*/
protected function getDefaultNamespace($rootNamespace)
{
if ($namespace = $this->option('namespace')) {
return $namespace;
}
return str_replace('Controllers', 'Forms', config('admin.route.namespace'));
}
/**
* Get the desired class name from the input.
*
* @return string
*/
protected function getNameInput()
{
$name = trim($this->argument('name'));
$this->type = $this->qualifyClass($name);
return $name;
}
}
| php | MIT | 67c441eb78ecc5437e59775d89770cd9c2cb1e05 | 2026-01-04T15:05:15.717211Z | false |
z-song/laravel-admin | https://github.com/z-song/laravel-admin/blob/67c441eb78ecc5437e59775d89770cd9c2cb1e05/src/Console/UninstallCommand.php | src/Console/UninstallCommand.php | <?php
namespace Encore\Admin\Console;
use Illuminate\Console\Command;
class UninstallCommand extends Command
{
/**
* The console command name.
*
* @var string
*/
protected $signature = 'admin:uninstall';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Uninstall the admin package';
/**
* Execute the console command.
*
* @return void
*/
public function handle()
{
if (!$this->confirm('Are you sure to uninstall laravel-admin?')) {
return;
}
$this->removeFilesAndDirectories();
$this->line('<info>Uninstalling laravel-admin!</info>');
}
/**
* Remove files and directories.
*
* @return void
*/
protected function removeFilesAndDirectories()
{
$this->laravel['files']->deleteDirectory(config('admin.directory'));
$this->laravel['files']->deleteDirectory(public_path('vendor/laravel-admin/'));
$this->laravel['files']->delete(config_path('admin.php'));
}
}
| php | MIT | 67c441eb78ecc5437e59775d89770cd9c2cb1e05 | 2026-01-04T15:05:15.717211Z | false |
z-song/laravel-admin | https://github.com/z-song/laravel-admin/blob/67c441eb78ecc5437e59775d89770cd9c2cb1e05/src/Console/ExportSeedCommand.php | src/Console/ExportSeedCommand.php | <?php
namespace Encore\Admin\Console;
use Illuminate\Console\Command;
class ExportSeedCommand extends Command
{
/**
* The console command name.
*
* @var string
*/
protected $signature = 'admin:export-seed {classname=AdminTablesSeeder}
{--users : add to seed users tables}
{--except-fields=id,created_at,updated_at : except fields}';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Export seed a Laravel-admin database tables menu, roles and permissions';
/**
* Execute the console command.
*
* @return void
*/
public function handle()
{
$name = $this->argument('classname');
$exceptFields = explode(',', $this->option('except-fields'));
$exportUsers = $this->option('users');
$seedFile = $this->laravel->databasePath().'/seeders/'.$name.'.php';
$contents = $this->getStub('AdminTablesSeeder');
$replaces = [
'DummyClass' => $name,
'ClassMenu' => config('admin.database.menu_model'),
'ClassPermission' => config('admin.database.permissions_model'),
'ClassRole' => config('admin.database.roles_model'),
'TableRoleMenu' => config('admin.database.role_menu_table'),
'TableRolePermissions' => config('admin.database.role_permissions_table'),
'ArrayMenu' => $this->getTableDataArrayAsString(config('admin.database.menu_table'), $exceptFields),
'ArrayPermission' => $this->getTableDataArrayAsString(config('admin.database.permissions_table'), $exceptFields),
'ArrayRole' => $this->getTableDataArrayAsString(config('admin.database.roles_table'), $exceptFields),
'ArrayPivotRoleMenu' => $this->getTableDataArrayAsString(config('admin.database.role_menu_table'), $exceptFields),
'ArrayPivotRolePermissions' => $this->getTableDataArrayAsString(config('admin.database.role_permissions_table'), $exceptFields),
];
if ($exportUsers) {
$replaces = array_merge($replaces, [
'ClassUsers' => config('admin.database.users_model'),
'TableRoleUsers' => config('admin.database.role_users_table'),
'TablePermissionsUsers' => config('admin.database.user_permissions_table'),
'ArrayUsers' => $this->getTableDataArrayAsString(config('admin.database.users_table'), $exceptFields),
'ArrayPivotRoleUsers' => $this->getTableDataArrayAsString(config('admin.database.role_users_table'), $exceptFields),
'ArrayPivotPermissionsUsers' => $this->getTableDataArrayAsString(config('admin.database.user_permissions_table'), $exceptFields),
]);
} else {
$contents = preg_replace('/\/\/ users tables[\s\S]*?(?=\/\/ finish)/mu', '', $contents);
}
$contents = str_replace(array_keys($replaces), array_values($replaces), $contents);
$this->laravel['files']->put($seedFile, $contents);
$this->line('<info>Admin tables seed file was created:</info> '.str_replace(base_path(), '', $seedFile));
$this->line("Use: <info>php artisan db:seed --class={$name}</info>");
}
/**
* Get data array from table as string result var_export.
*
* @param string $table
* @param array $exceptFields
*
* @return string
*/
protected function getTableDataArrayAsString($table, $exceptFields = [])
{
$fields = \DB::getSchemaBuilder()->getColumnListing($table);
$fields = array_diff($fields, $exceptFields);
$array = \DB::table($table)->get($fields)->map(function ($item) {
return (array) $item;
})->all();
return $this->varExport($array, str_repeat(' ', 12));
}
/**
* Get stub contents.
*
* @param $name
*
* @return string
*/
protected function getStub($name)
{
return $this->laravel['files']->get(__DIR__."/stubs/$name.stub");
}
/**
* Custom var_export for correct work with \r\n.
*
* @param $var
* @param string $indent
*
* @return string
*/
protected function varExport($var, $indent = '')
{
switch (gettype($var)) {
case 'string':
return '"'.addcslashes($var, "\\\$\"\r\n\t\v\f").'"';
case 'array':
$indexed = array_keys($var) === range(0, count($var) - 1);
$r = [];
foreach ($var as $key => $value) {
$r[] = "$indent "
.($indexed ? '' : $this->varExport($key).' => ')
.$this->varExport($value, "{$indent} ");
}
return "[\n".implode(",\n", $r)."\n".$indent.']';
case 'boolean':
return $var ? 'true' : 'false';
case 'integer':
case 'double':
return $var;
default:
return var_export($var, true);
}
}
}
| php | MIT | 67c441eb78ecc5437e59775d89770cd9c2cb1e05 | 2026-01-04T15:05:15.717211Z | false |
z-song/laravel-admin | https://github.com/z-song/laravel-admin/blob/67c441eb78ecc5437e59775d89770cd9c2cb1e05/src/Console/PublishCommand.php | src/Console/PublishCommand.php | <?php
namespace Encore\Admin\Console;
use Illuminate\Console\Command;
class PublishCommand extends Command
{
/**
* The console command name.
*
* @var string
*/
protected $signature = 'admin:publish {--force}';
/**
* The console command description.
*
* @var string
*/
protected $description = "re-publish laravel-admin's assets, configuration, language and migration files. If you want overwrite the existing files, you can add the `--force` option";
/**
* Execute the console command.
*
* @return void
*/
public function handle()
{
$force = $this->option('force');
$options = ['--provider' => 'Encore\Admin\AdminServiceProvider'];
if ($force == true) {
$options['--force'] = true;
}
$this->call('vendor:publish', $options);
$this->call('view:clear');
}
}
| php | MIT | 67c441eb78ecc5437e59775d89770cd9c2cb1e05 | 2026-01-04T15:05:15.717211Z | false |
z-song/laravel-admin | https://github.com/z-song/laravel-admin/blob/67c441eb78ecc5437e59775d89770cd9c2cb1e05/src/Exception/Handler.php | src/Exception/Handler.php | <?php
namespace Encore\Admin\Exception;
use Illuminate\Support\MessageBag;
use Illuminate\Support\ViewErrorBag;
class Handler
{
/**
* Render exception.
*
* @param \Exception $exception
*
* @return string
*/
public static function renderException(\Exception $exception)
{
$error = new MessageBag([
'type' => get_class($exception),
'message' => $exception->getMessage(),
'file' => $exception->getFile(),
'line' => $exception->getLine(),
'trace' => $exception->getTraceAsString(),
]);
$errors = new ViewErrorBag();
$errors->put('exception', $error);
return view('admin::partials.exception', compact('errors'))->render();
}
/**
* Flash a error message to content.
*
* @param string $title
* @param string $message
*
* @return mixed
*/
public static function error($title = '', $message = '')
{
$error = new MessageBag(compact('title', 'message'));
return session()->flash('error', $error);
}
}
| php | MIT | 67c441eb78ecc5437e59775d89770cd9c2cb1e05 | 2026-01-04T15:05:15.717211Z | false |
z-song/laravel-admin | https://github.com/z-song/laravel-admin/blob/67c441eb78ecc5437e59775d89770cd9c2cb1e05/src/Middleware/Pjax.php | src/Middleware/Pjax.php | <?php
namespace Encore\Admin\Middleware;
use Closure;
use Encore\Admin\Facades\Admin;
use Illuminate\Http\Request;
use Illuminate\Support\MessageBag;
use Symfony\Component\DomCrawler\Crawler;
use Symfony\Component\HttpFoundation\Response;
class Pjax
{
/**
* Handle an incoming request.
*
* @param Request $request
* @param Closure $next
*
* @return Response
*/
public function handle($request, Closure $next)
{
$response = $next($request);
if (!$request->pjax() || $response->isRedirection() || Admin::guard()->guest()) {
return $response;
}
if (!$response->isSuccessful()) {
return $this->handleErrorResponse($response);
}
try {
$this->filterResponse($response, $request->header('X-PJAX-CONTAINER'))
->setUriHeader($response, $request);
} catch (\Exception $exception) {
}
return $response;
}
/**
* Send a response through this middleware.
*
* @param Response $response
*/
public static function respond(Response $response)
{
$next = function () use ($response) {
return $response;
};
(new static())->handle(Request::capture(), $next)->send();
exit;
}
/**
* Handle Response with exceptions.
*
* @param Response $response
*
* @return \Illuminate\Http\RedirectResponse
*/
protected function handleErrorResponse(Response $response)
{
$exception = $response->exception;
$error = new MessageBag([
'type' => get_class($exception),
'message' => $exception->getMessage(),
'file' => $exception->getFile(),
'line' => $exception->getLine(),
]);
return back()->withInput()->withErrors($error, 'exception');
}
/**
* Prepare the PJAX-specific response content.
*
* @param Response $response
* @param string $container
*
* @return $this
*/
protected function filterResponse(Response $response, $container)
{
$crawler = new Crawler($response->getContent());
$response->setContent(
$this->makeTitle($crawler).
$this->fetchContents($crawler, $container)
);
return $this;
}
/**
* Prepare an HTML title tag.
*
* @param Crawler $crawler
*
* @return string
*/
protected function makeTitle($crawler)
{
$pageTitle = $crawler->filter('head > title')->html();
return "<title>{$pageTitle}</title>";
}
/**
* Fetch the PJAX-specific HTML from the response.
*
* @param Crawler $crawler
* @param string $container
*
* @return string
*/
protected function fetchContents($crawler, $container)
{
$content = $crawler->filter($container);
if (!$content->count()) {
abort(422);
}
return $this->decodeUtf8HtmlEntities($content->html());
}
/**
* Decode utf-8 characters to html entities.
*
* @param string $html
*
* @return string
*/
protected function decodeUtf8HtmlEntities($html)
{
return preg_replace_callback('/(&#[0-9]+;)/', function ($html) {
return mb_convert_encoding($html[1], 'UTF-8', 'HTML-ENTITIES');
}, $html);
}
/**
* Set the PJAX-URL header to the current uri.
*
* @param Response $response
* @param Request $request
*/
protected function setUriHeader(Response $response, Request $request)
{
$response->header(
'X-PJAX-URL',
$request->getRequestUri()
);
}
}
| php | MIT | 67c441eb78ecc5437e59775d89770cd9c2cb1e05 | 2026-01-04T15:05:15.717211Z | false |
z-song/laravel-admin | https://github.com/z-song/laravel-admin/blob/67c441eb78ecc5437e59775d89770cd9c2cb1e05/src/Middleware/Bootstrap.php | src/Middleware/Bootstrap.php | <?php
namespace Encore\Admin\Middleware;
use Closure;
use Encore\Admin\Facades\Admin;
use Illuminate\Http\Request;
class Bootstrap
{
public function handle(Request $request, Closure $next)
{
Admin::bootstrap();
return $next($request);
}
}
| php | MIT | 67c441eb78ecc5437e59775d89770cd9c2cb1e05 | 2026-01-04T15:05:15.717211Z | false |
z-song/laravel-admin | https://github.com/z-song/laravel-admin/blob/67c441eb78ecc5437e59775d89770cd9c2cb1e05/src/Middleware/Authenticate.php | src/Middleware/Authenticate.php | <?php
namespace Encore\Admin\Middleware;
use Closure;
use Encore\Admin\Facades\Admin;
class Authenticate
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
*
* @return mixed
*/
public function handle($request, Closure $next)
{
\config(['auth.defaults.guard' => 'admin']);
$redirectTo = admin_base_path(config('admin.auth.redirect_to', 'auth/login'));
if (Admin::guard()->guest() && !$this->shouldPassThrough($request)) {
return redirect()->to($redirectTo);
}
return $next($request);
}
/**
* Determine if the request has a URI that should pass through verification.
*
* @param \Illuminate\Http\Request $request
*
* @return bool
*/
protected function shouldPassThrough($request)
{
// 下面的路由不验证登陆
$excepts = config('admin.auth.excepts', []);
array_delete($excepts, [
'_handle_action_',
'_handle_form_',
'_handle_selectable_',
'_handle_renderable_',
]);
return collect($excepts)
->map('admin_base_path')
->contains(function ($except) use ($request) {
if ($except !== '/') {
$except = trim($except, '/');
}
return $request->is($except);
});
}
}
| php | MIT | 67c441eb78ecc5437e59775d89770cd9c2cb1e05 | 2026-01-04T15:05:15.717211Z | false |
z-song/laravel-admin | https://github.com/z-song/laravel-admin/blob/67c441eb78ecc5437e59775d89770cd9c2cb1e05/src/Middleware/Permission.php | src/Middleware/Permission.php | <?php
namespace Encore\Admin\Middleware;
use Encore\Admin\Auth\Permission as Checker;
use Encore\Admin\Facades\Admin;
use Illuminate\Http\Request;
use Illuminate\Support\Str;
class Permission
{
/**
* @var string
*/
protected $middlewarePrefix = 'admin.permission:';
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @param array $args
*
* @return mixed
*/
public function handle(Request $request, \Closure $next, ...$args)
{
if (config('admin.check_route_permission') === false) {
return $next($request);
}
if (!Admin::user() || !empty($args) || $this->shouldPassThrough($request)) {
return $next($request);
}
if ($this->checkRoutePermission($request)) {
return $next($request);
}
if (!Admin::user()->allPermissions()->first(function ($permission) use ($request) {
return $permission->shouldPassThrough($request);
})) {
Checker::error();
}
return $next($request);
}
/**
* If the route of current request contains a middleware prefixed with 'admin.permission:',
* then it has a manually set permission middleware, we need to handle it first.
*
* @param Request $request
*
* @return bool
*/
public function checkRoutePermission(Request $request)
{
if (!$middleware = collect($request->route()->middleware())->first(function ($middleware) {
return Str::startsWith($middleware, $this->middlewarePrefix);
})) {
return false;
}
$args = explode(',', str_replace($this->middlewarePrefix, '', $middleware));
$method = array_shift($args);
if (!method_exists(Checker::class, $method)) {
throw new \InvalidArgumentException("Invalid permission method [$method].");
}
call_user_func_array([Checker::class, $method], [$args]);
return true;
}
/**
* Determine if the request has a URI that should pass through verification.
*
* @param \Illuminate\Http\Request $request
*
* @return bool
*/
protected function shouldPassThrough($request)
{
// 下面这些路由不验证权限
$excepts = array_merge(config('admin.auth.excepts', []), [
'auth/login',
'auth/logout',
'_handle_action_',
'_handle_form_',
'_handle_selectable_',
'_handle_renderable_',
]);
return collect($excepts)
->map('admin_base_path')
->contains(function ($except) use ($request) {
if ($except !== '/') {
$except = trim($except, '/');
}
return $request->is($except);
});
}
}
| php | MIT | 67c441eb78ecc5437e59775d89770cd9c2cb1e05 | 2026-01-04T15:05:15.717211Z | false |
z-song/laravel-admin | https://github.com/z-song/laravel-admin/blob/67c441eb78ecc5437e59775d89770cd9c2cb1e05/src/Middleware/LogOperation.php | src/Middleware/LogOperation.php | <?php
namespace Encore\Admin\Middleware;
use Encore\Admin\Auth\Database\OperationLog as OperationLogModel;
use Encore\Admin\Facades\Admin;
use Illuminate\Http\Request;
use Illuminate\Support\Str;
class LogOperation
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
*
* @return mixed
*/
public function handle(Request $request, \Closure $next)
{
if ($this->shouldLogOperation($request)) {
$log = [
'user_id' => Admin::user()->id,
'path' => substr($request->path(), 0, 255),
'method' => $request->method(),
'ip' => $request->getClientIp(),
'input' => json_encode($request->input()),
];
try {
OperationLogModel::create($log);
} catch (\Exception $exception) {
// pass
}
}
return $next($request);
}
/**
* @param Request $request
*
* @return bool
*/
protected function shouldLogOperation(Request $request)
{
return config('admin.operation_log.enable')
&& !$this->inExceptArray($request)
&& $this->inAllowedMethods($request->method())
&& Admin::user();
}
/**
* Whether requests using this method are allowed to be logged.
*
* @param string $method
*
* @return bool
*/
protected function inAllowedMethods($method)
{
$allowedMethods = collect(config('admin.operation_log.allowed_methods'))->filter();
if ($allowedMethods->isEmpty()) {
return true;
}
return $allowedMethods->map(function ($method) {
return strtoupper($method);
})->contains($method);
}
/**
* Determine if the request has a URI that should pass through CSRF verification.
*
* @param \Illuminate\Http\Request $request
*
* @return bool
*/
protected function inExceptArray($request)
{
foreach (config('admin.operation_log.except') as $except) {
if ($except !== '/') {
$except = trim($except, '/');
}
$methods = [];
if (Str::contains($except, ':')) {
list($methods, $except) = explode(':', $except);
$methods = explode(',', $methods);
}
$methods = array_map('strtoupper', $methods);
if ($request->is($except) &&
(empty($methods) || in_array($request->method(), $methods))) {
return true;
}
}
return false;
}
}
| php | MIT | 67c441eb78ecc5437e59775d89770cd9c2cb1e05 | 2026-01-04T15:05:15.717211Z | false |
z-song/laravel-admin | https://github.com/z-song/laravel-admin/blob/67c441eb78ecc5437e59775d89770cd9c2cb1e05/src/Middleware/Session.php | src/Middleware/Session.php | <?php
namespace Encore\Admin\Middleware;
use Illuminate\Http\Request;
class Session
{
public function handle(Request $request, \Closure $next)
{
$path = '/'.trim(config('admin.route.prefix'), '/');
config(['session.path' => $path]);
if ($domain = config('admin.route.domain')) {
config(['session.domain' => $domain]);
}
return $next($request);
}
}
| php | MIT | 67c441eb78ecc5437e59775d89770cd9c2cb1e05 | 2026-01-04T15:05:15.717211Z | false |
z-song/laravel-admin | https://github.com/z-song/laravel-admin/blob/67c441eb78ecc5437e59775d89770cd9c2cb1e05/src/Show/Field.php | src/Show/Field.php | <?php
namespace Encore\Admin\Show;
use Encore\Admin\Show;
use Encore\Admin\Widgets\Carousel;
use Illuminate\Contracts\Support\Arrayable;
use Illuminate\Contracts\Support\Renderable;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Arr;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Str;
use Illuminate\Support\Traits\Macroable;
class Field implements Renderable
{
use Macroable {
__call as macroCall;
}
/**
* @var string
*/
protected $view = 'admin::show.field';
/**
* Name of column.
*
* @var string
*/
protected $name;
/**
* Label of column.
*
* @var string
*/
protected $label;
/**
* Width for label and field.
*
* @var array
*/
protected $width = [
'label' => 2,
'field' => 8,
];
/**
* Escape field value or not.
*
* @var bool
*/
protected $escape = true;
/**
* Field value.
*
* @var mixed
*/
protected $value;
/**
* @var Collection
*/
protected $showAs = [];
/**
* Parent show instance.
*
* @var Show
*/
protected $parent;
/**
* Relation name.
*
* @var string
*/
protected $relation;
/**
* If show contents in box.
*
* @var bool
*/
public $border = true;
/**
* @var array
*/
protected $fileTypes = [
'image' => 'png|jpg|jpeg|tmp|gif',
'word' => 'doc|docx',
'excel' => 'xls|xlsx|csv',
'powerpoint' => 'ppt|pptx',
'pdf' => 'pdf',
'code' => 'php|js|java|python|ruby|go|c|cpp|sql|m|h|json|html|aspx',
'archive' => 'zip|tar\.gz|rar|rpm',
'txt' => 'txt|pac|log|md',
'audio' => 'mp3|wav|flac|3pg|aa|aac|ape|au|m4a|mpc|ogg',
'video' => 'mkv|rmvb|flv|mp4|avi|wmv|rm|asf|mpeg',
];
/**
* Field constructor.
*
* @param string $name
* @param string $label
*/
public function __construct($name = '', $label = '')
{
$this->name = $name;
$this->label = $this->formatLabel($label);
$this->showAs = new Collection();
}
/**
* Set parent show instance.
*
* @param Show $show
*
* @return $this
*/
public function setParent(Show $show)
{
$this->parent = $show;
return $this;
}
/**
* Get name of this column.
*
* @return mixed
*/
public function getName()
{
return $this->name;
}
/**
* Format label.
*
* @param $label
*
* @return mixed
*/
protected function formatLabel($label)
{
$label = $label ?: ucfirst($this->name);
return str_replace(['.', '_'], ' ', $label);
}
/**
* Get label of the column.
*
* @return mixed
*/
public function getLabel()
{
return $this->label;
}
/**
* Field display callback.
*
* @param callable $callable
*
* @return $this
*/
public function as(callable $callable)
{
$this->showAs->push($callable);
return $this;
}
/**
* Display field using array value map.
*
* @param array $values
* @param null $default
*
* @return $this
*/
public function using(array $values, $default = null)
{
return $this->as(function ($value) use ($values, $default) {
if (is_null($value)) {
return $default;
}
return Arr::get($values, $value, $default);
});
}
/**
* Show field as a image.
*
* @param string $server
* @param int $width
* @param int $height
*
* @return $this
*/
public function image($server = '', $width = 200, $height = 200)
{
return $this->unescape()->as(function ($images) use ($server, $width, $height) {
return collect($images)->map(function ($path) use ($server, $width, $height) {
if (empty($path)) {
return '';
}
if (url()->isValidUrl($path)) {
$src = $path;
} elseif ($server) {
$src = $server.$path;
} else {
$disk = config('admin.upload.disk');
if (config("filesystems.disks.{$disk}")) {
$src = Storage::disk($disk)->url($path);
} else {
return '';
}
}
return "<img src='$src' style='max-width:{$width}px;max-height:{$height}px' class='img' />";
})->implode(' ');
});
}
/**
* Show field as a carousel.
*
* @param int $width
* @param int $height
* @param string $server
*
* @return Field
*/
public function carousel($width = 300, $height = 200, $server = '')
{
return $this->unescape()->as(function ($images) use ($server, $width, $height) {
$items = collect($images)->map(function ($path) use ($server, $width, $height) {
if (empty($path)) {
return '';
}
if (url()->isValidUrl($path)) {
$image = $path;
} elseif ($server) {
$image = $server.$path;
} else {
$disk = config('admin.upload.disk');
if (config("filesystems.disks.{$disk}")) {
$image = Storage::disk($disk)->url($path);
} else {
$image = '';
}
}
$caption = '';
return compact('image', 'caption');
});
return (new Carousel($items))->width($width)->height($height);
});
}
/**
* Show field as a file.
*
* @param string $server
* @param bool $download
*
* @return Field
*/
public function file($server = '', $download = true)
{
$field = $this;
return $this->unescape()->as(function ($path) use ($server, $download, $field) {
$name = basename($path);
$field->border = false;
$size = $url = '';
if (url()->isValidUrl($path)) {
$url = $path;
} elseif ($server) {
$url = $server.$path;
} else {
$storage = Storage::disk(config('admin.upload.disk'));
if ($storage->exists($path)) {
$url = $storage->url($path);
$size = ($storage->size($path) / 1000).'KB';
}
}
if (!$url) {
return '';
}
$download = $download ? "download='$name'" : '';
return <<<HTML
<ul class="mailbox-attachments clearfix">
<li style="margin-bottom: 0;">
<span class="mailbox-attachment-icon"><i class="fa {$field->getFileIcon($name)}"></i></span>
<div class="mailbox-attachment-info">
<div class="mailbox-attachment-name">
<i class="fa fa-paperclip"></i> {$name}
</div>
<span class="mailbox-attachment-size">
{$size}
<a href="{$url}" class="btn btn-default btn-xs pull-right" target="_blank" $download><i class="fa fa-cloud-download"></i></a>
</span>
</div>
</li>
</ul>
HTML;
});
}
/**
* Show field as a link.
*
* @param string $href
* @param string $target
*
* @return Field
*/
public function link($href = '', $target = '_blank')
{
return $this->unescape()->as(function ($link) use ($href, $target) {
$href = $href ?: $link;
return "<a href='$href' target='{$target}'>{$link}</a>";
});
}
/**
* Show field as labels.
*
* @param string $style
*
* @return Field
*/
public function label($style = 'success')
{
return $this->unescape()->as(function ($value) use ($style) {
if ($value instanceof Arrayable) {
$value = $value->toArray();
}
return collect((array) $value)->map(function ($name) use ($style) {
return "<span class='label label-{$style}'>$name</span>";
})->implode(' ');
});
}
/**
* Show field as badges.
*
* @param string $style
*
* @return Field
*/
public function badge($style = 'blue')
{
return $this->unescape()->as(function ($value) use ($style) {
if ($value instanceof Arrayable) {
$value = $value->toArray();
}
return collect((array) $value)->map(function ($name) use ($style) {
return "<span class='badge bg-{$style}'>$name</span>";
})->implode(' ');
});
}
/**
* Show field as number.
*
* @param int $decimals
* @param string $decimal_seperator
* @param string $thousands_seperator
*
* @return Field
*/
public function number($decimals = 0, $decimal_seperator = '.', $thousands_seperator = ',')
{
return $this->unescape()->as(function ($value) use ($decimals, $decimal_seperator, $thousands_seperator) {
return number_format($value, $decimals, $decimal_seperator, $thousands_seperator);
});
}
/**
* Show field as json code.
*
* @return Field
*/
public function json()
{
$field = $this;
return $this->unescape()->as(function ($value) use ($field) {
if (is_string($value)) {
$content = json_decode($value, true);
} else {
$content = $value;
}
if (json_last_error() == 0) {
$field->border = false;
return '<pre><code>'.json_encode($content, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE).'</code></pre>';
}
return $value;
});
}
/**
* Show readable filesize for giving integer size.
*
* @return Field
*/
public function filesize()
{
return $this->as(function ($value) {
return file_size($value);
});
}
/**
* Get file icon.
*
* @param string $file
*
* @return string
*/
public function getFileIcon($file = '')
{
$extension = File::extension($file);
foreach ($this->fileTypes as $type => $regex) {
if (preg_match("/^($regex)$/i", $extension) !== 0) {
return "fa-file-{$type}-o";
}
}
return 'fa-file-o';
}
/**
* Set escape or not for this field.
*
* @param bool $escape
*
* @return $this
*/
public function setEscape($escape = true)
{
$this->escape = $escape;
return $this;
}
/**
* Unescape for this field.
*
* @return Field
*/
public function unescape()
{
return $this->setEscape(false);
}
/**
* Set value for this field.
*
* @param Model $model
*
* @return $this
*/
public function setValue(Model $model)
{
if ($this->relation) {
if (!$relationValue = $model->{$this->relation}) {
return $this;
}
$this->value = $relationValue;
} else {
if (Str::contains($this->name, '.')) {
$this->value = $this->getRelationValue($model, $this->name);
} else {
$this->value = $model->getAttribute($this->name);
}
}
return $this;
}
/**
* Set relation name for this field.
*
* @param string $relation
*
* @return $this
*/
public function setRelation($relation)
{
$this->relation = $relation;
return $this;
}
/**
* @param Model $model
* @param string $name
*
* @return mixed
*/
protected function getRelationValue($model, $name)
{
list($relation, $key) = explode('.', $name);
if ($related = $model->getRelationValue($relation)) {
return $related->getAttribute($key);
}
}
/**
* Set width for field and label.
*
* @param int $field
* @param int $label
*
* @return $this
*/
public function setWidth($field = 8, $label = 2)
{
$this->width = [
'label' => $label,
'field' => $field,
];
return $this;
}
/**
* Call extended field.
*
* @param string|AbstractField|\Closure $abstract
* @param array $arguments
*
* @return Field
*/
protected function callExtendedField($abstract, $arguments = [])
{
if ($abstract instanceof \Closure) {
return $this->as($abstract);
}
if (is_string($abstract) && class_exists($abstract)) {
/** @var AbstractField $extend */
$extend = new $abstract();
}
if ($abstract instanceof AbstractField) {
/** @var AbstractField $extend */
$extend = $abstract;
}
if (!isset($extend)) {
admin_warning("[$abstract] is not a valid Show field.");
return $this;
}
if (!$extend->escape) {
$this->unescape();
}
$field = $this;
return $this->as(function ($value) use ($extend, $field, $arguments) {
if (!$extend->border) {
$field->border = false;
}
$extend->setValue($value)->setModel($this);
return $extend->render(...$arguments);
});
}
/**
* @param string $method
* @param array $arguments
*
* @return $this
*/
public function __call($method, $arguments = [])
{
if ($class = Arr::get(Show::$extendedFields, $method)) {
return $this->callExtendedField($class, $arguments);
}
if (static::hasMacro($method)) {
return $this->macroCall($method, $arguments);
}
if ($this->relation) {
$this->name = $method;
$this->label = $this->formatLabel(Arr::get($arguments, 0));
}
return $this;
}
/**
* Get all variables passed to field view.
*
* @return array
*/
protected function variables()
{
return [
'content' => $this->value,
'escape' => $this->escape,
'label' => $this->getLabel(),
'wrapped' => $this->border,
'width' => $this->width,
];
}
/**
* Render this field.
*
* @return string
*/
public function render()
{
if ($this->showAs->isNotEmpty()) {
$this->showAs->each(function ($callable) {
$this->value = $callable->call(
$this->parent->getModel(),
$this->value
);
});
}
return view($this->view, $this->variables());
}
}
| php | MIT | 67c441eb78ecc5437e59775d89770cd9c2cb1e05 | 2026-01-04T15:05:15.717211Z | false |
z-song/laravel-admin | https://github.com/z-song/laravel-admin/blob/67c441eb78ecc5437e59775d89770cd9c2cb1e05/src/Show/Divider.php | src/Show/Divider.php | <?php
namespace Encore\Admin\Show;
class Divider extends Field
{
public function render()
{
return '<hr>';
}
}
| php | MIT | 67c441eb78ecc5437e59775d89770cd9c2cb1e05 | 2026-01-04T15:05:15.717211Z | false |
z-song/laravel-admin | https://github.com/z-song/laravel-admin/blob/67c441eb78ecc5437e59775d89770cd9c2cb1e05/src/Show/Relation.php | src/Show/Relation.php | <?php
namespace Encore\Admin\Show;
use Encore\Admin\Grid;
use Encore\Admin\Show;
use Illuminate\Contracts\Support\Renderable;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\HasManyThrough;
use Illuminate\Database\Eloquent\Relations\HasOne;
use Illuminate\Database\Eloquent\Relations\MorphMany;
use Illuminate\Database\Eloquent\Relations\MorphOne;
class Relation extends Field
{
/**
* Relation name.
*
* @var string
*/
protected $name;
/**
* Relation panel builder.
*
* @var callable
*/
protected $builder;
/**
* Relation panel title.
*
* @var string
*/
protected $title;
/**
* Parent model.
*
* @var Model
*/
protected $model;
/**
* Relation constructor.
*
* @param string $name
* @param callable $builder
* @param string $title
*/
public function __construct($name, $builder, $title = '')
{
$this->name = $name;
$this->builder = $builder;
$this->title = $this->formatLabel($title);
}
/**
* Set parent model for relation.
*
* @param Model $model
*
* @return $this
*/
public function setModel(Model $model)
{
$this->model = $model;
return $this;
}
/**
* Get null renderable instance.
*
* @return Renderable|__anonymous@1539
*/
protected function getNullRenderable()
{
return new class() implements Renderable {
public function render()
{
}
};
}
/**
* Render this relation panel.
*
* @return string
*/
public function render()
{
$relation = $this->model->{$this->name}();
$renderable = $this->getNullRenderable();
if ($relation instanceof HasOne
|| $relation instanceof BelongsTo
|| $relation instanceof MorphOne
) {
$model = $this->model->{$this->name};
if (!$model instanceof Model) {
$model = $relation->getRelated();
}
$renderable = new Show($model, $this->builder);
$renderable->panel()->title($this->title);
}
if ($relation instanceof HasMany
|| $relation instanceof MorphMany
|| $relation instanceof BelongsToMany
|| $relation instanceof HasManyThrough
) {
$renderable = new Grid($relation->getRelated(), $this->builder);
$renderable->setName($this->name)
->setTitle($this->title)
->setRelation($relation);
}
return $renderable->render();
}
}
| php | MIT | 67c441eb78ecc5437e59775d89770cd9c2cb1e05 | 2026-01-04T15:05:15.717211Z | false |
z-song/laravel-admin | https://github.com/z-song/laravel-admin/blob/67c441eb78ecc5437e59775d89770cd9c2cb1e05/src/Show/AbstractField.php | src/Show/AbstractField.php | <?php
namespace Encore\Admin\Show;
use Illuminate\Contracts\Support\Renderable;
use Illuminate\Database\Eloquent\Model;
abstract class AbstractField implements Renderable
{
/**
* Field value.
*
* @var mixed
*/
protected $value;
/**
* Current field model.
*
* @var Model
*/
protected $model;
/**
* If this field show with a border.
*
* @var bool
*/
public $border = true;
/**
* If this field show escaped contents.
*
* @var bool
*/
public $escape = true;
/**
* @param mixed $value
*
* @return AbstractField $this
*/
public function setValue($value)
{
$this->value = $value;
return $this;
}
/**
* @param Model $model
*
* @return AbstractField $this
*/
public function setModel($model)
{
$this->model = $model;
return $this;
}
/**
* @return mixed
*/
abstract public function render();
}
| php | MIT | 67c441eb78ecc5437e59775d89770cd9c2cb1e05 | 2026-01-04T15:05:15.717211Z | false |
z-song/laravel-admin | https://github.com/z-song/laravel-admin/blob/67c441eb78ecc5437e59775d89770cd9c2cb1e05/src/Show/Panel.php | src/Show/Panel.php | <?php
namespace Encore\Admin\Show;
use Encore\Admin\Show;
use Illuminate\Contracts\Support\Renderable;
use Illuminate\Support\Collection;
class Panel implements Renderable
{
/**
* The view to be rendered.
*
* @var string
*/
protected $view = 'admin::show.panel';
/**
* The fields that this panel holds.
*
* @var Collection
*/
protected $fields;
/**
* Variables in the view.
*
* @var array
*/
protected $data;
/**
* Parent show instance.
*
* @var Show
*/
protected $parent;
/**
* Panel constructor.
*/
public function __construct(Show $show)
{
$this->parent = $show;
$this->initData();
}
/**
* Initialize view data.
*/
protected function initData()
{
$this->data = [
'fields' => new Collection(),
'tools' => new Tools($this),
'style' => 'info',
'title' => trans('admin.detail'),
];
}
/**
* Set parent container.
*
* @param Show $show
*
* @return $this
*/
public function setParent(Show $show)
{
$this->parent = $show;
return $this;
}
/**
* Get parent container.
*
* @return Show
*/
public function getParent()
{
return $this->parent;
}
/**
* Set style for this panel.
*
* @param string $style
*
* @return $this
*/
public function style($style = 'info')
{
$this->data['style'] = $style;
return $this;
}
/**
* Set title for this panel.
*
* @param string $title
*
* @return $this
*/
public function title($title)
{
$this->data['title'] = $title;
return $this;
}
/**
* Set view for this panel to render.
*
* @param string $view
*
* @return $this
*/
public function view($view)
{
$this->view = $view;
return $this;
}
/**
* Build panel tools.
*
* @param $callable
*/
public function tools($callable)
{
call_user_func($callable, $this->data['tools']);
}
/**
* Fill fields to panel.
*
* @param []Field $fields
*
* @return $this
*/
public function fill($fields)
{
$this->data['fields'] = $fields;
return $this;
}
/**
* Render this panel.
*
* @return string
*/
public function render()
{
return view($this->view, $this->data)->render();
}
}
| php | MIT | 67c441eb78ecc5437e59775d89770cd9c2cb1e05 | 2026-01-04T15:05:15.717211Z | false |
z-song/laravel-admin | https://github.com/z-song/laravel-admin/blob/67c441eb78ecc5437e59775d89770cd9c2cb1e05/src/Show/Tools.php | src/Show/Tools.php | <?php
namespace Encore\Admin\Show;
use Encore\Admin\Admin;
use Illuminate\Contracts\Support\Htmlable;
use Illuminate\Contracts\Support\Renderable;
use Illuminate\Support\Collection;
class Tools implements Renderable
{
/**
* The panel that holds this tool.
*
* @var Panel
*/
protected $panel;
/**
* @var string
*/
protected $resource;
/**
* Default tools.
*
* @var array
*/
protected $tools = ['delete', 'edit', 'list'];
/**
* Tools should be appends to default tools.
*
* @var Collection
*/
protected $appends;
/**
* Tools should be prepends to default tools.
*
* @var Collection
*/
protected $prepends;
/**
* Tools constructor.
*
* @param Panel $panel
*/
public function __construct(Panel $panel)
{
$this->panel = $panel;
$this->appends = new Collection();
$this->prepends = new Collection();
}
/**
* Append a tools.
*
* @param mixed $tool
*
* @return $this
*/
public function append($tool)
{
$this->appends->push($tool);
return $this;
}
/**
* Prepend a tool.
*
* @param mixed $tool
*
* @return $this
*/
public function prepend($tool)
{
$this->prepends->push($tool);
return $this;
}
/**
* Get resource path.
*
* @return string
*/
public function getResource()
{
if (is_null($this->resource)) {
$this->resource = $this->panel->getParent()->getResourcePath();
}
return $this->resource;
}
/**
* Disable `list` tool.
*
* @return $this
*/
public function disableList(bool $disable = true)
{
if ($disable) {
array_delete($this->tools, 'list');
} elseif (!in_array('list', $this->tools)) {
array_push($this->tools, 'list');
}
return $this;
}
/**
* Disable `delete` tool.
*
* @return $this
*/
public function disableDelete(bool $disable = true)
{
if ($disable) {
array_delete($this->tools, 'delete');
} elseif (!in_array('delete', $this->tools)) {
array_push($this->tools, 'delete');
}
return $this;
}
/**
* Disable `edit` tool.
*
* @return $this
*/
public function disableEdit(bool $disable = true)
{
if ($disable) {
array_delete($this->tools, 'edit');
} elseif (!in_array('edit', $this->tools)) {
array_push($this->tools, 'edit');
}
return $this;
}
/**
* Get request path for resource list.
*
* @return string
*/
protected function getListPath()
{
return ltrim($this->getResource(), '/');
}
/**
* Get request path for edit.
*
* @return string
*/
protected function getEditPath()
{
$key = $this->panel->getParent()->getModel()->getKey();
return $this->getListPath().'/'.$key.'/edit';
}
/**
* Get request path for delete.
*
* @return string
*/
protected function getDeletePath()
{
$key = $this->panel->getParent()->getModel()->getKey();
return $this->getListPath().'/'.$key;
}
/**
* Render `list` tool.
*
* @return string
*/
protected function renderList()
{
$list = trans('admin.list');
return <<<HTML
<div class="btn-group pull-right" style="margin-right: 5px">
<a href="{$this->getListPath()}" class="btn btn-sm btn-default" title="{$list}">
<i class="fa fa-list"></i><span class="hidden-xs"> {$list}</span>
</a>
</div>
HTML;
}
/**
* Render `edit` tool.
*
* @return string
*/
protected function renderEdit()
{
$edit = trans('admin.edit');
return <<<HTML
<div class="btn-group pull-right" style="margin-right: 5px">
<a href="{$this->getEditPath()}" class="btn btn-sm btn-primary" title="{$edit}">
<i class="fa fa-edit"></i><span class="hidden-xs"> {$edit}</span>
</a>
</div>
HTML;
}
/**
* Render `delete` tool.
*
* @return string
*/
protected function renderDelete()
{
$trans = [
'delete_confirm' => trans('admin.delete_confirm'),
'confirm' => trans('admin.confirm'),
'cancel' => trans('admin.cancel'),
'delete' => trans('admin.delete'),
];
$class = uniqid();
$script = <<<SCRIPT
$('.{$class}-delete').unbind('click').click(function() {
swal({
title: "{$trans['delete_confirm']}",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "{$trans['confirm']}",
showLoaderOnConfirm: true,
cancelButtonText: "{$trans['cancel']}",
preConfirm: function() {
return new Promise(function(resolve) {
$.ajax({
method: 'post',
url: '{$this->getDeletePath()}',
data: {
_method:'delete',
_token:LA.token,
},
success: function (data) {
$.pjax({container:'#pjax-container', url: '{$this->getListPath()}' });
resolve(data);
}
});
});
}
}).then(function(result) {
var data = result.value;
if (typeof data === 'object') {
if (data.status) {
swal(data.message, '', 'success');
} else {
swal(data.message, '', 'error');
}
}
});
});
SCRIPT;
Admin::script($script);
return <<<HTML
<div class="btn-group pull-right" style="margin-right: 5px">
<a href="javascript:void(0);" class="btn btn-sm btn-danger {$class}-delete" title="{$trans['delete']}">
<i class="fa fa-trash"></i><span class="hidden-xs"> {$trans['delete']}</span>
</a>
</div>
HTML;
}
/**
* Render custom tools.
*
* @param Collection $tools
*
* @return mixed
*/
protected function renderCustomTools($tools)
{
return $tools->map(function ($tool) {
if ($tool instanceof Renderable) {
return $tool->render();
}
if ($tool instanceof Htmlable) {
return $tool->toHtml();
}
return (string) $tool;
})->implode(' ');
}
/**
* Render tools.
*
* @return string
*/
public function render()
{
$output = $this->renderCustomTools($this->prepends);
foreach ($this->tools as $tool) {
$renderMethod = 'render'.ucfirst($tool);
$output .= $this->$renderMethod();
}
return $output.$this->renderCustomTools($this->appends);
}
}
| php | MIT | 67c441eb78ecc5437e59775d89770cd9c2cb1e05 | 2026-01-04T15:05:15.717211Z | false |
z-song/laravel-admin | https://github.com/z-song/laravel-admin/blob/67c441eb78ecc5437e59775d89770cd9c2cb1e05/src/Widgets/Navbar.php | src/Widgets/Navbar.php | <?php
namespace Encore\Admin\Widgets;
use Encore\Admin\Widgets\Navbar\RefreshButton;
use Illuminate\Contracts\Support\Htmlable;
use Illuminate\Contracts\Support\Renderable;
class Navbar implements Renderable
{
/**
* @var array
*/
protected $elements = [];
/**
* Navbar constructor.
*/
public function __construct()
{
$this->elements = [
'left' => collect(),
'right' => collect(),
];
}
/**
* @param $element
*
* @return $this
*/
public function left($element)
{
$this->elements['left']->push($element);
return $this;
}
/**
* @param $element
*
* @return $this
*/
public function right($element)
{
$this->elements['right']->push($element);
return $this;
}
/**
* @param $element
*
* @return Navbar
*
* @deprecated
*/
public function add($element)
{
return $this->right($element);
}
/**
* @param string $part
*
* @return mixed
*/
public function render($part = 'right')
{
if ($part == 'right') {
$this->right(new RefreshButton());
}
if (!isset($this->elements[$part]) || $this->elements[$part]->isEmpty()) {
return '';
}
return $this->elements[$part]->map(function ($element) {
if ($element instanceof Htmlable) {
return $element->toHtml();
}
if ($element instanceof Renderable) {
return $element->render();
}
return (string) $element;
})->implode('');
}
}
| php | MIT | 67c441eb78ecc5437e59775d89770cd9c2cb1e05 | 2026-01-04T15:05:15.717211Z | false |
z-song/laravel-admin | https://github.com/z-song/laravel-admin/blob/67c441eb78ecc5437e59775d89770cd9c2cb1e05/src/Widgets/StepForm.php | src/Widgets/StepForm.php | <?php
namespace Encore\Admin\Widgets;
class StepForm extends Form
{
/**
* @var int|string
*/
protected $current;
/**
* @var array
*/
protected $steps = [];
/**
* @var string
*/
protected $url;
/**
* @var array
*/
protected $buttons = [];
/**
* @param array $data
*
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
*/
protected function next($data = [])
{
$this->remember($data);
return $this->redirectToNextStep();
}
protected function prev()
{
return back()->withInput();
}
/**
* @param array $data
*/
protected function remember($data)
{
session()->put("steps.{$this->current}", $data);
}
/**
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
*/
protected function redirectToNextStep()
{
$index = array_search($this->current, $this->steps);
$step = $this->steps[$index + 1];
$nextUrl = $this->url.'?'.http_build_query(compact('step'));
return redirect($nextUrl);
}
/**
* Get all data from steps.
*
* @return array
*/
protected function all()
{
$prev = session()->get('steps', []);
return array_merge($prev, [$this->current => request()->all()]);
}
/**
* Clear all data from steps.
*/
protected function clear()
{
session()->remove('steps');
}
/**
* @param array $steps
*
* @return $this
*/
public function setSteps($steps)
{
$this->steps = $steps;
return $this;
}
/**
* @param string|int $current
*
* @return $this
*/
public function setCurrent($current)
{
$this->current = $current;
return $this;
}
/**
* @param string $url
*
* @return $this
*/
public function setUrl($url)
{
$this->url = $url;
return $this;
}
protected function prepareForm()
{
parent::prepareForm();
$url = request()->url();
$this->hidden('_url')->default($url);
$this->hidden('_current')->default($this->current);
$this->hidden('_steps')->default(implode(',', $this->steps));
$this->divider();
$this->addFooter();
}
protected function addFooter()
{
$footer = '';
$index = array_search($this->current, $this->steps);
$trans = [
'prev' => __('admin.prev'),
'next' => __('admin.next'),
'submit' => __('admin.submit'),
];
if ($index !== 0) {
$step = $this->steps[$index - 1];
$prevUrl = request()->fullUrlWithQuery(compact('step'));
$footer .= "<a href=\"{$prevUrl}\" class=\"btn btn-warning pull-left\">{$trans['prev']}</a>";
}
if ($index !== count($this->steps) - 1) {
$footer .= "<button class=\"btn btn-info pull-right\">{$trans['next']}</button>";
}
if ($index === count($this->steps) - 1) {
$footer .= "<button class=\"btn btn-info pull-right\">{$trans['submit']}</button>";
}
$this->html($footer);
}
/**
* @return $this
*/
public function sanitize()
{
$this->setUrl(request('_url'))
->setCurrent(request('_current'))
->setSteps(explode(',', request('_steps')));
foreach (['_form_', '_token', '_url', '_current', '_steps'] as $key) {
request()->request->remove($key);
}
return $this;
}
/**
* @return mixed
*/
public function data()
{
return session()->get('steps.'.$this->current, []);
}
}
| php | MIT | 67c441eb78ecc5437e59775d89770cd9c2cb1e05 | 2026-01-04T15:05:15.717211Z | false |
z-song/laravel-admin | https://github.com/z-song/laravel-admin/blob/67c441eb78ecc5437e59775d89770cd9c2cb1e05/src/Widgets/Table.php | src/Widgets/Table.php | <?php
namespace Encore\Admin\Widgets;
use Illuminate\Contracts\Support\Renderable;
use Illuminate\Support\Arr;
class Table extends Widget implements Renderable
{
/**
* @var string
*/
protected $view = 'admin::widgets.table';
/**
* @var array
*/
protected $headers = [];
/**
* @var array
*/
protected $rows = [];
/**
* @var array
*/
protected $style = [];
/**
* Table constructor.
*
* @param array $headers
* @param array $rows
* @param array $style
*/
public function __construct($headers = [], $rows = [], $style = [])
{
$this->setHeaders($headers);
$this->setRows($rows);
$this->setStyle($style);
$this->class('table '.implode(' ', $this->style));
}
/**
* Set table headers.
*
* @param array $headers
*
* @return $this
*/
public function setHeaders($headers = [])
{
$this->headers = $headers;
return $this;
}
/**
* Set table rows.
*
* @param array $rows
*
* @return $this
*/
public function setRows($rows = [])
{
if (Arr::isAssoc($rows)) {
foreach ($rows as $key => $item) {
$this->rows[] = [$key, $item];
}
return $this;
}
$this->rows = $rows;
return $this;
}
/**
* Set table style.
*
* @param array $style
*
* @return $this
*/
public function setStyle($style = [])
{
$this->style = $style;
return $this;
}
/**
* Render the table.
*
* @return string
*/
public function render()
{
$vars = [
'headers' => $this->headers,
'rows' => $this->rows,
'style' => $this->style,
'attributes' => $this->formatAttributes(),
];
return view($this->view, $vars)->render();
}
}
| php | MIT | 67c441eb78ecc5437e59775d89770cd9c2cb1e05 | 2026-01-04T15:05:15.717211Z | false |
z-song/laravel-admin | https://github.com/z-song/laravel-admin/blob/67c441eb78ecc5437e59775d89770cd9c2cb1e05/src/Widgets/Box.php | src/Widgets/Box.php | <?php
namespace Encore\Admin\Widgets;
use Illuminate\Contracts\Support\Renderable;
class Box extends Widget implements Renderable
{
/**
* @var string
*/
protected $view = 'admin::widgets.box';
/**
* @var string
*/
protected $title = '';
/**
* @var string
*/
protected $content = 'here is the box content.';
/**
* @var string
*/
protected $footer = '';
/**
* @var array
*/
protected $tools = [];
/**
* @var string
*/
protected $script;
/**
* Box constructor.
*
* @param string $title
* @param string $content
*/
public function __construct($title = '', $content = '', $footer = '')
{
if ($title) {
$this->title($title);
}
if ($content) {
$this->content($content);
}
if ($footer) {
$this->footer($footer);
}
$this->class('box');
}
/**
* Set box content.
*
* @param string|Renderable $content
*
* @return $this
*/
public function content($content)
{
if ($content instanceof Renderable) {
$this->content = $content->render();
} else {
$this->content = (string) $content;
}
return $this;
}
/**
* Set box footer.
*
* @param string|Renderable $footer
*
* @return $this
*/
public function footer($footer)
{
if ($footer instanceof Renderable) {
$this->footer = $footer->render();
} else {
$this->footer = (string) $footer;
}
return $this;
}
/**
* Set box title.
*
* @param string $title
*
* @return $this
*/
public function title($title)
{
$this->title = $title;
return $this;
}
/**
* Set box as collapsable.
*
* @return $this
*/
public function collapsable()
{
$this->tools[] =
'<button class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i></button>';
return $this;
}
/**
* Set box body scrollable.
*
* @param array $options
*
* @return $this
*/
public function scrollable($options = [], $nodeSelector = '')
{
$this->id = uniqid('box-slim-scroll-');
$scrollOptions = json_encode($options);
$nodeSelector = $nodeSelector ?: '.box-body';
$this->script = <<<SCRIPT
$("#{$this->id} {$nodeSelector}").slimScroll({$scrollOptions});
SCRIPT;
return $this;
}
/**
* Set box as removable.
*
* @return $this
*/
public function removable()
{
$this->tools[] =
'<button class="btn btn-box-tool" data-widget="remove"><i class="fa fa-times"></i></button>';
return $this;
}
/**
* Set box style.
*
* @param string $styles
*
* @return $this|Box
*/
public function style($styles)
{
if (is_string($styles)) {
return $this->style([$styles]);
}
$styles = array_map(function ($style) {
return 'box-'.$style;
}, $styles);
$this->class = $this->class.' '.implode(' ', $styles);
return $this;
}
/**
* Add `box-solid` class to box.
*
* @return $this
*/
public function solid()
{
return $this->style('solid');
}
/**
* Variables in view.
*
* @return array
*/
protected function variables()
{
return [
'title' => $this->title,
'content' => $this->content,
'footer' => $this->footer,
'tools' => $this->tools,
'attributes' => $this->formatAttributes(),
'script' => $this->script,
];
}
/**
* Render box.
*
* @return string
*/
public function render()
{
return view($this->view, $this->variables())->render();
}
}
| php | MIT | 67c441eb78ecc5437e59775d89770cd9c2cb1e05 | 2026-01-04T15:05:15.717211Z | false |
z-song/laravel-admin | https://github.com/z-song/laravel-admin/blob/67c441eb78ecc5437e59775d89770cd9c2cb1e05/src/Widgets/MultipleSteps.php | src/Widgets/MultipleSteps.php | <?php
namespace Encore\Admin\Widgets;
use Illuminate\Contracts\Support\Renderable;
class MultipleSteps implements Renderable
{
/**
* @var int|string
*/
protected $current;
/**
* @var array
*/
protected $steps = [];
/**
* @var string
*/
protected $stepName = 'step';
/**
* MultipleSteps constructor.
*
* @param array $steps
* @param null $current
*/
public function __construct($steps = [], $current = null)
{
$this->steps = $steps;
$this->current = $this->resolveCurrentStep($steps, $current);
}
/**
* @param array $steps
* @param null $current
*
* @return static
*/
public static function make($steps, $current = null): self
{
return new static($steps, $current);
}
/**
* @param array $steps
* @param string|int $current
*
* @return string|int
*/
protected function resolveCurrentStep($steps, $current)
{
$current = $current ?: request($this->stepName, 0);
if (!isset($steps[$current])) {
$current = key($steps);
}
return $current;
}
/**
* @return string|null
*/
public function render()
{
$class = $this->steps[$this->current];
if (!is_subclass_of($class, StepForm::class)) {
admin_error("Class [{$class}] must be a sub-class of [Encore\Admin\Widgets\StepForm].");
return;
}
/** @var StepForm $step */
$step = new $class();
return $step
->setSteps(array_keys($this->steps))
->setCurrent($this->current)
->render();
}
}
| php | MIT | 67c441eb78ecc5437e59775d89770cd9c2cb1e05 | 2026-01-04T15:05:15.717211Z | false |
z-song/laravel-admin | https://github.com/z-song/laravel-admin/blob/67c441eb78ecc5437e59775d89770cd9c2cb1e05/src/Widgets/Callout.php | src/Widgets/Callout.php | <?php
namespace Encore\Admin\Widgets;
use Illuminate\Contracts\Support\Renderable;
class Callout extends Widget implements Renderable
{
/**
* @var string
*/
protected $view = 'admin::widgets.callout';
/**
* @var string
*/
protected $title = '';
/**
* @var string
*/
protected $content = '';
/**
* @var string
*/
protected $style = 'danger';
/**
* Callout constructor.
*
* @param string $content
* @param string $title
* @param string $style
*/
public function __construct($content, $title = '', $style = 'danger')
{
$this->content = (string) $content;
$this->title = $title;
$this->style($style);
}
/**
* Add style to Callout.
*
* @param string $style
*
* @return $this
*/
public function style($style = 'info')
{
$this->style = $style;
return $this;
}
/**
* @return array
*/
protected function variables()
{
$this->class("callout callout-{$this->style}");
return [
'title' => $this->title,
'content' => $this->content,
'attributes' => $this->formatAttributes(),
];
}
/**
* Render Callout.
*
* @return string
*/
public function render()
{
return view($this->view, $this->variables())->render();
}
}
| php | MIT | 67c441eb78ecc5437e59775d89770cd9c2cb1e05 | 2026-01-04T15:05:15.717211Z | false |
z-song/laravel-admin | https://github.com/z-song/laravel-admin/blob/67c441eb78ecc5437e59775d89770cd9c2cb1e05/src/Widgets/Carousel.php | src/Widgets/Carousel.php | <?php
namespace Encore\Admin\Widgets;
use Illuminate\Contracts\Support\Renderable;
class Carousel extends Widget implements Renderable
{
/**
* @var string
*/
protected $view = 'admin::widgets.carousel';
/**
* @var array
*/
protected $items;
/**
* @var string
*/
protected $title = 'Carousel';
/**
* Carousel constructor.
*
* @param array $items
*/
public function __construct($items = [])
{
$this->items = $items;
$this->id('carousel-'.uniqid());
$this->class('carousel slide');
$this->offsetSet('data-ride', 'carousel');
}
/**
* Set title.
*
* @param string $title
*/
public function title($title)
{
$this->title = $title;
}
/**
* Render Carousel.
*
* @return string
*/
public function render()
{
$variables = [
'items' => $this->items,
'title' => $this->title,
'attributes' => $this->formatAttributes(),
'id' => $this->id,
'width' => $this->width ?: 300,
'height' => $this->height ?: 200,
];
return view($this->view, $variables)->render();
}
}
| php | MIT | 67c441eb78ecc5437e59775d89770cd9c2cb1e05 | 2026-01-04T15:05:15.717211Z | false |
z-song/laravel-admin | https://github.com/z-song/laravel-admin/blob/67c441eb78ecc5437e59775d89770cd9c2cb1e05/src/Widgets/Tab.php | src/Widgets/Tab.php | <?php
namespace Encore\Admin\Widgets;
use Encore\Admin\Facades\Admin;
use Illuminate\Contracts\Support\Renderable;
class Tab extends Widget implements Renderable
{
use ContainsForms;
const TYPE_CONTENT = 1;
const TYPE_LINK = 2;
/**
* @var string
*/
protected $view = 'admin::widgets.tab';
/**
* @var array
*/
protected $data = [
'id' => '',
'title' => '',
'tabs' => [],
'dropDown' => [],
'active' => 0,
];
public function __construct()
{
$this->class('nav-tabs-custom');
}
/**
* Add a tab and its contents.
*
* @param string $title
* @param string|Renderable $content
* @param bool $active
* @param string|null $id
*
* @return $this
*/
public function add($title, $content, $active = false, $id = null)
{
$this->data['tabs'][] = [
'id' => $id ?: mt_rand(),
'title' => $title,
'content' => $content,
'type' => static::TYPE_CONTENT,
];
if ($active) {
$this->data['active'] = count($this->data['tabs']) - 1;
}
return $this;
}
/**
* Add a link on tab.
*
* @param string $title
* @param string $href
* @param bool $active
*
* @return $this
*/
public function addLink($title, $href, $active = false)
{
$this->data['tabs'][] = [
'id' => mt_rand(),
'title' => $title,
'href' => $href,
'type' => static::TYPE_LINK,
];
if ($active) {
$this->data['active'] = count($this->data['tabs']) - 1;
}
return $this;
}
/**
* Set title.
*
* @param string $title
*/
public function title($title = '')
{
$this->data['title'] = $title;
}
/**
* Set drop-down items.
*
* @param array $links
*
* @return $this
*/
public function dropDown(array $links)
{
if (is_array($links[0])) {
foreach ($links as $link) {
call_user_func([$this, 'dropDown'], $link);
}
return $this;
}
$this->data['dropDown'][] = [
'name' => $links[0],
'href' => $links[1],
];
return $this;
}
/**
* Render Tab.
*
* @return string
*/
public function render()
{
$data = array_merge(
$this->data,
['attributes' => $this->formatAttributes()]
);
$this->setupScript();
return view($this->view, $data)->render();
}
/**
* Setup script.
*/
protected function setupScript()
{
$script = <<<'SCRIPT'
var hash = document.location.hash;
if (hash) {
$('.nav-tabs a[href="' + hash + '"]').tab('show');
}
// Change hash for page-reload
$('.nav-tabs a').on('shown.bs.tab', function (e) {
history.pushState(null,null, e.target.hash);
});
SCRIPT;
Admin::script($script);
}
}
| php | MIT | 67c441eb78ecc5437e59775d89770cd9c2cb1e05 | 2026-01-04T15:05:15.717211Z | false |
z-song/laravel-admin | https://github.com/z-song/laravel-admin/blob/67c441eb78ecc5437e59775d89770cd9c2cb1e05/src/Widgets/Widget.php | src/Widgets/Widget.php | <?php
namespace Encore\Admin\Widgets;
use Illuminate\Support\Fluent;
abstract class Widget extends Fluent
{
/**
* @var string
*/
protected $view;
/**
* @return mixed
*/
abstract public function render();
/**
* Set view of widget.
*
* @param string $view
*/
public function view($view)
{
$this->view = $view;
}
/**
* Build an HTML attribute string from an array.
*
* @return string
*/
public function formatAttributes()
{
$html = [];
foreach ((array) $this->getAttributes() as $key => $value) {
$element = $this->attributeElement($key, $value);
if (!is_null($element)) {
$html[] = $element;
}
}
return count($html) > 0 ? ' '.implode(' ', $html) : '';
}
/**
* Build a single attribute element.
*
* @param string $key
* @param string $value
*
* @return string
*/
protected function attributeElement($key, $value)
{
if (is_numeric($key)) {
$key = $value;
}
if (!is_null($value)) {
return $key.'="'.htmlentities($value, ENT_QUOTES, 'UTF-8').'"';
}
}
/**
* @return mixed
*/
public function __toString()
{
return $this->render();
}
}
| php | MIT | 67c441eb78ecc5437e59775d89770cd9c2cb1e05 | 2026-01-04T15:05:15.717211Z | false |
z-song/laravel-admin | https://github.com/z-song/laravel-admin/blob/67c441eb78ecc5437e59775d89770cd9c2cb1e05/src/Widgets/InfoBox.php | src/Widgets/InfoBox.php | <?php
namespace Encore\Admin\Widgets;
use Illuminate\Contracts\Support\Renderable;
class InfoBox extends Widget implements Renderable
{
/**
* @var string
*/
protected $view = 'admin::widgets.info-box';
/**
* @var array
*/
protected $data = [];
/**
* InfoBox constructor.
*
* @param string $name
* @param string $icon
* @param string $color
* @param string $link
* @param string $info
*/
public function __construct($name, $icon, $color, $link, $info)
{
$this->data = [
'name' => $name,
'icon' => $icon,
'link' => $link,
'info' => $info,
];
$this->class("small-box bg-$color");
}
/**
* @return string
*/
public function render()
{
$variables = array_merge($this->data, ['attributes' => $this->formatAttributes()]);
return view($this->view, $variables)->render();
}
}
| php | MIT | 67c441eb78ecc5437e59775d89770cd9c2cb1e05 | 2026-01-04T15:05:15.717211Z | false |
z-song/laravel-admin | https://github.com/z-song/laravel-admin/blob/67c441eb78ecc5437e59775d89770cd9c2cb1e05/src/Widgets/ContainsForms.php | src/Widgets/ContainsForms.php | <?php
namespace Encore\Admin\Widgets;
trait ContainsForms
{
/**
* @var string
*/
protected $activeName = 'active';
/**
* @param array $forms
* @param null $active
*
* @return mixed
*/
public static function forms($forms, $active = null)
{
$tab = new static();
return $tab->buildTabbedForms($forms, $active);
}
/**
* @param array $forms
* @param null $active
*
* @return $this
*/
protected function buildTabbedForms($forms, $active = null)
{
$active = $active ?: request($this->activeName);
if (!isset($forms[$active])) {
$active = key($forms);
}
foreach ($forms as $name => $class) {
if (!is_subclass_of($class, Form::class)) {
admin_error("Class [{$class}] must be a sub-class of [Encore\Admin\Widgets\Form].");
continue;
}
/** @var Form $form */
$form = app()->make($class);
if ($name == $active) {
$this->add($form->title(), $form->unbox(), true);
} else {
$this->addLink($form->title(), $this->getTabUrl($name));
}
}
return $this;
}
/**
* @param string $name
*
* @return string
*/
protected function getTabUrl($name)
{
$query = [$this->activeName => $name];
return request()->fullUrlWithQuery($query);
}
}
| php | MIT | 67c441eb78ecc5437e59775d89770cd9c2cb1e05 | 2026-01-04T15:05:15.717211Z | false |
z-song/laravel-admin | https://github.com/z-song/laravel-admin/blob/67c441eb78ecc5437e59775d89770cd9c2cb1e05/src/Widgets/Form.php | src/Widgets/Form.php | <?php
namespace Encore\Admin\Widgets;
use Closure;
use Encore\Admin\Facades\Admin;
use Encore\Admin\Form as BaseForm;
use Encore\Admin\Form\Field;
use Encore\Admin\Layout\Content;
use Illuminate\Contracts\Support\Arrayable;
use Illuminate\Contracts\Support\Renderable;
use Illuminate\Http\Request;
use Illuminate\Support\Arr;
use Illuminate\Support\MessageBag;
use Illuminate\Validation\Validator;
/**
* Class Form.
*
* @method Field\Text text($name, $label = '')
* @method Field\Password password($name, $label = '')
* @method Field\Checkbox checkbox($name, $label = '')
* @method Field\CheckboxButton checkboxButton($name, $label = '')
* @method Field\CheckboxCard checkboxCard($name, $label = '')
* @method Field\Radio radio($name, $label = '')
* @method Field\RadioButton radioButton($name, $label = '')
* @method Field\RadioCard radioCard($name, $label = '')
* @method Field\Select select($name, $label = '')
* @method Field\MultipleSelect multipleSelect($name, $label = '')
* @method Field\Textarea textarea($name, $label = '')
* @method Field\Hidden hidden($name, $label = '')
* @method Field\Id id($name, $label = '')
* @method Field\Ip ip($name, $label = '')
* @method Field\Url url($name, $label = '')
* @method Field\Color color($name, $label = '')
* @method Field\Email email($name, $label = '')
* @method Field\Mobile mobile($name, $label = '')
* @method Field\Slider slider($name, $label = '')
* @method Field\File file($name, $label = '')
* @method Field\Image image($name, $label = '')
* @method Field\Date date($name, $label = '')
* @method Field\Datetime datetime($name, $label = '')
* @method Field\Time time($name, $label = '')
* @method Field\Year year($column, $label = '')
* @method Field\Month month($column, $label = '')
* @method Field\DateRange dateRange($start, $end, $label = '')
* @method Field\DateTimeRange dateTimeRange($start, $end, $label = '')
* @method Field\TimeRange timeRange($start, $end, $label = '')
* @method Field\Number number($name, $label = '')
* @method Field\Currency currency($name, $label = '')
* @method Field\SwitchField switch($name, $label = '')
* @method Field\Display display($name, $label = '')
* @method Field\Rate rate($name, $label = '')
* @method Field\Divider divider($title = '')
* @method Field\Decimal decimal($column, $label = '')
* @method Field\Html html($html)
* @method Field\Tags tags($column, $label = '')
* @method Field\Icon icon($column, $label = '')
* @method Field\Captcha captcha($column, $label = '')
* @method Field\Listbox listbox($column, $label = '')
* @method Field\Table table($column, $label, $builder)
* @method Field\Timezone timezone($column, $label = '')
* @method Field\KeyValue keyValue($column, $label = '')
* @method Field\ListField list($column, $label = '')
* @method mixed handle(Request $request)
*/
class Form implements Renderable
{
use BaseForm\Concerns\HandleCascadeFields;
/**
* The title of form.
*
* @var string
*/
public $title;
/**
* The description of form.
*
* @var string
*/
public $description;
/**
* @var Field[]
*/
protected $fields = [];
/**
* @var array
*/
protected $data = [];
/**
* @var array
*/
protected $attributes = [];
/**
* Available buttons.
*
* @var array
*/
protected $buttons = ['reset', 'submit'];
/**
* Width for label and submit field.
*
* @var array
*/
protected $width = [
'label' => 2,
'field' => 8,
];
/**
* @var bool
*/
public $inbox = true;
/**
* @var string
*/
public $confirm = '';
/**
* @var Form
*/
protected $form;
/**
* Form constructor.
*
* @param array $data
*/
public function __construct($data = [])
{
$this->fill($data);
$this->initFormAttributes();
}
/**
* Get form title.
*
* @return mixed
*/
public function title()
{
return $this->title;
}
/**
* Get form description.
*
* @return mixed
*/
public function description()
{
return $this->description ?: ' ';
}
/**
* @return array
*/
public function data()
{
return $this->data;
}
/**
* @return array
*/
public function confirm($message)
{
$this->confirm = $message;
return $this;
}
/**
* Fill data to form fields.
*
* @param array $data
*
* @return $this
*/
public function fill($data = [])
{
if ($data instanceof Arrayable) {
$data = $data->toArray();
}
if (!empty($data)) {
$this->data = $data;
}
return $this;
}
/**
* @return $this
*/
public function sanitize()
{
foreach (['_form_', '_token'] as $key) {
request()->request->remove($key);
}
return $this;
}
/**
* Initialize the form attributes.
*/
protected function initFormAttributes()
{
$this->attributes = [
'id' => 'widget-form-'.uniqid(),
'method' => 'POST',
'action' => '',
'class' => 'form-horizontal',
'accept-charset' => 'UTF-8',
'pjax-container' => true,
];
}
/**
* Add form attributes.
*
* @param string|array $attr
* @param string $value
*
* @return $this
*/
public function attribute($attr, $value = '')
{
if (is_array($attr)) {
foreach ($attr as $key => $value) {
$this->attribute($key, $value);
}
} else {
$this->attributes[$attr] = $value;
}
return $this;
}
/**
* Format form attributes form array to html.
*
* @param array $attributes
*
* @return string
*/
public function formatAttribute($attributes = [])
{
$attributes = $attributes ?: $this->attributes;
if ($this->hasFile()) {
$attributes['enctype'] = 'multipart/form-data';
}
$html = [];
foreach ($attributes as $key => $val) {
$html[] = "$key=\"$val\"";
}
return implode(' ', $html) ?: '';
}
/**
* Action uri of the form.
*
* @param string $action
*
* @return $this
*/
public function action($action)
{
return $this->attribute('action', $action);
}
/**
* Method of the form.
*
* @param string $method
*
* @return $this
*/
public function method($method = 'POST')
{
if (strtolower($method) == 'put') {
$this->hidden('_method')->default($method);
return $this;
}
return $this->attribute('method', strtoupper($method));
}
/**
* Disable Pjax.
*
* @return $this
*/
public function disablePjax()
{
Arr::forget($this->attributes, 'pjax-container');
return $this;
}
/**
* Disable reset button.
*
* @return $this
*/
public function disableReset()
{
array_delete($this->buttons, 'reset');
return $this;
}
/**
* Disable submit button.
*
* @return $this
*/
public function disableSubmit()
{
array_delete($this->buttons, 'submit');
return $this;
}
/**
* Set field and label width in current form.
*
* @param int $fieldWidth
* @param int $labelWidth
*
* @return $this
*/
public function setWidth($fieldWidth = 8, $labelWidth = 2)
{
collect($this->fields)->each(function ($field) use ($fieldWidth, $labelWidth) {
/* @var Field $field */
$field->setWidth($fieldWidth, $labelWidth);
});
// set this width
$this->width = [
'label' => $labelWidth,
'field' => $fieldWidth,
];
return $this;
}
/**
* Determine if the form has field type.
*
* @param string $name
*
* @return bool
*/
public function hasField($name)
{
return isset(BaseForm::$availableFields[$name]);
}
/**
* Add a form field to form.
*
* @param Field $field
*
* @return $this
*/
public function pushField(Field $field)
{
$field->setWidgetForm($this);
array_push($this->fields, $field);
return $this;
}
/**
* Get all fields of form.
*
* @return Field[]
*/
public function fields()
{
return collect($this->fields);
}
/**
* Get variables for render form.
*
* @return array
*/
protected function getVariables()
{
$this->fields()->each->fill($this->data());
return [
'fields' => $this->fields,
'attributes' => $this->formatAttribute(),
'method' => $this->attributes['method'],
'buttons' => $this->buttons,
'width' => $this->width,
];
}
/**
* Determine if form fields has files.
*
* @return bool
*/
public function hasFile()
{
foreach ($this->fields as $field) {
if ($field instanceof Field\File) {
return true;
}
}
return false;
}
/**
* Validate this form fields.
*
* @param Request $request
*
* @return bool|MessageBag
*/
public function validate(Request $request)
{
if (method_exists($this, 'form')) {
$this->form();
}
$failedValidators = [];
/** @var Field $field */
foreach ($this->fields() as $field) {
if (!$validator = $field->getValidator($request->all())) {
continue;
}
if (($validator instanceof Validator) && !$validator->passes()) {
$failedValidators[] = $validator;
}
}
$message = $this->mergeValidationMessages($failedValidators);
return $message->any() ? $message : false;
}
/**
* Merge validation messages from input validators.
*
* @param \Illuminate\Validation\Validator[] $validators
*
* @return MessageBag
*/
protected function mergeValidationMessages($validators)
{
$messageBag = new MessageBag();
foreach ($validators as $validator) {
$messageBag = $messageBag->merge($validator->messages());
}
return $messageBag;
}
/**
* Add a fieldset to form.
*
* @param string $title
* @param Closure $setCallback
*
* @return Field\Fieldset
*/
public function fieldset(string $title, Closure $setCallback)
{
$fieldset = new Field\Fieldset();
$this->html($fieldset->start($title))->plain();
$setCallback($this);
$this->html($fieldset->end())->plain();
return $fieldset;
}
/**
* @return $this
*/
public function unbox()
{
$this->inbox = false;
return $this;
}
protected function addConfirmScript()
{
$id = $this->attributes['id'];
$trans = [
'cancel' => trans('admin.cancel'),
'submit' => trans('admin.submit'),
];
$settings = [
'type' => 'question',
'showCancelButton' => true,
'confirmButtonText' => $trans['submit'],
'cancelButtonText' => $trans['cancel'],
'title' => $this->confirm,
'text' => '',
];
$settings = trim(json_encode($settings, JSON_PRETTY_PRINT));
$script = <<<SCRIPT
$('form#{$id}').off('submit').on('submit', function (e) {
e.preventDefault();
var form = this;
$.admin.swal($settings).then(function (result) {
if (result.value == true) {
form.submit();
}
});
return false;
});
SCRIPT;
Admin::script($script);
}
protected function addCascadeScript()
{
$id = $this->attributes['id'];
$script = <<<SCRIPT
;(function () {
$('form#{$id}').submit(function (e) {
e.preventDefault();
$(this).find('div.cascade-group.hide :input').attr('disabled', true);
});
})();
SCRIPT;
Admin::script($script);
}
protected function prepareForm()
{
if (method_exists($this, 'form')) {
$this->form();
}
if (!empty($this->confirm)) {
$this->addConfirmScript();
}
$this->addCascadeScript();
}
protected function prepareHandle()
{
if (method_exists($this, 'handle')) {
$this->method('POST');
$this->action(admin_url('_handle_form_'));
$this->hidden('_form_')->default(get_called_class());
}
}
/**
* Render the form.
*
* @return string
*/
public function render()
{
$this->prepareForm();
$this->prepareHandle();
$form = view('admin::widgets.form', $this->getVariables())->render();
if (!($title = $this->title()) || !$this->inbox) {
return $form;
}
return (new Box($title, $form))->render();
}
/**
* Generate a Field object and add to form builder if Field exists.
*
* @param string $method
* @param array $arguments
*
* @return Field|$this
*/
public function __call($method, $arguments)
{
if (!$this->hasField($method)) {
return $this;
}
$class = BaseForm::$availableFields[$method];
$field = new $class(Arr::get($arguments, 0), array_slice($arguments, 1));
return tap($field, function ($field) {
$this->pushField($field);
});
}
/**
* @param Content $content
*
* @return Content
*/
public function __invoke(Content $content)
{
return $content->title($this->title())
->description($this->description())
->body($this);
}
}
| php | MIT | 67c441eb78ecc5437e59775d89770cd9c2cb1e05 | 2026-01-04T15:05:15.717211Z | false |
z-song/laravel-admin | https://github.com/z-song/laravel-admin/blob/67c441eb78ecc5437e59775d89770cd9c2cb1e05/src/Widgets/Collapse.php | src/Widgets/Collapse.php | <?php
namespace Encore\Admin\Widgets;
use Illuminate\Contracts\Support\Renderable;
class Collapse extends Widget implements Renderable
{
/**
* @var string
*/
protected $view = 'admin::widgets.collapse';
/**
* @var array
*/
protected $items = [];
/**
* Collapse constructor.
*/
public function __construct()
{
$this->id('accordion-'.uniqid());
$this->class('box-group');
$this->style('margin-bottom: 20px');
}
/**
* Add item.
*
* @param string $title
* @param string $content
*
* @return $this
*/
public function add($title, $content)
{
$this->items[] = [
'title' => $title,
'content' => $content,
];
return $this;
}
protected function variables()
{
return [
'id' => $this->id,
'items' => $this->items,
'attributes' => $this->formatAttributes(),
];
}
/**
* Render Collapse.
*
* @return string
*/
public function render()
{
return view($this->view, $this->variables())->render();
}
}
| php | MIT | 67c441eb78ecc5437e59775d89770cd9c2cb1e05 | 2026-01-04T15:05:15.717211Z | false |
z-song/laravel-admin | https://github.com/z-song/laravel-admin/blob/67c441eb78ecc5437e59775d89770cd9c2cb1e05/src/Widgets/Alert.php | src/Widgets/Alert.php | <?php
namespace Encore\Admin\Widgets;
use Illuminate\Contracts\Support\Renderable;
class Alert extends Widget implements Renderable
{
/**
* @var string
*/
protected $view = 'admin::widgets.alert';
/**
* @var string|\Symfony\Component\Translation\TranslatorInterface
*/
protected $title = '';
/**
* @var string
*/
protected $content = '';
/**
* @var string
*/
protected $style = 'danger';
/**
* @var string
*/
protected $icon = 'ban';
/**
* Alert constructor.
*
* @param mixed $content
* @param string $title
* @param string $style
*/
public function __construct($content, $title = '', $style = 'danger')
{
$this->content = (string) $content;
$this->title = $title ?: trans('admin.alert');
$this->style($style);
}
/**
* Add style.
*
* @param string $style
*
* @return $this
*/
public function style($style = 'info')
{
$this->style = $style;
return $this;
}
/**
* Add icon.
*
* @param string $icon
*
* @return $this
*/
public function icon($icon)
{
$this->icon = $icon;
return $this;
}
/**
* @return array
*/
protected function variables()
{
$this->class("alert alert-{$this->style} alert-dismissable");
return [
'title' => $this->title,
'content' => $this->content,
'icon' => $this->icon,
'attributes' => $this->formatAttributes(),
];
}
/**
* Render alter.
*
* @return string
*/
public function render()
{
return view($this->view, $this->variables())->render();
}
}
| php | MIT | 67c441eb78ecc5437e59775d89770cd9c2cb1e05 | 2026-01-04T15:05:15.717211Z | false |
z-song/laravel-admin | https://github.com/z-song/laravel-admin/blob/67c441eb78ecc5437e59775d89770cd9c2cb1e05/src/Widgets/Navbar/RefreshButton.php | src/Widgets/Navbar/RefreshButton.php | <?php
namespace Encore\Admin\Widgets\Navbar;
use Encore\Admin\Admin;
use Illuminate\Contracts\Support\Renderable;
class RefreshButton implements Renderable
{
public function render()
{
return Admin::component('admin::components.refresh-btn');
}
}
| php | MIT | 67c441eb78ecc5437e59775d89770cd9c2cb1e05 | 2026-01-04T15:05:15.717211Z | false |
z-song/laravel-admin | https://github.com/z-song/laravel-admin/blob/67c441eb78ecc5437e59775d89770cd9c2cb1e05/src/Widgets/Navbar/Fullscreen.php | src/Widgets/Navbar/Fullscreen.php | <?php
namespace Encore\Admin\Widgets\Navbar;
use Encore\Admin\Admin;
use Illuminate\Contracts\Support\Renderable;
/**
* Class FullScreen.
*
* @see https://javascript.ruanyifeng.com/htmlapi/fullscreen.html
*/
class Fullscreen implements Renderable
{
public function render()
{
return Admin::component('admin::components.fullscreen');
}
}
| php | MIT | 67c441eb78ecc5437e59775d89770cd9c2cb1e05 | 2026-01-04T15:05:15.717211Z | false |
z-song/laravel-admin | https://github.com/z-song/laravel-admin/blob/67c441eb78ecc5437e59775d89770cd9c2cb1e05/tests/PermissionsTest.php | tests/PermissionsTest.php | <?php
use Encore\Admin\Auth\Database\Administrator;
use Encore\Admin\Auth\Database\Permission;
use Encore\Admin\Auth\Database\Role;
class PermissionsTest extends TestCase
{
protected function setUp(): void
{
parent::setUp();
$this->be(Administrator::first(), 'admin');
}
public function testPermissionsIndex()
{
$this->assertTrue(Administrator::first()->isAdministrator());
$this->visit('admin/auth/permissions')
->see('Permissions');
}
public function testAddAndDeletePermissions()
{
$this->visit('admin/auth/permissions/create')
->see('Permissions')
->submitForm('Submit', ['slug' => 'can-edit', 'name' => 'Can edit', 'http_path' => 'users/1/edit', 'http_method' => ['GET']])
->seePageIs('admin/auth/permissions')
->visit('admin/auth/permissions/create')
->see('Permissions')
->submitForm('Submit', ['slug' => 'can-delete', 'name' => 'Can delete', 'http_path' => 'users/1', 'http_method' => ['DELETE']])
->seePageIs('admin/auth/permissions')
->seeInDatabase(config('admin.database.permissions_table'), ['slug' => 'can-edit', 'name' => 'Can edit', 'http_path' => 'users/1/edit', 'http_method' => 'GET'])
->seeInDatabase(config('admin.database.permissions_table'), ['slug' => 'can-delete', 'name' => 'Can delete', 'http_path' => 'users/1', 'http_method' => 'DELETE'])
->assertEquals(7, Permission::count());
$this->assertTrue(Administrator::first()->can('can-edit'));
$this->assertTrue(Administrator::first()->can('can-delete'));
$this->delete('admin/auth/permissions/6')
->assertEquals(6, Permission::count());
$this->delete('admin/auth/permissions/7')
->assertEquals(5, Permission::count());
}
public function testAddPermissionToRole()
{
$this->visit('admin/auth/permissions/create')
->see('Permissions')
->submitForm('Submit', ['slug' => 'can-create', 'name' => 'Can Create', 'http_path' => 'users/create', 'http_method' => ['GET']])
->seePageIs('admin/auth/permissions');
$this->assertEquals(6, Permission::count());
$this->visit('admin/auth/roles/1/edit')
->see('Edit')
->submitForm('Submit', ['permissions' => [1]])
->seePageIs('admin/auth/roles')
->seeInDatabase(config('admin.database.role_permissions_table'), ['role_id' => 1, 'permission_id' => 1]);
}
public function testAddPermissionToUser()
{
$this->visit('admin/auth/permissions/create')
->see('Permissions')
->submitForm('Submit', ['slug' => 'can-create', 'name' => 'Can Create', 'http_path' => 'users/create', 'http_method' => ['GET']])
->seePageIs('admin/auth/permissions');
$this->assertEquals(6, Permission::count());
$this->visit('admin/auth/users/1/edit')
->see('Edit')
->submitForm('Submit', ['permissions' => [1], 'roles' => [1]])
->seePageIs('admin/auth/users')
->seeInDatabase(config('admin.database.user_permissions_table'), ['user_id' => 1, 'permission_id' => 1])
->seeInDatabase(config('admin.database.role_users_table'), ['user_id' => 1, 'role_id' => 1]);
}
public function testAddUserAndAssignPermission()
{
$user = [
'username' => 'Test',
'name' => 'Name',
'password' => '123456',
'password_confirmation' => '123456',
];
$this->visit('admin/auth/users/create')
->see('Create')
->submitForm('Submit', $user)
->seePageIs('admin/auth/users')
->seeInDatabase(config('admin.database.users_table'), ['username' => 'Test']);
$this->assertFalse(Administrator::find(2)->isAdministrator());
$this->visit('admin/auth/permissions/create')
->see('Permissions')
->submitForm('Submit', ['slug' => 'can-update', 'name' => 'Can Update', 'http_path' => 'users/*/edit', 'http_method' => ['GET']])
->seePageIs('admin/auth/permissions');
$this->assertEquals(6, Permission::count());
$this->visit('admin/auth/permissions/create')
->see('Permissions')
->submitForm('Submit', ['slug' => 'can-remove', 'name' => 'Can Remove', 'http_path' => 'users/*', 'http_method' => ['DELETE']])
->seePageIs('admin/auth/permissions');
$this->assertEquals(7, Permission::count());
$this->visit('admin/auth/users/2/edit')
->see('Edit')
->submitForm('Submit', ['permissions' => [6]])
->seePageIs('admin/auth/users')
->seeInDatabase(config('admin.database.user_permissions_table'), ['user_id' => 2, 'permission_id' => 6]);
$this->assertTrue(Administrator::find(2)->can('can-update'));
$this->assertTrue(Administrator::find(2)->cannot('can-remove'));
$this->visit('admin/auth/users/2/edit')
->see('Edit')
->submitForm('Submit', ['permissions' => [7]])
->seePageIs('admin/auth/users')
->seeInDatabase(config('admin.database.user_permissions_table'), ['user_id' => 2, 'permission_id' => 7]);
$this->assertTrue(Administrator::find(2)->can('can-remove'));
$this->visit('admin/auth/users/2/edit')
->see('Edit')
->submitForm('Submit', ['permissions' => []])
->seePageIs('admin/auth/users')
->missingFromDatabase(config('admin.database.user_permissions_table'), ['user_id' => 2, 'permission_id' => 6])
->missingFromDatabase(config('admin.database.user_permissions_table'), ['user_id' => 2, 'permission_id' => 7]);
$this->assertTrue(Administrator::find(2)->cannot('can-update'));
$this->assertTrue(Administrator::find(2)->cannot('can-remove'));
}
public function testPermissionThroughRole()
{
$user = [
'username' => 'Test',
'name' => 'Name',
'password' => '123456',
'password_confirmation' => '123456',
];
// 1.add a user
$this->visit('admin/auth/users/create')
->see('Create')
->submitForm('Submit', $user)
->seePageIs('admin/auth/users')
->seeInDatabase(config('admin.database.users_table'), ['username' => 'Test']);
$this->assertFalse(Administrator::find(2)->isAdministrator());
// 2.add a role
$this->visit('admin/auth/roles/create')
->see('Roles')
->submitForm('Submit', ['slug' => 'developer', 'name' => 'Developer...'])
->seePageIs('admin/auth/roles')
->seeInDatabase(config('admin.database.roles_table'), ['slug' => 'developer', 'name' => 'Developer...'])
->assertEquals(2, Role::count());
$this->assertFalse(Administrator::find(2)->isRole('developer'));
// 3.assign role to user
$this->visit('admin/auth/users/2/edit')
->see('Edit')
->submitForm('Submit', ['roles' => [2]])
->seePageIs('admin/auth/users')
->seeInDatabase(config('admin.database.role_users_table'), ['user_id' => 2, 'role_id' => 2]);
$this->assertTrue(Administrator::find(2)->isRole('developer'));
// 4.add a permission
$this->visit('admin/auth/permissions/create')
->see('Permissions')
->submitForm('Submit', ['slug' => 'can-remove', 'name' => 'Can Remove', 'http_path' => 'users/*', 'http_method' => ['DELETE']])
->seePageIs('admin/auth/permissions');
$this->assertEquals(6, Permission::count());
$this->assertTrue(Administrator::find(2)->cannot('can-remove'));
// 5.assign permission to role
$this->visit('admin/auth/roles/2/edit')
->see('Edit')
->submitForm('Submit', ['permissions' => [6]])
->seePageIs('admin/auth/roles')
->seeInDatabase(config('admin.database.role_permissions_table'), ['role_id' => 2, 'permission_id' => 6]);
$this->assertTrue(Administrator::find(2)->can('can-remove'));
}
public function testEditPermission()
{
$this->visit('admin/auth/permissions/create')
->see('Permissions')
->submitForm('Submit', ['slug' => 'can-edit', 'name' => 'Can edit', 'http_path' => 'users/1/edit', 'http_method' => ['GET']])
->seePageIs('admin/auth/permissions')
->seeInDatabase(config('admin.database.permissions_table'), ['slug' => 'can-edit'])
->seeInDatabase(config('admin.database.permissions_table'), ['name' => 'Can edit'])
->assertEquals(6, Permission::count());
$this->visit('admin/auth/permissions/1/edit')
->see('Permissions')
->submitForm('Submit', ['slug' => 'can-delete'])
->seePageIs('admin/auth/permissions')
->seeInDatabase(config('admin.database.permissions_table'), ['slug' => 'can-delete'])
->assertEquals(6, Permission::count());
}
}
| php | MIT | 67c441eb78ecc5437e59775d89770cd9c2cb1e05 | 2026-01-04T15:05:15.717211Z | false |
z-song/laravel-admin | https://github.com/z-song/laravel-admin/blob/67c441eb78ecc5437e59775d89770cd9c2cb1e05/tests/RolesTest.php | tests/RolesTest.php | <?php
use Encore\Admin\Auth\Database\Administrator;
use Encore\Admin\Auth\Database\Role;
class RolesTest extends TestCase
{
protected function setUp(): void
{
parent::setUp();
$this->be(Administrator::first(), 'admin');
}
public function testRolesIndex()
{
$this->visit('admin/auth/roles')
->see('Roles')
->see('administrator');
}
public function testAddRole()
{
$this->visit('admin/auth/roles/create')
->see('Roles')
->submitForm('Submit', ['slug' => 'developer', 'name' => 'Developer...'])
->seePageIs('admin/auth/roles')
->seeInDatabase(config('admin.database.roles_table'), ['slug' => 'developer', 'name' => 'Developer...'])
->assertEquals(2, Role::count());
}
public function testAddRoleToUser()
{
$user = [
'username' => 'Test',
'name' => 'Name',
'password' => '123456',
'password_confirmation' => '123456',
];
$this->visit('admin/auth/users/create')
->see('Create')
->submitForm('Submit', $user)
->seePageIs('admin/auth/users')
->seeInDatabase(config('admin.database.users_table'), ['username' => 'Test']);
$this->assertEquals(1, Role::count());
$this->visit('admin/auth/roles/create')
->see('Roles')
->submitForm('Submit', ['slug' => 'developer', 'name' => 'Developer...'])
->seePageIs('admin/auth/roles')
->seeInDatabase(config('admin.database.roles_table'), ['slug' => 'developer', 'name' => 'Developer...'])
->assertEquals(2, Role::count());
$this->assertFalse(Administrator::find(2)->isRole('developer'));
$this->visit('admin/auth/users/2/edit')
->see('Edit')
->submitForm('Submit', ['roles' => [2]])
->seePageIs('admin/auth/users')
->seeInDatabase(config('admin.database.role_users_table'), ['user_id' => 2, 'role_id' => 2]);
$this->assertTrue(Administrator::find(2)->isRole('developer'));
$this->assertFalse(Administrator::find(2)->inRoles(['editor', 'operator']));
$this->assertTrue(Administrator::find(2)->inRoles(['developer', 'operator', 'editor']));
}
public function testDeleteRole()
{
$this->assertEquals(1, Role::count());
$this->visit('admin/auth/roles/create')
->see('Roles')
->submitForm('Submit', ['slug' => 'developer', 'name' => 'Developer...'])
->seePageIs('admin/auth/roles')
->seeInDatabase(config('admin.database.roles_table'), ['slug' => 'developer', 'name' => 'Developer...'])
->assertEquals(2, Role::count());
$this->delete('admin/auth/roles/2')
->assertEquals(1, Role::count());
$this->delete('admin/auth/roles/1')
->assertEquals(0, Role::count());
}
public function testEditRole()
{
$this->visit('admin/auth/roles/create')
->see('Roles')
->submitForm('Submit', ['slug' => 'developer', 'name' => 'Developer...'])
->seePageIs('admin/auth/roles')
->seeInDatabase(config('admin.database.roles_table'), ['slug' => 'developer', 'name' => 'Developer...'])
->assertEquals(2, Role::count());
$this->visit('admin/auth/roles/2/edit')
->see('Roles')
->submitForm('Submit', ['name' => 'blablabla'])
->seePageIs('admin/auth/roles')
->seeInDatabase(config('admin.database.roles_table'), ['name' => 'blablabla'])
->assertEquals(2, Role::count());
}
}
| php | MIT | 67c441eb78ecc5437e59775d89770cd9c2cb1e05 | 2026-01-04T15:05:15.717211Z | false |
z-song/laravel-admin | https://github.com/z-song/laravel-admin/blob/67c441eb78ecc5437e59775d89770cd9c2cb1e05/tests/UsersTest.php | tests/UsersTest.php | <?php
use Encore\Admin\Auth\Database\Administrator;
class UsersTest extends TestCase
{
protected $user;
protected function setUp(): void
{
parent::setUp();
$this->user = Administrator::first();
$this->be($this->user, 'admin');
}
public function testUsersIndexPage()
{
$this->visit('admin/auth/users')
->see('Administrator');
}
public function testCreateUser()
{
$user = [
'username' => 'Test',
'name' => 'Name',
'password' => '123456',
'password_confirmation' => '123456',
];
// create user
$this->visit('admin/auth/users/create')
->see('Create')
->submitForm('Submit', $user)
->seePageIs('admin/auth/users')
->seeInDatabase(config('admin.database.users_table'), ['username' => 'Test']);
// assign role to user
$this->visit('admin/auth/users/2/edit')
->see('Edit')
->submitForm('Submit', ['roles' => [1]])
->seePageIs('admin/auth/users')
->seeInDatabase(config('admin.database.role_users_table'), ['user_id' => 2, 'role_id' => 1]);
$this->visit('admin/auth/logout')
->dontSeeIsAuthenticated('admin')
->seePageIs('admin/auth/login')
->submitForm('Login', ['username' => $user['username'], 'password' => $user['password']])
->see('dashboard')
->seeIsAuthenticated('admin')
->seePageIs('admin');
$this->assertTrue($this->app['auth']->guard('admin')->getUser()->isAdministrator());
$this->see('<span>Users</span>')
->see('<span>Roles</span>')
->see('<span>Permission</span>')
->see('<span>Operation log</span>')
->see('<span>Menu</span>');
}
public function testUpdateUser()
{
$this->visit('admin/auth/users/'.$this->user->id.'/edit')
->see('Create')
->submitForm('Submit', ['name' => 'test', 'roles' => [1]])
->seePageIs('admin/auth/users')
->seeInDatabase(config('admin.database.users_table'), ['name' => 'test']);
}
public function testResetPassword()
{
$password = 'odjwyufkglte';
$data = [
'password' => $password,
'password_confirmation' => $password,
'roles' => [1],
];
$this->visit('admin/auth/users/'.$this->user->id.'/edit')
->see('Create')
->submitForm('Submit', $data)
->seePageIs('admin/auth/users')
->visit('admin/auth/logout')
->dontSeeIsAuthenticated('admin')
->seePageIs('admin/auth/login')
->submitForm('Login', ['username' => $this->user->username, 'password' => $password])
->see('dashboard')
->seeIsAuthenticated('admin')
->seePageIs('admin');
}
}
| php | MIT | 67c441eb78ecc5437e59775d89770cd9c2cb1e05 | 2026-01-04T15:05:15.717211Z | false |
z-song/laravel-admin | https://github.com/z-song/laravel-admin/blob/67c441eb78ecc5437e59775d89770cd9c2cb1e05/tests/ImageUploadTest.php | tests/ImageUploadTest.php | <?php
use Encore\Admin\Auth\Database\Administrator;
use Illuminate\Support\Facades\File;
use Tests\Models\Image;
use Tests\Models\MultipleImage;
class ImageUploadTest extends TestCase
{
protected function setUp(): void
{
parent::setUp();
$this->be(Administrator::first(), 'admin');
}
public function testDisableFilter()
{
$this->visit('admin/images')
->dontSeeElement('input[name=id]');
}
public function testImageUploadPage()
{
$this->visit('admin/images/create')
->see('Images')
->seeInElement('h3[class=box-title]', 'Create')
->seeElement('input[name=image1]')
->seeElement('input[name=image2]')
->seeElement('input[name=image3]')
->seeElement('input[name=image4]')
->seeElement('input[name=image5]')
->seeElement('input[name=image6]')
->seeInElement('button[type=reset]', 'Reset')
->seeInElement('button[type=submit]', 'Submit');
}
protected function uploadImages()
{
return $this->visit('admin/images/create')
->attach(__DIR__.'/assets/test.jpg', 'image1')
->attach(__DIR__.'/assets/test.jpg', 'image2')
->attach(__DIR__.'/assets/test.jpg', 'image3')
->attach(__DIR__.'/assets/test.jpg', 'image4')
->attach(__DIR__.'/assets/test.jpg', 'image5')
->attach(__DIR__.'/assets/test.jpg', 'image6')
->press('Submit');
}
public function testUploadImage()
{
File::cleanDirectory(public_path('uploads/images'));
$this->uploadImages()
->seePageIs('admin/images');
$this->assertEquals(Image::count(), 1);
$this->seeInDatabase('test_images', ['image4' => 'images/renamed.jpeg']);
$images = Image::first()->toArray();
foreach (range(1, 6) as $index) {
$this->assertFileExists(public_path('uploads/'.$images['image'.$index]));
}
$this->assertFileExists(public_path('uploads/images/asdasdasdasdasd.jpeg'));
File::cleanDirectory(public_path('uploads/images'));
}
public function testRemoveImage()
{
File::cleanDirectory(public_path('uploads/images'));
$this->uploadImages();
$this->assertEquals($this->fileCountInImageDir(), 6);
}
public function testUpdateImage()
{
File::cleanDirectory(public_path('uploads/images'));
$this->uploadImages();
$old = Image::first();
$this->visit('admin/images/1/edit')
->see('ID')
->see('Created At')
->see('Updated At')
->seeElement('input[name=image1]')
->seeElement('input[name=image2]')
->seeElement('input[name=image3]')
->seeElement('input[name=image4]')
->seeElement('input[name=image5]')
->seeElement('input[name=image6]')
->seeInElement('button[type=reset]', 'Reset')
->seeInElement('button[type=submit]', 'Submit');
$this->attach(__DIR__.'/assets/test.jpg', 'image3')
->attach(__DIR__.'/assets/test.jpg', 'image4')
->attach(__DIR__.'/assets/test.jpg', 'image5')
->press('Submit');
$new = Image::first();
$this->assertEquals($old->id, $new->id);
$this->assertEquals($old->image1, $new->image1);
$this->assertEquals($old->image2, $new->image2);
$this->assertEquals($old->image6, $new->image6);
$this->assertNotEquals($old->image3, $new->image3);
$this->assertNotEquals($old->image4, $new->image4);
$this->assertNotEquals($old->image5, $new->image5);
File::cleanDirectory(public_path('uploads/images'));
}
public function testDeleteImages()
{
File::cleanDirectory(public_path('uploads/images'));
$this->uploadImages();
$this->visit('admin/images')
->seeInElement('td', 1);
$images = Image::first()->toArray();
$this->delete('admin/images/1')
->dontSeeInDatabase('test_images', ['id' => 1]);
foreach (range(1, 6) as $index) {
$this->assertFileDoesNotExist(public_path('uploads/'.$images['image'.$index]));
}
$this->visit('admin/images')
->seeInElement('td', 'svg');
}
public function testBatchDelete()
{
File::cleanDirectory(public_path('uploads/images'));
$this->uploadImages();
$this->uploadImages();
$this->uploadImages();
$this->visit('admin/images')
->seeInElement('td', 1)
->seeInElement('td', 2)
->seeInElement('td', 3);
$this->assertEquals($this->fileCountInImageDir(), 18);
$this->assertEquals(Image::count(), 3);
$this->delete('admin/images/1,2,3');
$this->assertEquals(Image::count(), 0);
$this->visit('admin/images')
->seeInElement('td', 'svg');
$this->assertEquals($this->fileCountInImageDir(), 0);
}
public function testUploadMultipleImage()
{
File::cleanDirectory(public_path('uploads/images'));
$this->visit('admin/multiple-images/create')
->seeElement('input[type=file][name="pictures[]"][multiple]');
$path = __DIR__.'/assets/test.jpg';
$file = new \Illuminate\Http\UploadedFile($path, 'test.jpg', 'image/jpeg', null, true);
$size = rand(10, 20);
$files = ['pictures' => array_pad([], $size, $file)];
$this->call(
'POST', // $method
'/admin/multiple-images', // $action
[], // $parameters
[],
$files
);
$this->assertResponseStatus(302);
$this->assertRedirectedTo('/admin/multiple-images');
$this->assertEquals($this->fileCountInImageDir(), $size);
$pictures = MultipleImage::first()->pictures;
$this->assertCount($size, $pictures);
foreach ($pictures as $picture) {
$this->assertFileExists(public_path('uploads/'.$picture));
}
}
public function testRemoveMultipleFiles()
{
File::cleanDirectory(public_path('uploads/images'));
// upload files
$path = __DIR__.'/assets/test.jpg';
$file = new \Illuminate\Http\UploadedFile($path, 'test.jpg', 'image/jpeg', null, true);
$size = rand(10, 20);
$files = ['pictures' => array_pad([], $size, $file)];
$this->call(
'POST', // $method
'/admin/multiple-images', // $action
[], // $parameters
[],
$files
);
$this->assertEquals($this->fileCountInImageDir(), $size);
}
protected function fileCountInImageDir($dir = 'uploads/images')
{
$file = new FilesystemIterator(public_path($dir), FilesystemIterator::SKIP_DOTS);
return iterator_count($file);
}
}
| php | MIT | 67c441eb78ecc5437e59775d89770cd9c2cb1e05 | 2026-01-04T15:05:15.717211Z | false |
z-song/laravel-admin | https://github.com/z-song/laravel-admin/blob/67c441eb78ecc5437e59775d89770cd9c2cb1e05/tests/UserGridTest.php | tests/UserGridTest.php | <?php
use Encore\Admin\Auth\Database\Administrator;
use Tests\Models\Profile as ProfileModel;
use Tests\Models\User as UserModel;
class UserGridTest extends TestCase
{
protected function setUp(): void
{
parent::setUp();
$this->be(Administrator::first(), 'admin');
}
public function testIndexPage()
{
$this->visit('admin/users')
->see('Users')
->seeInElement('tr th', 'Username')
->seeInElement('tr th', 'Email')
->seeInElement('tr th', 'Mobile')
->seeInElement('tr th', 'Full name')
->seeInElement('tr th', 'Avatar')
->seeInElement('tr th', 'Post code')
->seeInElement('tr th', 'Address')
->seeInElement('tr th', 'Position')
->seeInElement('tr th', 'Color')
->seeInElement('tr th', '开始时间')
->seeInElement('tr th', '结束时间')
->seeInElement('tr th', 'Color')
->seeInElement('tr th', 'Created at')
->seeInElement('tr th', 'Updated at');
$action = url('/admin/users');
$this->seeElement("form[action='$action'][method=get]")
->seeElement("form[action='$action'][method=get] input[name=id]")
->seeElement("form[action='$action'][method=get] input[name=username]")
->seeElement("form[action='$action'][method=get] input[name=email]")
->seeElement("form[action='$action'][method=get] input[name='profile[start_at][start]']")
->seeElement("form[action='$action'][method=get] input[name='profile[start_at][end]']")
->seeElement("form[action='$action'][method=get] input[name='profile[end_at][start]']")
->seeElement("form[action='$action'][method=get] input[name='profile[end_at][end]']");
$urlAll = url('/admin/users?_export_=all');
$urlNew = url('/admin/users/create');
$this->seeInElement("a[href=\"{$urlAll}\"]", 'All')
->seeInElement("a[href=\"{$urlNew}\"]", 'New');
}
protected function seedsTable($count = 100)
{
factory(\Tests\Models\User::class, $count)
->create()
->each(function ($u) {
$u->profile()->save(factory(\Tests\Models\Profile::class)->make());
$u->tags()->saveMany(factory(\Tests\Models\Tag::class, 5)->make());
$u->data = ['json' => ['field' => random_int(0, 50)]];
$u->save();
});
}
public function testGridWithData()
{
$this->seedsTable();
$this->visit('admin/users')
->see('Users');
$this->assertCount(100, UserModel::all());
$this->assertCount(100, ProfileModel::all());
}
public function testGridPagination()
{
$this->seedsTable(65);
$this->visit('admin/users')
->see('Users');
$this->visit('admin/users?page=2');
$this->assertCount(20, $this->crawler()->filter('td a i[class*=fa-edit]'));
$this->visit('admin/users?page=3');
$this->assertCount(20, $this->crawler()->filter('td a i[class*=fa-edit]'));
$this->visit('admin/users?page=4');
$this->assertCount(5, $this->crawler()->filter('td a i[class*=fa-edit]'));
$this->click(1)->seePageIs('admin/users?page=1');
$this->assertCount(20, $this->crawler()->filter('td a i[class*=fa-edit]'));
}
public function testOrderByJson()
{
$this->seedsTable(10);
$this->assertCount(10, UserModel::all());
$this->visit('admin/users?_sort[column]=data.json.field&_sort[type]=desc&_sort[cast]=unsigned');
$jsonTds = $this->crawler->filter('table.table tbody td.column-data-json-field');
$this->assertCount(10, $jsonTds);
$prevValue = PHP_INT_MAX;
foreach ($jsonTds as $jsonTd) {
$currentValue = (int) $jsonTd->nodeValue;
$this->assertTrue($currentValue <= $prevValue);
$prevValue = $currentValue;
}
}
public function testEqualFilter()
{
$this->seedsTable(50);
$this->visit('admin/users')
->see('Users');
$this->assertCount(50, UserModel::all());
$this->assertCount(50, ProfileModel::all());
$id = rand(1, 50);
$user = UserModel::find($id);
$this->visit('admin/users?id='.$id)
->seeInElement('td', $user->username)
->seeInElement('td', $user->email)
->seeInElement('td', $user->mobile)
->seeElement("img[src='{$user->avatar}']")
->seeInElement('td', "{$user->profile->first_name} {$user->profile->last_name}")
->seeInElement('td', $user->postcode)
->seeInElement('td', $user->address)
->seeInElement('td', "{$user->profile->latitude} {$user->profile->longitude}")
->seeInElement('td', $user->color)
->seeInElement('td', $user->start_at)
->seeInElement('td', $user->end_at);
}
public function testLikeFilter()
{
$this->seedsTable(50);
$this->visit('admin/users')
->see('Users');
$this->assertCount(50, UserModel::all());
$this->assertCount(50, ProfileModel::all());
$users = UserModel::where('username', 'like', '%mi%')->get();
$this->visit('admin/users?username=mi');
$this->assertCount($this->crawler()->filter('table tr')->count() - 1, $users);
foreach ($users as $user) {
$this->seeInElement('td', $user->username);
}
}
public function testFilterRelation()
{
$this->seedsTable(50);
$user = UserModel::with('profile')->find(rand(1, 50));
$this->visit('admin/users?email='.$user->email)
->seeInElement('td', $user->username)
->seeInElement('td', $user->email)
->seeInElement('td', $user->mobile)
->seeElement("img[src='{$user->avatar}']")
->seeInElement('td', "{$user->profile->first_name} {$user->profile->last_name}")
->seeInElement('td', $user->postcode)
->seeInElement('td', $user->address)
->seeInElement('td', "{$user->profile->latitude} {$user->profile->longitude}")
->seeInElement('td', $user->color)
->seeInElement('td', $user->start_at)
->seeInElement('td', $user->end_at);
}
public function testDisplayCallback()
{
$this->seedsTable(1);
$user = UserModel::with('profile')->find(1);
$this->visit('admin/users')
->seeInElement('th', 'Column1 not in table')
->seeInElement('th', 'Column2 not in table')
->seeInElement('td', "full name:{$user->profile->first_name} {$user->profile->last_name}")
->seeInElement('td', "{$user->email}#{$user->profile->color}");
}
public function testHasManyRelation()
{
factory(\Tests\Models\User::class, 10)
->create()
->each(function ($u) {
$u->profile()->save(factory(\Tests\Models\Profile::class)->make());
$u->tags()->saveMany(factory(\Tests\Models\Tag::class, 5)->make());
});
$this->visit('admin/users')
->seeElement('td code');
$this->assertCount(50, $this->crawler()->filter('td code'));
}
public function testGridActions()
{
$this->seedsTable(15);
$this->visit('admin/users');
$this->assertCount(15, $this->crawler()->filter('td a i[class*=fa-edit]'));
$this->assertCount(15, $this->crawler()->filter('td a i[class*=fa-trash]'));
}
public function testGridRows()
{
$this->seedsTable(10);
$this->visit('admin/users')
->seeInElement('td a[class*=btn]', 'detail');
$this->assertCount(5, $this->crawler()->filter('td a[class*=btn]'));
}
public function testGridPerPage()
{
$this->seedsTable(98);
$this->visit('admin/users')
->seeElement('select[class*=per-page][name=per-page]')
->seeInElement('select option', 10)
->seeInElement('select option[selected]', 20)
->seeInElement('select option', 30)
->seeInElement('select option', 50)
->seeInElement('select option', 100);
$this->assertEquals('http://localhost:8000/admin/users?per_page=20', $this->crawler()->filter('select option[selected]')->attr('value'));
$perPage = rand(1, 98);
$this->visit('admin/users?per_page='.$perPage)
->seeInElement('select option[selected]', $perPage)
->assertCount($perPage + 1, $this->crawler()->filter('tr'));
}
}
| php | MIT | 67c441eb78ecc5437e59775d89770cd9c2cb1e05 | 2026-01-04T15:05:15.717211Z | false |
z-song/laravel-admin | https://github.com/z-song/laravel-admin/blob/67c441eb78ecc5437e59775d89770cd9c2cb1e05/tests/FileUploadTest.php | tests/FileUploadTest.php | <?php
use Encore\Admin\Auth\Database\Administrator;
use Illuminate\Support\Facades\File;
use Tests\Models\File as FileModel;
class FileUploadTest extends TestCase
{
protected function setUp(): void
{
parent::setUp();
$this->be(Administrator::first(), 'admin');
}
public function testFileUploadPage()
{
$this->visit('admin/files/create')
->see('Files')
->seeInElement('h3[class=box-title]', 'Create')
->seeElement('input[name=file1]')
->seeElement('input[name=file2]')
->seeElement('input[name=file3]')
->seeElement('input[name=file4]')
->seeElement('input[name=file5]')
->seeElement('input[name=file6]')
// ->seeInElement('a[href="/admin/files"]', 'List')
->seeInElement('button[type=reset]', 'Reset')
->seeInElement('button[type=submit]', 'Submit');
}
protected function uploadFiles()
{
return $this->visit('admin/files/create')
->attach(__DIR__.'/AuthTest.php', 'file1')
->attach(__DIR__.'/InstallTest.php', 'file2')
->attach(__DIR__.'/IndexTest.php', 'file3')
->attach(__DIR__.'/LaravelTest.php', 'file4')
->attach(__DIR__.'/routes.php', 'file5')
->attach(__DIR__.'/migrations/2016_11_22_093148_create_test_tables.php', 'file6')
->press('Submit');
}
public function testUploadFile()
{
File::cleanDirectory(public_path('uploads/files'));
$this->uploadFiles()
->seePageIs('admin/files');
$this->assertEquals(FileModel::count(), 1);
$where = [
'file1' => 'files/AuthTest.php',
'file2' => 'files/InstallTest.php',
'file3' => 'files/IndexTest.php',
'file4' => 'files/LaravelTest.php',
'file5' => 'files/routes.php',
'file6' => 'files/2016_11_22_093148_create_test_tables.php',
];
$this->seeInDatabase('test_files', $where);
$files = FileModel::first()->toArray();
foreach (range(1, 6) as $index) {
$this->assertFileExists(public_path('uploads/'.$files['file'.$index]));
}
File::cleanDirectory(public_path('uploads/files'));
}
public function testUpdateFile()
{
File::cleanDirectory(public_path('uploads/files'));
$this->uploadFiles();
$old = FileModel::first();
$this->visit('admin/files/1/edit')
->see('ID')
->see('Created At')
->see('Updated At')
->seeElement('input[name=file1]')
->seeElement('input[name=file2]')
->seeElement('input[name=file3]')
->seeElement('input[name=file4]')
->seeElement('input[name=file5]')
->seeElement('input[name=file6]')
// ->seeInElement('a[href="/admin/files"]', 'List')
->seeInElement('button[type=reset]', 'Reset')
->seeInElement('button[type=submit]', 'Submit');
$this->attach(__DIR__.'/RolesTest.php', 'file3')
->attach(__DIR__.'/MenuTest.php', 'file4')
->attach(__DIR__.'/TestCase.php', 'file5')
->press('Submit');
$new = FileModel::first();
$this->assertEquals($old->id, $new->id);
$this->assertEquals($old->file1, $new->file1);
$this->assertEquals($old->file2, $new->file2);
$this->assertEquals($old->file6, $new->file6);
$this->assertNotEquals($old->file3, $new->file3);
$this->assertNotEquals($old->file4, $new->file4);
$this->assertNotEquals($old->file5, $new->file5);
File::cleanDirectory(public_path('uploads/files'));
}
public function testDeleteFiles()
{
File::cleanDirectory(public_path('uploads/files'));
$this->uploadFiles();
$this->visit('admin/files')
->seeInElement('td', 1);
$files = FileModel::first()->toArray();
$this->delete('admin/files/1')
->dontSeeInDatabase('test_files', ['id' => 1]);
foreach (range(1, 6) as $index) {
$this->assertFileDoesNotExist(public_path('uploads/'.$files['file'.$index]));
}
$this->visit('admin/files')
->seeInElement('td', 'svg');
}
public function testBatchDelete()
{
File::cleanDirectory(public_path('uploads/files'));
$this->uploadFiles();
$this->uploadFiles();
$this->uploadFiles();
$this->visit('admin/files')
->seeInElement('td', 1)
->seeInElement('td', 2)
->seeInElement('td', 3);
$fi = new FilesystemIterator(public_path('uploads/files'), FilesystemIterator::SKIP_DOTS);
$this->assertEquals(iterator_count($fi), 18);
$this->assertEquals(FileModel::count(), 3);
$this->delete('admin/files/1,2,3');
$this->assertEquals(FileModel::count(), 0);
$this->visit('admin/files')
->seeInElement('td', 'svg');
$this->assertEquals(iterator_count($fi), 0);
}
}
| php | MIT | 67c441eb78ecc5437e59775d89770cd9c2cb1e05 | 2026-01-04T15:05:15.717211Z | false |
z-song/laravel-admin | https://github.com/z-song/laravel-admin/blob/67c441eb78ecc5437e59775d89770cd9c2cb1e05/tests/TestCase.php | tests/TestCase.php | <?php
use Illuminate\Filesystem\Filesystem;
use Illuminate\Support\Arr;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
use Laravel\BrowserKitTesting\TestCase as BaseTestCase;
class TestCase extends BaseTestCase
{
protected $baseUrl = 'http://localhost:8000';
/**
* Boots the application.
*
* @return \Illuminate\Foundation\Application
*/
public function createApplication()
{
$app = require __DIR__.'/../vendor/laravel/laravel/bootstrap/app.php';
$app->booting(function () {
$loader = \Illuminate\Foundation\AliasLoader::getInstance();
$loader->alias('Admin', \Encore\Admin\Facades\Admin::class);
});
$app->make('Illuminate\Contracts\Console\Kernel')->bootstrap();
$app->register('Encore\Admin\AdminServiceProvider');
return $app;
}
protected function setUp(): void
{
parent::setUp();
$adminConfig = require __DIR__.'/config/admin.php';
$this->app['config']->set('database.default', env('DB_CONNECTION', 'mysql'));
$this->app['config']->set('database.connections.mysql.host', env('MYSQL_HOST', 'localhost'));
$this->app['config']->set('database.connections.mysql.database', env('MYSQL_DATABASE', 'laravel_admin_test'));
$this->app['config']->set('database.connections.mysql.username', env('MYSQL_USER', 'root'));
$this->app['config']->set('database.connections.mysql.password', env('MYSQL_PASSWORD', ''));
$this->app['config']->set('app.key', 'AckfSECXIvnK5r28GVIWUAxmbBSjTsmF');
$this->app['config']->set('filesystems', require __DIR__.'/config/filesystems.php');
$this->app['config']->set('admin', $adminConfig);
foreach (Arr::dot(Arr::get($adminConfig, 'auth'), 'auth.') as $key => $value) {
$this->app['config']->set($key, $value);
}
$this->artisan('vendor:publish', ['--provider' => 'Encore\Admin\AdminServiceProvider']);
Schema::defaultStringLength(191);
$this->artisan('admin:install');
$this->migrateTestTables();
if (file_exists($routes = admin_path('routes.php'))) {
require $routes;
}
require __DIR__.'/routes.php';
require __DIR__.'/seeds/factory.php';
// \Encore\Admin\Admin::$css = [];
// \Encore\Admin\Admin::$js = [];
// \Encore\Admin\Admin::$script = [];
}
protected function tearDown(): void
{
(new CreateAdminTables())->down();
(new CreateTestTables())->down();
DB::select("delete from `migrations` where `migration` = '2016_01_04_173148_create_admin_tables'");
parent::tearDown();
}
/**
* run package database migrations.
*
* @return void
*/
public function migrateTestTables()
{
$fileSystem = new Filesystem();
$fileSystem->requireOnce(__DIR__.'/migrations/2016_11_22_093148_create_test_tables.php');
(new CreateTestTables())->up();
}
}
| php | MIT | 67c441eb78ecc5437e59775d89770cd9c2cb1e05 | 2026-01-04T15:05:15.717211Z | false |
z-song/laravel-admin | https://github.com/z-song/laravel-admin/blob/67c441eb78ecc5437e59775d89770cd9c2cb1e05/tests/InstallTest.php | tests/InstallTest.php | <?php
class InstallTest extends TestCase
{
public function testInstalledDirectories()
{
$this->assertFileExists(admin_path());
$this->assertFileExists(admin_path('Controllers'));
$this->assertFileExists(admin_path('routes.php'));
$this->assertFileExists(admin_path('bootstrap.php'));
$this->assertFileExists(admin_path('Controllers/HomeController.php'));
$this->assertFileExists(admin_path('Controllers/AuthController.php'));
$this->assertFileExists(admin_path('Controllers/ExampleController.php'));
$this->assertFileExists(config_path('admin.php'));
$this->assertFileExists(public_path('vendor/laravel-admin'));
}
}
| php | MIT | 67c441eb78ecc5437e59775d89770cd9c2cb1e05 | 2026-01-04T15:05:15.717211Z | false |
z-song/laravel-admin | https://github.com/z-song/laravel-admin/blob/67c441eb78ecc5437e59775d89770cd9c2cb1e05/tests/OperationLogTest.php | tests/OperationLogTest.php | <?php
use Encore\Admin\Auth\Database\Administrator;
use Encore\Admin\Auth\Database\OperationLog;
class OperationLogTest extends TestCase
{
protected function setUp(): void
{
parent::setUp();
$this->be(Administrator::first(), 'admin');
}
public function testOperationLogIndex()
{
$this->visit('admin/auth/logs')
->see('Operation log')
->see('List')
->see('GET')
->see('admin/auth/logs');
}
public function testGenerateLogs()
{
$table = config('admin.database.operation_log_table');
$this->visit('admin/auth/menu')
->seePageIs('admin/auth/menu')
->visit('admin/auth/users')
->seePageIs('admin/auth/users')
->visit('admin/auth/permissions')
->seePageIs('admin/auth/permissions')
->visit('admin/auth/roles')
->seePageIs('admin/auth/roles')
->visit('admin/auth/logs')
->seePageIs('admin/auth/logs')
->seeInDatabase($table, ['path' => 'admin/auth/menu', 'method' => 'GET'])
->seeInDatabase($table, ['path' => 'admin/auth/users', 'method' => 'GET'])
->seeInDatabase($table, ['path' => 'admin/auth/permissions', 'method' => 'GET'])
->seeInDatabase($table, ['path' => 'admin/auth/roles', 'method' => 'GET']);
$this->assertEquals(4, OperationLog::count());
}
public function testDeleteLogs()
{
$table = config('admin.database.operation_log_table');
$this->visit('admin/auth/logs')
->seePageIs('admin/auth/logs')
->assertEquals(0, OperationLog::count());
$this->visit('admin/auth/users');
$this->seeInDatabase($table, ['path' => 'admin/auth/users', 'method' => 'GET']);
$this->delete('admin/auth/logs/1')
->assertEquals(0, OperationLog::count());
}
public function testDeleteMultipleLogs()
{
$table = config('admin.database.operation_log_table');
$this->visit('admin/auth/menu')
->visit('admin/auth/users')
->visit('admin/auth/permissions')
->visit('admin/auth/roles')
->seeInDatabase($table, ['path' => 'admin/auth/menu', 'method' => 'GET'])
->seeInDatabase($table, ['path' => 'admin/auth/users', 'method' => 'GET'])
->seeInDatabase($table, ['path' => 'admin/auth/permissions', 'method' => 'GET'])
->seeInDatabase($table, ['path' => 'admin/auth/roles', 'method' => 'GET'])
->assertEquals(4, OperationLog::count());
$this->delete('admin/auth/logs/1,2,3,4')
->notSeeInDatabase($table, ['path' => 'admin/auth/menu', 'method' => 'GET'])
->notSeeInDatabase($table, ['path' => 'admin/auth/users', 'method' => 'GET'])
->notSeeInDatabase($table, ['path' => 'admin/auth/permissions', 'method' => 'GET'])
->notSeeInDatabase($table, ['path' => 'admin/auth/roles', 'method' => 'GET'])
->assertEquals(0, OperationLog::count());
}
}
| php | MIT | 67c441eb78ecc5437e59775d89770cd9c2cb1e05 | 2026-01-04T15:05:15.717211Z | false |
z-song/laravel-admin | https://github.com/z-song/laravel-admin/blob/67c441eb78ecc5437e59775d89770cd9c2cb1e05/tests/MenuTest.php | tests/MenuTest.php | <?php
use Encore\Admin\Auth\Database\Administrator;
use Encore\Admin\Auth\Database\Menu;
class MenuTest extends TestCase
{
protected function setUp(): void
{
parent::setUp();
$this->be(Administrator::first(), 'admin');
}
public function testMenuIndex()
{
$this->visit('admin/auth/menu')
->see('Menu')
->see('Index')
->see('Auth')
->see('Users')
->see('Roles')
->see('Permission')
->see('Menu');
}
public function testAddMenu()
{
$item = ['parent_id' => '0', 'title' => 'Test', 'uri' => 'test'];
$this->visit('admin/auth/menu')
->seePageIs('admin/auth/menu')
->see('Menu')
->submitForm('Submit', $item)
->seePageIs('admin/auth/menu')
->seeInDatabase(config('admin.database.menu_table'), $item)
->assertEquals(8, Menu::count());
// $this->expectException(\Laravel\BrowserKitTesting\HttpException::class);
//
// $this->visit('admin')
// ->see('Test')
// ->click('Test');
}
public function testDeleteMenu()
{
$this->delete('admin/auth/menu/8')
->assertEquals(7, Menu::count());
}
public function testEditMenu()
{
$this->visit('admin/auth/menu/1/edit')
->see('Menu')
->submitForm('Submit', ['title' => 'blablabla'])
->seePageIs('admin/auth/menu')
->seeInDatabase(config('admin.database.menu_table'), ['title' => 'blablabla'])
->assertEquals(7, Menu::count());
}
public function testShowPage()
{
$this->visit('admin/auth/menu/1/edit')
->seePageIs('admin/auth/menu/1/edit');
}
public function testEditMenuParent()
{
$this->expectException(\Laravel\BrowserKitTesting\HttpException::class);
$this->visit('admin/auth/menu/5/edit')
->see('Menu')
->submitForm('Submit', ['parent_id' => 5]);
}
}
| php | MIT | 67c441eb78ecc5437e59775d89770cd9c2cb1e05 | 2026-01-04T15:05:15.717211Z | false |
z-song/laravel-admin | https://github.com/z-song/laravel-admin/blob/67c441eb78ecc5437e59775d89770cd9c2cb1e05/tests/IndexTest.php | tests/IndexTest.php | <?php
use Encore\Admin\Auth\Database\Administrator;
class IndexTest extends TestCase
{
protected function setUp(): void
{
parent::setUp();
$this->be(Administrator::first(), 'admin');
}
public function testIndex()
{
$this->visit('admin/')
->see('Dashboard')
->see('Description...')
->see('Environment')
->see('PHP version')
->see('Laravel version')
->see('Available extensions')
->seeLink('laravel-admin-ext/helpers', 'https://github.com/laravel-admin-extensions/helpers')
->seeLink('laravel-admin-ext/backup', 'https://github.com/laravel-admin-extensions/backup')
->seeLink('laravel-admin-ext/media-manager', 'https://github.com/laravel-admin-extensions/media-manager')
->see('Dependencies')
->see('php')
// ->see('>=7.0.0')
->see('laravel/framework');
}
public function testClickMenu()
{
$this->visit('admin/')
->click('Users')
->seePageis('admin/auth/users')
->click('Roles')
->seePageis('admin/auth/roles')
->click('Permission')
->seePageis('admin/auth/permissions')
->click('Menu')
->seePageis('admin/auth/menu')
->click('Operation log')
->seePageis('admin/auth/logs');
}
}
| php | MIT | 67c441eb78ecc5437e59775d89770cd9c2cb1e05 | 2026-01-04T15:05:15.717211Z | false |
z-song/laravel-admin | https://github.com/z-song/laravel-admin/blob/67c441eb78ecc5437e59775d89770cd9c2cb1e05/tests/routes.php | tests/routes.php | <?php
Route::group([
'prefix' => config('admin.route.prefix'),
'namespace' => 'Tests\Controllers',
'middleware' => ['web', 'admin'],
], function ($router) {
$router->resource('images', ImageController::class);
$router->resource('multiple-images', MultipleImageController::class);
$router->resource('files', FileController::class);
$router->resource('users', UserController::class);
});
| php | MIT | 67c441eb78ecc5437e59775d89770cd9c2cb1e05 | 2026-01-04T15:05:15.717211Z | false |
z-song/laravel-admin | https://github.com/z-song/laravel-admin/blob/67c441eb78ecc5437e59775d89770cd9c2cb1e05/tests/LaravelTest.php | tests/LaravelTest.php | <?php
class LaravelTest extends TestCase
{
public function testLaravel()
{
$this->visit('/')
->assertResponseStatus(200)
->see('Laravel');
}
}
| php | MIT | 67c441eb78ecc5437e59775d89770cd9c2cb1e05 | 2026-01-04T15:05:15.717211Z | false |
z-song/laravel-admin | https://github.com/z-song/laravel-admin/blob/67c441eb78ecc5437e59775d89770cd9c2cb1e05/tests/UserSettingTest.php | tests/UserSettingTest.php | <?php
use Encore\Admin\Auth\Database\Administrator;
use Illuminate\Support\Facades\File;
class UserSettingTest extends TestCase
{
protected function setUp(): void
{
parent::setUp();
$this->be(Administrator::first(), 'admin');
}
public function testVisitSettingPage()
{
$this->visit('admin/auth/setting')
->see('User setting')
->see('Username')
->see('Name')
->see('Avatar')
->see('Password')
->see('Password confirmation');
$this->seeElement('input[value=Administrator]')
->seeInElement('.box-body', 'administrator');
}
public function testUpdateName()
{
$data = [
'name' => 'tester',
];
$this->visit('admin/auth/setting')
->submitForm('Submit', $data)
->seePageIs('admin/auth/setting');
$this->seeInDatabase('admin_users', ['name' => $data['name']]);
}
public function testUpdateAvatar()
{
File::cleanDirectory(public_path('uploads/images'));
$this->visit('admin/auth/setting')
->attach(__DIR__.'/assets/test.jpg', 'avatar')
->press('Submit')
->seePageIs('admin/auth/setting');
$avatar = Administrator::first()->avatar;
$this->assertEquals('http://localhost:8000/uploads/images/test.jpg', $avatar);
}
public function testUpdatePasswordConfirmation()
{
$data = [
'password' => '123456',
'password_confirmation' => '123',
];
$this->visit('admin/auth/setting')
->submitForm('Submit', $data)
->seePageIs('admin/auth/setting')
->see('The Password confirmation does not match.');
}
public function testUpdatePassword()
{
$data = [
'password' => '123456',
'password_confirmation' => '123456',
];
$this->visit('admin/auth/setting')
->submitForm('Submit', $data)
->seePageIs('admin/auth/setting');
$this->assertTrue(app('hash')->check($data['password'], Administrator::first()->makeVisible('password')->password));
$this->visit('admin/auth/logout')
->seePageIs('admin/auth/login')
->dontSeeIsAuthenticated('admin');
$credentials = ['username' => 'admin', 'password' => '123456'];
$this->visit('admin/auth/login')
->see('login')
->submitForm('Login', $credentials)
->see('dashboard')
->seeCredentials($credentials, 'admin')
->seeIsAuthenticated('admin')
->seePageIs('admin');
}
}
| php | MIT | 67c441eb78ecc5437e59775d89770cd9c2cb1e05 | 2026-01-04T15:05:15.717211Z | false |
z-song/laravel-admin | https://github.com/z-song/laravel-admin/blob/67c441eb78ecc5437e59775d89770cd9c2cb1e05/tests/UserFormTest.php | tests/UserFormTest.php | <?php
use Encore\Admin\Auth\Database\Administrator;
use Tests\Models\User as UserModel;
class UserFormTest extends TestCase
{
protected function setUp(): void
{
parent::setUp();
$this->be(Administrator::first(), 'admin');
}
public function testCreatePage()
{
$this->visit('admin/users/create')
->seeElement('input[type=text][name=username]')
->seeElement('input[type=email][name=email]')
->seeElement('input[type=text][name=mobile]')
->seeElement('input[type=file][name=avatar]')
->seeElement('hr')
->seeElement("input[type=text][name='profile[first_name]']")
->seeElement("input[type=text][name='profile[last_name]']")
->seeElement("input[type=text][name='profile[postcode]']")
->seeElement("textarea[name='profile[address]'][rows=15]")
->seeElement("input[type=hidden][name='profile[latitude]']")
->seeElement("input[type=hidden][name='profile[longitude]']")
->seeElement("input[type=text][name='profile[color]']")
->seeElement("input[type=text][name='profile[start_at]']")
->seeElement("input[type=text][name='profile[end_at]']")
->seeElement('span[class=help-block] i[class*=fa-info-circle]')
->seeInElement('span[class=help-block]', 'Please input your postcode')
->seeElement('span[class=help-block] i[class*=fa-image]')
->seeInElement('span[class=help-block]', '上传头像')
->seeElement("select[name='tags[]'][multiple=multiple]")
->seeInElement('a[html-field]', 'html...');
}
public function testSubmitForm()
{
$data = [
'username' => 'John Doe',
'email' => 'hello@world.com',
'mobile' => '13421234123',
'password' => '123456',
'password_confirmation' => '123456',
//"avatar" => "test.jpg",
'profile' => [
'first_name' => 'John',
'last_name' => 'Doe',
'postcode' => '123456',
'address' => 'Jinshajiang RD',
'latitude' => '131.2123123456',
'longitude' => '21.342123456',
'color' => '#ffffff',
'start_at' => date('Y-m-d H:i:s', time()),
'end_at' => date('Y-m-d H:i:s', time()),
],
];
$this->visit('admin/users/create')
->attach(__DIR__.'/assets/test.jpg', 'avatar')
->submitForm('Submit', $data)
->seePageIs('admin/users')
->seeInElement('td', 1)
->seeInElement('td', $data['username'])
->seeInElement('td', $data['email'])
->seeInElement('td', $data['mobile'])
->seeInElement('td', "{$data['profile']['first_name']} {$data['profile']['last_name']}")
->seeElement('td img')
->seeInElement('td', $data['profile']['postcode'])
->seeInElement('td', $data['profile']['address'])
->seeInElement('td', "{$data['profile']['latitude']} {$data['profile']['longitude']}")
->seeInElement('td', $data['profile']['color'])
->seeInElement('td', $data['profile']['start_at'])
->seeInElement('td', $data['profile']['end_at']);
$this->assertCount(1, UserModel::all());
$this->seeInDatabase('test_users', ['username' => $data['username']]);
$this->seeInDatabase('test_users', ['email' => $data['email']]);
$this->seeInDatabase('test_users', ['mobile' => $data['mobile']]);
$this->seeInDatabase('test_users', ['password' => $data['password']]);
$this->seeInDatabase('test_user_profiles', ['first_name' => $data['profile']['first_name']]);
$this->seeInDatabase('test_user_profiles', ['last_name' => $data['profile']['last_name']]);
$this->seeInDatabase('test_user_profiles', ['postcode' => $data['profile']['postcode']]);
$this->seeInDatabase('test_user_profiles', ['address' => $data['profile']['address']]);
$this->seeInDatabase('test_user_profiles', ['latitude' => $data['profile']['latitude']]);
$this->seeInDatabase('test_user_profiles', ['longitude' => $data['profile']['longitude']]);
$this->seeInDatabase('test_user_profiles', ['color' => $data['profile']['color']]);
$this->seeInDatabase('test_user_profiles', ['start_at' => $data['profile']['start_at']]);
$this->seeInDatabase('test_user_profiles', ['end_at' => $data['profile']['end_at']]);
$avatar = UserModel::first()->avatar;
$this->assertFileExists(public_path('uploads/'.$avatar));
}
protected function seedsTable($count = 100)
{
factory(\Tests\Models\User::class, $count)
->create()
->each(function ($u) {
$u->profile()->save(factory(\Tests\Models\Profile::class)->make());
$u->tags()->saveMany(factory(\Tests\Models\Tag::class, 5)->make());
});
}
public function testEditForm()
{
$this->seedsTable(10);
$id = rand(1, 10);
$user = UserModel::with('profile')->find($id);
$this->visit("admin/users/$id/edit")
->seeElement("input[type=text][name=username][value='{$user->username}']")
->seeElement("input[type=email][name=email][value='{$user->email}']")
->seeElement("input[type=text][name=mobile][value='{$user->mobile}']")
->seeElement('hr')
->seeElement("input[type=text][name='profile[first_name]'][value='{$user->profile->first_name}']")
->seeElement("input[type=text][name='profile[last_name]'][value='{$user->profile->last_name}']")
->seeElement("input[type=text][name='profile[postcode]'][value='{$user->profile->postcode}']")
->seeInElement("textarea[name='profile[address]']", $user->profile->address)
->seeElement("input[type=hidden][name='profile[latitude]'][value='{$user->profile->latitude}']")
->seeElement("input[type=hidden][name='profile[longitude]'][value='{$user->profile->longitude}']")
->seeElement("input[type=text][name='profile[color]'][value='{$user->profile->color}']")
->seeElement("input[type=text][name='profile[start_at]'][value='{$user->profile->start_at}']")
->seeElement("input[type=text][name='profile[end_at]'][value='{$user->profile->end_at}']")
->seeElement("select[name='tags[]'][multiple=multiple]");
$this->assertCount(50, $this->crawler()->filter("select[name='tags[]'] option"));
$this->assertCount(5, $this->crawler()->filter("select[name='tags[]'] option[selected]"));
}
public function testUpdateForm()
{
$this->seedsTable(10);
$id = rand(1, 10);
$this->visit("admin/users/$id/edit")
->type('hello world', 'username')
->type('123', 'password')
->type('123', 'password_confirmation')
->press('Submit')
->seePageIs('admin/users')
->seeInDatabase('test_users', ['username' => 'hello world']);
$user = UserModel::with('profile')->find($id);
$this->assertEquals($user->username, 'hello world');
}
public function testUpdateFormWithRule()
{
$this->seedsTable(10);
$id = rand(1, 10);
$this->visit("admin/users/$id/edit")
->type('', 'email')
->press('Submit')
->seePageIs("admin/users/$id/edit")
->see('The email field is required');
$this->type('xxaxx', 'email')
->press('Submit')
->seePageIs("admin/users/$id/edit")
->see('The email must be a valid email address.');
$this->visit("admin/users/$id/edit")
->type('123', 'password')
->type('1234', 'password_confirmation')
->press('Submit')
->seePageIs("admin/users/$id/edit")
->see('The Password confirmation does not match.');
$this->type('xx@xx.xx', 'email')
->type('123', 'password')
->type('123', 'password_confirmation')
->press('Submit')
->seePageIs('admin/users')
->seeInDatabase('test_users', ['email' => 'xx@xx.xx']);
}
public function testFormHeader()
{
$this->seedsTable(1);
$this->visit('admin/users/1/edit')
->seeInElement('a[class*=btn-danger]', 'Delete')
->seeInElement('a[class*=btn-default]', 'List')
->seeInElement('a[class*=btn-primary]', 'View');
}
public function testFormFooter()
{
$this->seedsTable(1);
$this->visit('admin/users/1/edit')
->seeElement('input[type=checkbox][value=1]')
->seeElement('input[type=checkbox][value=2]');
}
}
| php | MIT | 67c441eb78ecc5437e59775d89770cd9c2cb1e05 | 2026-01-04T15:05:15.717211Z | false |
z-song/laravel-admin | https://github.com/z-song/laravel-admin/blob/67c441eb78ecc5437e59775d89770cd9c2cb1e05/tests/ModelTreeTest.php | tests/ModelTreeTest.php | <?php
use Tests\Models\Tree;
class ModelTreeTest extends TestCase
{
protected function setUp(): void
{
parent::setUp();
}
public function testSelectOptions()
{
$rootText = 'Root Text';
$options = Tree::selectOptions(function ($query) {
return $query->where('uri', '');
}, $rootText);
$count = Tree::query()->where('uri', '')->count();
$this->assertEquals(array_shift($options), $rootText);
$this->assertEquals(count($options), $count);
}
}
| php | MIT | 67c441eb78ecc5437e59775d89770cd9c2cb1e05 | 2026-01-04T15:05:15.717211Z | false |
z-song/laravel-admin | https://github.com/z-song/laravel-admin/blob/67c441eb78ecc5437e59775d89770cd9c2cb1e05/tests/AuthTest.php | tests/AuthTest.php | <?php
class AuthTest extends TestCase
{
public function testLoginPage()
{
$this->visit('admin/auth/login')
->see('login');
}
public function testVisitWithoutLogin()
{
$this->visit('admin')
->dontSeeIsAuthenticated('admin')
->seePageIs('admin/auth/login');
}
public function testLogin()
{
$credentials = ['username' => 'admin', 'password' => 'admin'];
$this->visit('admin/auth/login')
->see('login')
->submitForm('Login', $credentials)
->see('dashboard')
->seeCredentials($credentials, 'admin')
->seeIsAuthenticated('admin')
->seePageIs('admin')
->see('Dashboard')
->see('Description...')
->see('Environment')
->see('PHP version')
->see('Laravel version')
->see('Available extensions')
->seeLink('laravel-admin-ext/helpers', 'https://github.com/laravel-admin-extensions/helpers')
->seeLink('laravel-admin-ext/backup', 'https://github.com/laravel-admin-extensions/backup')
->seeLink('laravel-admin-ext/media-manager', 'https://github.com/laravel-admin-extensions/media-manager')
->see('Dependencies')
->see('php')
// ->see('>=7.0.0')
->see('laravel/framework');
$this
->see('<span>Admin</span>')
->see('<span>Users</span>')
->see('<span>Roles</span>')
->see('<span>Permission</span>')
->see('<span>Operation log</span>')
->see('<span>Menu</span>');
}
public function testLogout()
{
$this->visit('admin/auth/logout')
->seePageIs('admin/auth/login')
->dontSeeIsAuthenticated('admin');
}
}
| php | MIT | 67c441eb78ecc5437e59775d89770cd9c2cb1e05 | 2026-01-04T15:05:15.717211Z | false |
z-song/laravel-admin | https://github.com/z-song/laravel-admin/blob/67c441eb78ecc5437e59775d89770cd9c2cb1e05/tests/seeds/UserTableSeeder.php | tests/seeds/UserTableSeeder.php | <?php
namespace Tests\Seeds;
use Illuminate\Database\Seeder;
class UserTableSeeder extends Seeder
{
public function run()
{
factory(\Tests\Models\User::class, 50)
->create()
->each(function ($u) {
$u->profile()->save(factory(\Tests\Models\Profile::class)->make());
$u->tags()->saveMany(factory(\Tests\Models\Tag::class, 5)->make());
$u->data = ['json' => ['field' => random_int(0, 50)]];
});
}
}
| php | MIT | 67c441eb78ecc5437e59775d89770cd9c2cb1e05 | 2026-01-04T15:05:15.717211Z | false |
z-song/laravel-admin | https://github.com/z-song/laravel-admin/blob/67c441eb78ecc5437e59775d89770cd9c2cb1e05/tests/seeds/factory.php | tests/seeds/factory.php | <?php
use Faker\Generator as Faker;
use Illuminate\Database\Eloquent\Factory;
$factory = app(Factory::class);
$factory->define(Tests\Models\User::class, function (Faker $faker) {
return [
'username' => $faker->userName,
'email' => $faker->email,
'mobile' => $faker->phoneNumber,
'avatar' => $faker->imageUrl(),
'password' => '$2y$10$U2WSLymU6eKJclK06glaF.Gj3Sw/ieDE3n7mJYjKEgDh4nzUiSESO', // bcrypt(123456)
];
});
$factory->define(Tests\Models\Profile::class, function (Faker $faker) {
return [
'first_name' => $faker->firstName,
'last_name' => $faker->lastName,
'postcode' => $faker->postcode,
'address' => $faker->address,
'latitude' => $faker->latitude,
'longitude' => $faker->longitude,
'color' => $faker->hexColor,
'start_at' => $faker->dateTime,
'end_at' => $faker->dateTime,
];
});
$factory->define(Tests\Models\Tag::class, function (Faker $faker) {
return [
'name' => $faker->word,
];
});
| php | MIT | 67c441eb78ecc5437e59775d89770cd9c2cb1e05 | 2026-01-04T15:05:15.717211Z | false |
z-song/laravel-admin | https://github.com/z-song/laravel-admin/blob/67c441eb78ecc5437e59775d89770cd9c2cb1e05/tests/controllers/ImageController.php | tests/controllers/ImageController.php | <?php
namespace Tests\Controllers;
use Encore\Admin\Controllers\AdminController;
use Encore\Admin\Form;
use Encore\Admin\Grid;
use Tests\Models\Image;
class ImageController extends AdminController
{
protected $title = 'Images';
/**
* Make a grid builder.
*
* @return Grid
*/
protected function grid()
{
$grid = new Grid(new Image());
$grid->id('ID')->sortable();
$grid->created_at();
$grid->updated_at();
$grid->disableFilter();
return $grid;
}
/**
* Make a form builder.
*
* @return Form
*/
protected function form()
{
$form = new Form(new Image());
$form->display('id', 'ID');
$form->image('image1');
$form->image('image2')->rotate(90);
$form->image('image3')->flip('v');
$form->image('image4')->move(null, 'renamed.jpeg');
$form->image('image5')->name(function ($file) {
return 'asdasdasdasdasd.'.$file->guessExtension();
});
$form->image('image6')->uniqueName();
$form->display('created_at', 'Created At');
$form->display('updated_at', 'Updated At');
return $form;
}
}
| php | MIT | 67c441eb78ecc5437e59775d89770cd9c2cb1e05 | 2026-01-04T15:05:15.717211Z | false |
z-song/laravel-admin | https://github.com/z-song/laravel-admin/blob/67c441eb78ecc5437e59775d89770cd9c2cb1e05/tests/controllers/UserController.php | tests/controllers/UserController.php | <?php
namespace Tests\Controllers;
use Encore\Admin\Controllers\AdminController;
use Encore\Admin\Form;
use Encore\Admin\Grid;
use Tests\Models\Tag;
use Tests\Models\User;
class UserController extends AdminController
{
protected $title = 'Users';
/**
* Make a grid builder.
*
* @return Grid
*/
protected function grid()
{
$grid = new Grid(new User());
$grid->id('ID')->sortable();
$grid->username();
$grid->email();
$grid->mobile();
$grid->full_name();
$grid->avatar()->display(function ($avatar) {
return "<img src='{$avatar}' />";
});
$grid->profile()->postcode('Post code');
$grid->profile()->address();
$grid->position('Position');
$grid->column('profile.color');
$grid->profile()->start_at('开始时间');
$grid->profile()->end_at('结束时间');
$grid->column('data->json->field', 'Json Field');
$grid->column('column1_not_in_table')->display(function () {
return 'full name:'.$this->full_name;
});
$grid->column('column2_not_in_table')->display(function () {
return $this->email.'#'.$this->profile['color'];
});
$grid->tags()->display(function ($tags) {
$tags = collect($tags)->map(function ($tag) {
return "<code>{$tag['name']}</code>";
})->toArray();
return implode('', $tags);
});
$grid->created_at();
$grid->updated_at();
$grid->filter(function ($filter) {
$filter->like('username');
$filter->like('email');
$filter->like('profile.postcode');
$filter->between('profile.start_at')->datetime();
$filter->between('profile.end_at')->datetime();
});
$grid->actions(function ($actions) {
if ($actions->getKey() % 2 == 0) {
$actions->append('<a href="/" class="btn btn-xs btn-danger">detail</a>');
}
});
return $grid;
}
/**
* Make a form builder.
*
* @return Form
*/
protected function form()
{
Form::extend('map', Form\Field\Map::class);
Form::extend('editor', Form\Field\Editor::class);
$form = new Form(new User());
$form->display('id', 'ID');
$form->text('username');
$form->email('email')->rules('required');
$form->mobile('mobile');
$form->image('avatar')->help('上传头像', 'fa-image');
$form->ignore(['password_confirmation']);
$form->password('password')->rules('confirmed');
$form->password('password_confirmation');
$form->divider();
$form->text('profile.first_name');
$form->text('profile.last_name');
$form->text('profile.postcode')->help('Please input your postcode');
$form->textarea('profile.address')->rows(15);
$form->map('profile.latitude', 'profile.longitude', 'Position');
$form->color('profile.color');
$form->datetime('profile.start_at');
$form->datetime('profile.end_at');
$form->multipleSelect('tags', 'Tags')->options(Tag::all()->pluck('name', 'id')); //->rules('max:10|min:3');
$form->display('created_at', 'Created At');
$form->display('updated_at', 'Updated At');
$form->html('<a html-field>html...</a>');
return $form;
}
}
| php | MIT | 67c441eb78ecc5437e59775d89770cd9c2cb1e05 | 2026-01-04T15:05:15.717211Z | false |
z-song/laravel-admin | https://github.com/z-song/laravel-admin/blob/67c441eb78ecc5437e59775d89770cd9c2cb1e05/tests/controllers/FileController.php | tests/controllers/FileController.php | <?php
namespace Tests\Controllers;
use Encore\Admin\Controllers\AdminController;
use Encore\Admin\Form;
use Encore\Admin\Grid;
use Tests\Models\File;
class FileController extends AdminController
{
protected $title = 'Files';
/**
* Make a grid builder.
*
* @return Grid
*/
protected function grid()
{
$grid = new Grid(new File());
$grid->id('ID')->sortable();
$grid->created_at();
$grid->updated_at();
return $grid;
}
/**
* Make a form builder.
*
* @return Form
*/
protected function form()
{
$form = new Form(new File());
$form->display('id', 'ID');
$form->file('file1');
$form->file('file2');
$form->file('file3');
$form->file('file4');
$form->file('file5');
$form->file('file6');
$form->display('created_at', 'Created At');
$form->display('updated_at', 'Updated At');
return $form;
}
}
| php | MIT | 67c441eb78ecc5437e59775d89770cd9c2cb1e05 | 2026-01-04T15:05:15.717211Z | false |
z-song/laravel-admin | https://github.com/z-song/laravel-admin/blob/67c441eb78ecc5437e59775d89770cd9c2cb1e05/tests/controllers/MultipleImageController.php | tests/controllers/MultipleImageController.php | <?php
namespace Tests\Controllers;
use Encore\Admin\Controllers\AdminController;
use Encore\Admin\Form;
use Encore\Admin\Grid;
use Tests\Models\MultipleImage;
class MultipleImageController extends AdminController
{
protected $title = 'Images';
/**
* Make a grid builder.
*
* @return Grid
*/
protected function grid()
{
$grid = new Grid(new MultipleImage());
$grid->id('ID')->sortable();
$grid->created_at();
$grid->updated_at();
$grid->disableFilter();
return $grid;
}
/**
* Make a form builder.
*
* @return Form
*/
protected function form()
{
$form = new Form(new MultipleImage());
$form->display('id', 'ID');
$form->multipleImage('pictures');
$form->display('created_at', 'Created At');
$form->display('updated_at', 'Updated At');
return $form;
}
}
| php | MIT | 67c441eb78ecc5437e59775d89770cd9c2cb1e05 | 2026-01-04T15:05:15.717211Z | false |
z-song/laravel-admin | https://github.com/z-song/laravel-admin/blob/67c441eb78ecc5437e59775d89770cd9c2cb1e05/tests/models/Tag.php | tests/models/Tag.php | <?php
namespace Tests\Models;
use Illuminate\Database\Eloquent\Model;
class Tag extends Model
{
protected $table = 'test_tags';
public function users()
{
return $this->belongsToMany(User::class, 'test_user_tags', 'tag_id', 'user_id');
}
}
| php | MIT | 67c441eb78ecc5437e59775d89770cd9c2cb1e05 | 2026-01-04T15:05:15.717211Z | false |
z-song/laravel-admin | https://github.com/z-song/laravel-admin/blob/67c441eb78ecc5437e59775d89770cd9c2cb1e05/tests/models/Profile.php | tests/models/Profile.php | <?php
namespace Tests\Models;
use Illuminate\Database\Eloquent\Model;
class Profile extends Model
{
protected $table = 'test_user_profiles';
public function user()
{
return $this->belongsTo(User::class, 'user_id');
}
}
| php | MIT | 67c441eb78ecc5437e59775d89770cd9c2cb1e05 | 2026-01-04T15:05:15.717211Z | false |
z-song/laravel-admin | https://github.com/z-song/laravel-admin/blob/67c441eb78ecc5437e59775d89770cd9c2cb1e05/tests/models/User.php | tests/models/User.php | <?php
namespace Tests\Models;
use Illuminate\Database\Eloquent\Model;
class User extends Model
{
protected $table = 'test_users';
protected $appends = ['full_name', 'position'];
protected $casts = ['data' => 'array'];
public function profile()
{
return $this->hasOne(Profile::class, 'user_id');
}
public function getFullNameAttribute()
{
return "{$this->profile['first_name']} {$this->profile['last_name']}";
}
public function getPositionAttribute()
{
return "{$this->profile->latitude} {$this->profile->longitude}";
}
public function tags()
{
return $this->belongsToMany(Tag::class, 'test_user_tags', 'user_id', 'tag_id');
}
}
| php | MIT | 67c441eb78ecc5437e59775d89770cd9c2cb1e05 | 2026-01-04T15:05:15.717211Z | false |
z-song/laravel-admin | https://github.com/z-song/laravel-admin/blob/67c441eb78ecc5437e59775d89770cd9c2cb1e05/tests/models/Image.php | tests/models/Image.php | <?php
namespace Tests\Models;
use Illuminate\Database\Eloquent\Model;
class Image extends Model
{
protected $table = 'test_images';
}
| php | MIT | 67c441eb78ecc5437e59775d89770cd9c2cb1e05 | 2026-01-04T15:05:15.717211Z | false |
z-song/laravel-admin | https://github.com/z-song/laravel-admin/blob/67c441eb78ecc5437e59775d89770cd9c2cb1e05/tests/models/Tree.php | tests/models/Tree.php | <?php
namespace Tests\Models;
use Encore\Admin\Traits\ModelTree;
use Illuminate\Database\Eloquent\Model;
class Tree extends Model
{
use ModelTree;
/**
* Create a new Eloquent model instance.
*
* @param array $attributes
*/
public function __construct(array $attributes = [])
{
$connection = config('admin.database.connection') ?: config('database.default');
$this->setConnection($connection);
$this->setTable(config('admin.database.menu_table'));
parent::__construct($attributes);
}
}
| php | MIT | 67c441eb78ecc5437e59775d89770cd9c2cb1e05 | 2026-01-04T15:05:15.717211Z | false |
z-song/laravel-admin | https://github.com/z-song/laravel-admin/blob/67c441eb78ecc5437e59775d89770cd9c2cb1e05/tests/models/File.php | tests/models/File.php | <?php
namespace Tests\Models;
use Illuminate\Database\Eloquent\Model;
class File extends Model
{
protected $table = 'test_files';
}
| php | MIT | 67c441eb78ecc5437e59775d89770cd9c2cb1e05 | 2026-01-04T15:05:15.717211Z | false |
z-song/laravel-admin | https://github.com/z-song/laravel-admin/blob/67c441eb78ecc5437e59775d89770cd9c2cb1e05/tests/models/MultipleImage.php | tests/models/MultipleImage.php | <?php
namespace Tests\Models;
use Illuminate\Database\Eloquent\Model;
class MultipleImage extends Model
{
protected $table = 'test_multiple_images';
public function setPicturesAttribute($pictures)
{
if (is_array($pictures)) {
$this->attributes['pictures'] = json_encode($pictures);
}
}
public function getPicturesAttribute($pictures)
{
return json_decode($pictures, true) ?: [];
}
}
| php | MIT | 67c441eb78ecc5437e59775d89770cd9c2cb1e05 | 2026-01-04T15:05:15.717211Z | false |
z-song/laravel-admin | https://github.com/z-song/laravel-admin/blob/67c441eb78ecc5437e59775d89770cd9c2cb1e05/tests/migrations/2016_11_22_093148_create_test_tables.php | tests/migrations/2016_11_22_093148_create_test_tables.php | <?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class CreateTestTables extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('test_images', function (Blueprint $table) {
$table->increments('id');
$table->string('image1');
$table->string('image2');
$table->string('image3');
$table->string('image4');
$table->string('image5');
$table->string('image6');
$table->timestamps();
});
Schema::create('test_multiple_images', function (Blueprint $table) {
$table->increments('id');
$table->text('pictures');
$table->timestamps();
});
Schema::create('test_files', function (Blueprint $table) {
$table->increments('id');
$table->string('file1');
$table->string('file2');
$table->string('file3');
$table->string('file4');
$table->string('file5');
$table->string('file6');
$table->timestamps();
});
Schema::create('test_users', function (Blueprint $table) {
$table->increments('id');
$table->string('username');
$table->string('email');
$table->string('mobile')->nullable();
$table->string('avatar')->nullable();
$table->string('password');
$table->json('data')->nullable();
$table->timestamps();
});
Schema::create('test_user_profiles', function (Blueprint $table) {
$table->increments('id');
$table->string('user_id');
$table->string('first_name')->nullable();
$table->string('last_name')->nullable();
$table->string('postcode')->nullable();
$table->string('address')->nullable();
$table->string('latitude')->nullable();
$table->string('longitude')->nullable();
$table->string('color')->nullable();
$table->timestamp('start_at')->nullable();
$table->timestamp('end_at')->nullable();
$table->timestamps();
});
Schema::create('test_tags', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->timestamps();
});
Schema::create('test_user_tags', function (Blueprint $table) {
$table->integer('user_id');
$table->integer('tag_id');
$table->index(['user_id', 'tag_id']);
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('test_images');
Schema::dropIfExists('test_multiple_images');
Schema::dropIfExists('test_files');
Schema::dropIfExists('test_users');
Schema::dropIfExists('test_user_profiles');
Schema::dropIfExists('test_tags');
Schema::dropIfExists('test_user_tags');
}
}
| php | MIT | 67c441eb78ecc5437e59775d89770cd9c2cb1e05 | 2026-01-04T15:05:15.717211Z | false |
z-song/laravel-admin | https://github.com/z-song/laravel-admin/blob/67c441eb78ecc5437e59775d89770cd9c2cb1e05/tests/config/admin.php | tests/config/admin.php | <?php
return [
/*
* Laravel-admin name.
*/
'name' => 'Laravel-admin',
/*
* Logo in admin panel header.
*/
'logo' => '<b>Laravel</b> admin',
/*
* Mini-logo in admin panel header.
*/
'logo-mini' => '<b>La</b>',
/*
* Route configuration.
*/
'route' => [
'prefix' => 'admin',
'namespace' => 'App\\Admin\\Controllers',
'middleware' => ['web', 'admin'],
],
/*
* Laravel-admin install directory.
*/
'directory' => app_path('Admin'),
/*
* Laravel-admin html title.
*/
'title' => 'Admin',
/*
* Use `https`.
*/
'secure' => false,
/*
* Laravel-admin auth setting.
*/
'auth' => [
'guards' => [
'admin' => [
'driver' => 'session',
'provider' => 'admin',
],
],
'providers' => [
'admin' => [
'driver' => 'eloquent',
'model' => Encore\Admin\Auth\Database\Administrator::class,
],
],
],
/*
* Laravel-admin upload setting.
*/
'upload' => [
'disk' => 'admin',
'directory' => [
'image' => 'images',
'file' => 'files',
],
],
/*
* Laravel-admin database setting.
*/
'database' => [
// Database connection for following tables.
'connection' => '',
// User tables and model.
'users_table' => 'admin_users',
'users_model' => Encore\Admin\Auth\Database\Administrator::class,
// Role table and model.
'roles_table' => 'admin_roles',
'roles_model' => Encore\Admin\Auth\Database\Role::class,
// Permission table and model.
'permissions_table' => 'admin_permissions',
'permissions_model' => Encore\Admin\Auth\Database\Permission::class,
// Menu table and model.
'menu_table' => 'admin_menu',
'menu_model' => Encore\Admin\Auth\Database\Menu::class,
// Pivot table for table above.
'operation_log_table' => 'admin_operation_log',
'user_permissions_table' => 'admin_user_permissions',
'role_users_table' => 'admin_role_users',
'role_permissions_table' => 'admin_role_permissions',
'role_menu_table' => 'admin_role_menu',
],
/*
* By setting this option to open or close operation log in laravel-admin.
*/
'operation_log' => [
'enable' => true,
/*
* Routes that will not log to database.
*
* All method to path like: admin/auth/logs
* or specific method to path like: get:admin/auth/logs
*/
'except' => [
'admin/auth/logs*',
],
],
/*
* @see https://adminlte.io/docs/2.4/layout
*/
'skin' => 'skin-blue-light',
/*
|---------------------------------------------------------|
|LAYOUT OPTIONS | fixed |
| | layout-boxed |
| | layout-top-nav |
| | sidebar-collapse |
| | sidebar-mini |
|---------------------------------------------------------|
*/
'layout' => ['sidebar-mini', 'sidebar-collapse'],
/*
* Version displayed in footer.
*/
'version' => '1.5.x-dev',
/*
* Settings for extensions.
*/
'extensions' => [
],
];
| php | MIT | 67c441eb78ecc5437e59775d89770cd9c2cb1e05 | 2026-01-04T15:05:15.717211Z | false |
z-song/laravel-admin | https://github.com/z-song/laravel-admin/blob/67c441eb78ecc5437e59775d89770cd9c2cb1e05/tests/config/filesystems.php | tests/config/filesystems.php | <?php
return [
/*
|--------------------------------------------------------------------------
| Default Filesystem Disk
|--------------------------------------------------------------------------
|
| Here you may specify the default filesystem disk that should be used
| by the framework. A "local" driver, as well as a variety of cloud
| based drivers are available for your choosing. Just store away!
|
| Supported: "local", "ftp", "s3", "rackspace"
|
*/
'default' => 'public',
/*
|--------------------------------------------------------------------------
| Default Cloud Filesystem Disk
|--------------------------------------------------------------------------
|
| Many applications store files both locally and in the cloud. For this
| reason, you may specify a default "cloud" driver here. This driver
| will be bound as the Cloud disk implementation in the container.
|
*/
'cloud' => 's3',
/*
|--------------------------------------------------------------------------
| Filesystem Disks
|--------------------------------------------------------------------------
|
| Here you may configure as many filesystem "disks" as you wish, and you
| may even configure multiple disks of the same driver. Defaults have
| been setup for each driver as an example of the required options.
|
*/
'disks' => [
'local' => [
'driver' => 'local',
'root' => storage_path('app'),
],
'public' => [
'driver' => 'local',
'root' => storage_path('app/public'),
'visibility' => 'public',
],
's3' => [
'driver' => 's3',
'key' => 'your-key',
'secret' => 'your-secret',
'region' => 'your-region',
'bucket' => 'your-bucket',
],
'admin' => [
'driver' => 'local',
'root' => public_path('uploads'),
'visibility' => 'public',
'url' => 'http://localhost:8000/uploads/',
],
'qiniu' => [
'driver' => 'qiniu',
'domains' => [
'default' => 'of8kfibjo.bkt.clouddn.com', //你的七牛域名
'https' => 'dn-yourdomain.qbox.me', //你的HTTPS域名
'custom' => 'static.abc.com', //你的自定义域名
],
'access_key' => 'tIyz5h5IDT1-PQS22iRrI4dCBEktWj76O-ls856K', //AccessKey
'secret_key' => 'TCU2GuSlbzxKgnixYO_-pdo4odbXttm1RNNvEwSD', //SecretKey
'bucket' => 'laravel', //Bucket名字
'notify_url' => '', //持久化处理回调地址
],
'aliyun' => [
'driver' => 'oss',
'access_id' => 'LTAIsOQNIDQN78Jr',
'access_key' => 'ChsYewaCxm1mi7AIBPRniuncEbFHNO',
'bucket' => 'laravel-admin',
'endpoint' => 'oss-cn-shanghai.aliyuncs.com',
],
],
];
| php | MIT | 67c441eb78ecc5437e59775d89770cd9c2cb1e05 | 2026-01-04T15:05:15.717211Z | false |
z-song/laravel-admin | https://github.com/z-song/laravel-admin/blob/67c441eb78ecc5437e59775d89770cd9c2cb1e05/config/admin.php | config/admin.php | <?php
return [
/*
|--------------------------------------------------------------------------
| Laravel-admin name
|--------------------------------------------------------------------------
|
| This value is the name of laravel-admin, This setting is displayed on the
| login page.
|
*/
'name' => 'Laravel-admin',
/*
|--------------------------------------------------------------------------
| Laravel-admin logo
|--------------------------------------------------------------------------
|
| The logo of all admin pages. You can also set it as an image by using a
| `img` tag, eg '<img src="http://logo-url" alt="Admin logo">'.
|
*/
'logo' => '<b>Laravel</b> admin',
/*
|--------------------------------------------------------------------------
| Laravel-admin mini logo
|--------------------------------------------------------------------------
|
| The logo of all admin pages when the sidebar menu is collapsed. You can
| also set it as an image by using a `img` tag, eg
| '<img src="http://logo-url" alt="Admin logo">'.
|
*/
'logo-mini' => '<b>La</b>',
/*
|--------------------------------------------------------------------------
| Laravel-admin bootstrap setting
|--------------------------------------------------------------------------
|
| This value is the path of laravel-admin bootstrap file.
|
*/
'bootstrap' => app_path('Admin/bootstrap.php'),
/*
|--------------------------------------------------------------------------
| Laravel-admin route settings
|--------------------------------------------------------------------------
|
| The routing configuration of the admin page, including the path prefix,
| the controller namespace, and the default middleware. If you want to
| access through the root path, just set the prefix to empty string.
|
*/
'route' => [
'prefix' => env('ADMIN_ROUTE_PREFIX', 'admin'),
'namespace' => 'App\\Admin\\Controllers',
'middleware' => ['web', 'admin'],
],
/*
|--------------------------------------------------------------------------
| Laravel-admin install directory
|--------------------------------------------------------------------------
|
| The installation directory of the controller and routing configuration
| files of the administration page. The default is `app/Admin`, which must
| be set before running `artisan admin::install` to take effect.
|
*/
'directory' => app_path('Admin'),
/*
|--------------------------------------------------------------------------
| Laravel-admin html title
|--------------------------------------------------------------------------
|
| Html title for all pages.
|
*/
'title' => 'Admin',
/*
|--------------------------------------------------------------------------
| Access via `https`
|--------------------------------------------------------------------------
|
| If your page is going to be accessed via https, set it to `true`.
|
*/
'https' => env('ADMIN_HTTPS', false),
/*
|--------------------------------------------------------------------------
| Laravel-admin auth setting
|--------------------------------------------------------------------------
|
| Authentication settings for all admin pages. Include an authentication
| guard and a user provider setting of authentication driver.
|
| You can specify a controller for `login` `logout` and other auth routes.
|
*/
'auth' => [
'controller' => App\Admin\Controllers\AuthController::class,
'guard' => 'admin',
'guards' => [
'admin' => [
'driver' => 'session',
'provider' => 'admin',
],
],
'providers' => [
'admin' => [
'driver' => 'eloquent',
'model' => Encore\Admin\Auth\Database\Administrator::class,
],
],
// Add "remember me" to login form
'remember' => true,
// Redirect to the specified URI when user is not authorized.
'redirect_to' => 'auth/login',
// The URIs that should be excluded from authorization.
'excepts' => [
'auth/login',
'auth/logout',
],
],
/*
|--------------------------------------------------------------------------
| Laravel-admin upload setting
|--------------------------------------------------------------------------
|
| File system configuration for form upload files and images, including
| disk and upload path.
|
*/
'upload' => [
// Disk in `config/filesystem.php`.
'disk' => 'admin',
// Image and file upload path under the disk above.
'directory' => [
'image' => 'images',
'file' => 'files',
],
],
/*
|--------------------------------------------------------------------------
| Laravel-admin database settings
|--------------------------------------------------------------------------
|
| Here are database settings for laravel-admin builtin model & tables.
|
*/
'database' => [
// Database connection for following tables.
'connection' => '',
// User tables and model.
'users_table' => 'admin_users',
'users_model' => Encore\Admin\Auth\Database\Administrator::class,
// Role table and model.
'roles_table' => 'admin_roles',
'roles_model' => Encore\Admin\Auth\Database\Role::class,
// Permission table and model.
'permissions_table' => 'admin_permissions',
'permissions_model' => Encore\Admin\Auth\Database\Permission::class,
// Menu table and model.
'menu_table' => 'admin_menu',
'menu_model' => Encore\Admin\Auth\Database\Menu::class,
// Pivot table for table above.
'operation_log_table' => 'admin_operation_log',
'user_permissions_table' => 'admin_user_permissions',
'role_users_table' => 'admin_role_users',
'role_permissions_table' => 'admin_role_permissions',
'role_menu_table' => 'admin_role_menu',
],
/*
|--------------------------------------------------------------------------
| User operation log setting
|--------------------------------------------------------------------------
|
| By setting this option to open or close operation log in laravel-admin.
|
*/
'operation_log' => [
'enable' => true,
/*
* Only logging allowed methods in the list
*/
'allowed_methods' => ['GET', 'HEAD', 'POST', 'PUT', 'DELETE', 'CONNECT', 'OPTIONS', 'TRACE', 'PATCH'],
/*
* Routes that will not log to database.
*
* All method to path like: admin/auth/logs
* or specific method to path like: get:admin/auth/logs.
*/
'except' => [
env('ADMIN_ROUTE_PREFIX', 'admin').'/auth/logs*',
],
],
/*
|--------------------------------------------------------------------------
| Indicates whether to check route permission.
|--------------------------------------------------------------------------
*/
'check_route_permission' => true,
/*
|--------------------------------------------------------------------------
| Indicates whether to check menu roles.
|--------------------------------------------------------------------------
*/
'check_menu_roles' => true,
/*
|--------------------------------------------------------------------------
| User default avatar
|--------------------------------------------------------------------------
|
| Set a default avatar for newly created users.
|
*/
'default_avatar' => '/vendor/laravel-admin/AdminLTE/dist/img/user2-160x160.jpg',
/*
|--------------------------------------------------------------------------
| Admin map field provider
|--------------------------------------------------------------------------
|
| Supported: "tencent", "google", "yandex".
|
*/
'map_provider' => 'google',
/*
|--------------------------------------------------------------------------
| Application Skin
|--------------------------------------------------------------------------
|
| This value is the skin of admin pages.
| @see https://adminlte.io/docs/2.4/layout
|
| Supported:
| "skin-blue", "skin-blue-light", "skin-yellow", "skin-yellow-light",
| "skin-green", "skin-green-light", "skin-purple", "skin-purple-light",
| "skin-red", "skin-red-light", "skin-black", "skin-black-light".
|
*/
'skin' => env('ADMIN_SKIN', 'skin-blue-light'),
/*
|--------------------------------------------------------------------------
| Application layout
|--------------------------------------------------------------------------
|
| This value is the layout of admin pages.
| @see https://adminlte.io/docs/2.4/layout
|
| Supported: "fixed", "layout-boxed", "layout-top-nav", "sidebar-collapse",
| "sidebar-mini".
|
*/
'layout' => ['sidebar-mini', 'sidebar-collapse'],
/*
|--------------------------------------------------------------------------
| Login page background image
|--------------------------------------------------------------------------
|
| This value is used to set the background image of login page.
|
*/
'login_background_image' => '',
/*
|--------------------------------------------------------------------------
| Show version at footer
|--------------------------------------------------------------------------
|
| Whether to display the version number of laravel-admin at the footer of
| each page
|
*/
'show_version' => true,
/*
|--------------------------------------------------------------------------
| Show environment at footer
|--------------------------------------------------------------------------
|
| Whether to display the environment at the footer of each page
|
*/
'show_environment' => true,
/*
|--------------------------------------------------------------------------
| Menu bind to permission
|--------------------------------------------------------------------------
|
| whether enable menu bind to a permission
*/
'menu_bind_permission' => true,
/*
|--------------------------------------------------------------------------
| Enable default breadcrumb
|--------------------------------------------------------------------------
|
| Whether enable default breadcrumb for every page content.
*/
'enable_default_breadcrumb' => true,
/*
|--------------------------------------------------------------------------
| Enable/Disable assets minify
|--------------------------------------------------------------------------
*/
'minify_assets' => [
// Assets will not be minified.
'excepts' => [
],
],
/*
|--------------------------------------------------------------------------
| Enable/Disable sidebar menu search
|--------------------------------------------------------------------------
*/
'enable_menu_search' => true,
/*
|--------------------------------------------------------------------------
| Exclude route from generate menu command
|--------------------------------------------------------------------------
*/
'menu_exclude' => [
'_handle_selectable_',
'_handle_renderable_',
],
/*
|--------------------------------------------------------------------------
| Alert message that will displayed on top of the page.
|--------------------------------------------------------------------------
*/
'top_alert' => '',
/*
|--------------------------------------------------------------------------
| The global Grid action display class.
|--------------------------------------------------------------------------
*/
'grid_action_class' => \Encore\Admin\Grid\Displayers\DropdownActions::class,
/*
|--------------------------------------------------------------------------
| Extension Directory
|--------------------------------------------------------------------------
|
| When you use command `php artisan admin:extend` to generate extensions,
| the extension files will be generated in this directory.
*/
'extension_dir' => app_path('Admin/Extensions'),
/*
|--------------------------------------------------------------------------
| Settings for extensions.
|--------------------------------------------------------------------------
|
| You can find all available extensions here
| https://github.com/laravel-admin-extensions.
|
*/
'extensions' => [
],
];
| php | MIT | 67c441eb78ecc5437e59775d89770cd9c2cb1e05 | 2026-01-04T15:05:15.717211Z | false |
z-song/laravel-admin | https://github.com/z-song/laravel-admin/blob/67c441eb78ecc5437e59775d89770cd9c2cb1e05/database/migrations/2016_01_04_173148_create_admin_tables.php | database/migrations/2016_01_04_173148_create_admin_tables.php | <?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateAdminTables extends Migration
{
/**
* {@inheritdoc}
*/
public function getConnection()
{
return config('admin.database.connection') ?: config('database.default');
}
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create(config('admin.database.users_table'), function (Blueprint $table) {
$table->increments('id');
$table->string('username', 190)->unique();
$table->string('password', 60);
$table->string('name');
$table->string('avatar')->nullable();
$table->string('remember_token', 100)->nullable();
$table->timestamps();
});
Schema::create(config('admin.database.roles_table'), function (Blueprint $table) {
$table->increments('id');
$table->string('name', 50)->unique();
$table->string('slug', 50)->unique();
$table->timestamps();
});
Schema::create(config('admin.database.permissions_table'), function (Blueprint $table) {
$table->increments('id');
$table->string('name', 50)->unique();
$table->string('slug', 50)->unique();
$table->string('http_method')->nullable();
$table->text('http_path')->nullable();
$table->timestamps();
});
Schema::create(config('admin.database.menu_table'), function (Blueprint $table) {
$table->increments('id');
$table->integer('parent_id')->default(0);
$table->integer('order')->default(0);
$table->string('title', 50);
$table->string('icon', 50);
$table->string('uri')->nullable();
$table->string('permission')->nullable();
$table->timestamps();
});
Schema::create(config('admin.database.role_users_table'), function (Blueprint $table) {
$table->integer('role_id');
$table->integer('user_id');
$table->index(['role_id', 'user_id']);
$table->timestamps();
});
Schema::create(config('admin.database.role_permissions_table'), function (Blueprint $table) {
$table->integer('role_id');
$table->integer('permission_id');
$table->index(['role_id', 'permission_id']);
$table->timestamps();
});
Schema::create(config('admin.database.user_permissions_table'), function (Blueprint $table) {
$table->integer('user_id');
$table->integer('permission_id');
$table->index(['user_id', 'permission_id']);
$table->timestamps();
});
Schema::create(config('admin.database.role_menu_table'), function (Blueprint $table) {
$table->integer('role_id');
$table->integer('menu_id');
$table->index(['role_id', 'menu_id']);
$table->timestamps();
});
Schema::create(config('admin.database.operation_log_table'), function (Blueprint $table) {
$table->increments('id');
$table->integer('user_id');
$table->string('path');
$table->string('method', 10);
$table->string('ip');
$table->text('input');
$table->index('user_id');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists(config('admin.database.users_table'));
Schema::dropIfExists(config('admin.database.roles_table'));
Schema::dropIfExists(config('admin.database.permissions_table'));
Schema::dropIfExists(config('admin.database.menu_table'));
Schema::dropIfExists(config('admin.database.user_permissions_table'));
Schema::dropIfExists(config('admin.database.role_users_table'));
Schema::dropIfExists(config('admin.database.role_permissions_table'));
Schema::dropIfExists(config('admin.database.role_menu_table'));
Schema::dropIfExists(config('admin.database.operation_log_table'));
}
}
| php | MIT | 67c441eb78ecc5437e59775d89770cd9c2cb1e05 | 2026-01-04T15:05:15.717211Z | false |
z-song/laravel-admin | https://github.com/z-song/laravel-admin/blob/67c441eb78ecc5437e59775d89770cd9c2cb1e05/resources/lang/ur/admin.php | resources/lang/ur/admin.php | <?php
return [
'online' => 'جڑا ہوا۔',
'login' => 'لاگ ان کریں۔',
'logout' => 'سائن آؤٹ',
'setting' => 'ترتیبات۔',
'name' => 'نام۔',
'username' => 'صارف کا نام',
'password' => 'پاس ورڈ',
'password_confirmation' => 'پاسورڈ کی تو ثیق',
'remember_me' => 'مجھے پہچانتے ہو',
'user_setting' => 'صارف کی ترتیب۔',
'avatar' => 'اوتار۔',
'list' => 'فہرست۔',
'new' => 'نئی',
'create' => 'بنانا',
'delete' => 'حذف کریں۔',
'remove' => 'دور',
'edit' => 'ترمیم',
'view' => 'دیکھیں',
'continue_editing' => 'ترمیم جاری رکھیں۔',
'continue_creating' => 'بنانا جاری رکھیں۔',
'detail' => 'تفصیل',
'browse' => 'براؤز کریں۔',
'reset' => 'ری سیٹ کریں۔',
'export' => 'برآمد کریں۔',
'batch_delete' => 'بیچ ڈیلیٹ۔',
'save' => 'محفوظ کریں',
'refresh' => 'ریفریش',
'order' => 'ترتیب',
'expand' => 'پھیلائیں۔',
'collapse' => 'گرنے',
'filter' => 'فلٹر',
'search' => 'تلاش کریں۔',
'close' => 'بند کریں',
'show' => 'دکھائیں۔',
'entries' => 'اندراجات',
'captcha' => 'کیپچا۔',
'action' => 'عمل',
'title' => 'عنوان',
'description' => 'تفصیل',
'back' => 'پیچھے',
'back_to_list' => 'فہرست پر واپس جائیں۔',
'submit' => 'جمع کرائیں',
'menu' => 'مینو',
'input' => 'ان پٹ۔',
'succeeded' => 'کامیاب ہوا۔',
'failed' => 'ناکام ہوگیا۔',
'delete_confirm' => 'کیا آپ واقعی اس آئٹم کو حذف کرنا چاہتے ہیں؟',
'delete_succeeded' => 'حذف کرنے میں کامیاب!',
'delete_failed' => 'حذف کرنے میں ناکام!',
'update_succeeded' => 'اپ ڈیٹ کامیاب!',
'save_succeeded' => 'محفوظ کریں کامیاب!',
'refresh_succeeded' => 'ریفریش کامیاب!',
'login_successful' => 'لاگ ان کامیاب۔',
'choose' => 'منتخب کریں۔',
'choose_file' => 'فائل منتخب کریں۔',
'choose_image' => 'تصویر منتخب کریں۔',
'more' => 'مزید',
'deny' => 'اجازت نہیں دی گئی',
'administrator' => 'ایڈمنسٹریٹر۔',
'roles' => 'کردار۔',
'permissions' => 'اجازت',
'slug' => 'سلگ۔',
'created_at' => 'ایٹ تیار کیا گیا',
'updated_at' => 'تازہ کاری شدہ',
'alert' => 'انتباہ',
'parent_id' => 'والدین',
'icon' => 'شبیہہ۔',
'uri' => 'URI',
'operation_log' => 'آپریشن لاگ',
'parent_select_error' => 'بنیادی انتخاب غلطی',
'pagination' => [
'range' => 'دکھا رہا ہے۔ :first کرنے کے لئے :last کے :total اندراجات',
],
'role' => 'کردار۔',
'permission' => 'اجازت۔',
'route' => 'راسته',
'confirm' => 'تصدیق کریں۔',
'cancel' => 'منسوخ کریں',
'http' => [
'method' => 'HTTP method',
'path' => 'HTTP path',
],
'all_methods_if_empty' => 'اگر تمام خالی ہیں تو',
'all' => 'سب',
'current_page' => 'موجودہ صفحہ',
'selected_rows' => 'قطاریں منتخب کی گئیں۔',
'upload' => 'اپ لوڈ کریں۔',
'new_folder' => 'نیا فولڈر',
'time' => 'وقت',
'size' => 'سائز',
'listbox' => [
'text_total' => 'سب دکھا رہا ہے۔ {0}',
'text_empty' => 'خالی فہرست۔',
'filtered' => '{0} / {1}',
'filter_clear' => 'سارے دکھاو',
'filter_placeholder' => 'فلٹر',
],
'grid_items_selected' => '{n} آئٹمز منتخب',
'menu_titles' => [],
'prev' => 'پچھلا',
'next' => 'اگلے',
'quick_create' => 'فوری تخلیق کریں۔',
];
| php | MIT | 67c441eb78ecc5437e59775d89770cd9c2cb1e05 | 2026-01-04T15:05:15.717211Z | false |
z-song/laravel-admin | https://github.com/z-song/laravel-admin/blob/67c441eb78ecc5437e59775d89770cd9c2cb1e05/resources/lang/de/admin.php | resources/lang/de/admin.php | <?php
return [
'online' => 'Online',
'login' => 'Anmelden',
'logout' => 'Abmelden',
'setting' => 'Einstellungen',
'name' => 'Name',
'username' => 'Benutzername',
'password' => 'Passwort',
'password_confirmation' => 'Passwort bestätigung',
'remember_me' => 'Remember me',
'user_setting' => 'Benutzer Einstellungen',
'avatar' => 'Avatar',
'list' => 'Liste',
'new' => 'Neu',
'create' => 'Erstellen',
'delete' => 'Löschen',
'remove' => 'Entfernen',
'edit' => 'Bearbeiten',
'view' => 'Ansehen',
'continue_editing' => 'Weiter bearbeiten',
'continue_creating' => 'Weitere erstellen',
'detail' => 'Details',
'browse' => 'Auswählen',
'reset' => 'Zurücksetzen',
'export' => 'Exportieren',
'batch_delete' => 'Chargenlöschung',
'save' => 'Speichern',
'refresh' => 'Aktualisieren',
'order' => 'Order',
'expand' => 'Aufklappen',
'collapse' => 'Zuklappen',
'filter' => 'Filter',
'search' => 'Suche',
'close' => 'Schließen',
'show' => 'Anzeigen',
'entries' => 'Einträge',
'captcha' => 'Captcha',
'action' => 'Aktion',
'title' => 'Titel',
'description' => 'Beschreibung',
'back' => 'Zurück',
'back_to_list' => 'Zurück zur Liste',
'submit' => 'Absenden',
'menu' => 'Menü',
'input' => 'Eingabe',
'succeeded' => 'Erfolgreich',
'failed' => 'Gescheitert',
'delete_confirm' => 'Wollen Sie diesen Eintrag wirklich löschen?',
'delete_succeeded' => 'Löschen erfolgreich!',
'delete_failed' => 'Löschen gescheitert!',
'update_succeeded' => 'Aktualisierung erfolgreich!',
'save_succeeded' => 'Speichern erfolgreich!',
'refresh_succeeded' => 'Aktualisierung erfolgreich!',
'login_successful' => 'Anmeldung erfolgreich',
'choose' => 'Auswählen',
'choose_file' => 'Datei auswählen',
'choose_image' => 'Bild auswählen',
'more' => 'Mehr',
'deny' => 'Zugriff verweigert',
'administrator' => 'Administrator',
'roles' => 'Rollen',
'permissions' => 'Rechte',
'slug' => 'Schlagwort',
'created_at' => 'Erstellt am',
'updated_at' => 'Aktualisiert am',
'alert' => 'Warnung',
'parent_id' => 'Übergeordnete ID',
'icon' => 'Icon',
'uri' => 'URL',
'operation_log' => 'Betriebs Log',
'parent_select_error' => 'Fehler bei der Parent Auswahl',
'pagination' => [
'range' => 'Zeigt :first bis :last von gesamt :total Einträgen',
],
'role' => 'Rolle',
'permission' => 'Rechte',
'route' => 'Route',
'confirm' => 'Bestätigen',
'cancel' => 'Abbrechen',
'http' => [
'method' => 'HTTP Methode',
'path' => 'HTTP Pfad',
],
'all_methods_if_empty' => 'Alle Methoden wenn leer',
'all' => 'Alle',
'current_page' => 'Aktuelle Seite',
'selected_rows' => 'Ausgewählte Zeilen',
'upload' => 'Hochladen',
'new_folder' => 'Neuer Ordner',
'time' => 'Zeit',
'size' => 'Größe',
'listbox' => [
'text_total' => 'Zeige alle {0}',
'text_empty' => 'Leere Liste',
'filtered' => '{0} / {1}',
'filter_clear' => 'Filter zurücksetzen',
'filter_placeholder' => 'Filtern',
],
'grid_items_selected' => '{n} Einträge ausgewählt',
'menu_titles' => [],
'prev' => 'Vorherige',
'next' => 'Nächste',
'quick_create' => 'Schnellerstellung',
];
| php | MIT | 67c441eb78ecc5437e59775d89770cd9c2cb1e05 | 2026-01-04T15:05:15.717211Z | false |
z-song/laravel-admin | https://github.com/z-song/laravel-admin/blob/67c441eb78ecc5437e59775d89770cd9c2cb1e05/resources/lang/az/admin.php | resources/lang/az/admin.php | <?php
return [
'online' => 'Aktiv',
'login' => 'Giriş',
'logout' => 'Çıxış',
'setting' => 'Ayarlar',
'name' => 'Ad',
'username' => 'İstifadəçi adı',
'password' => 'Şifrə',
'password_confirmation' => 'Şifrənin tekrarı',
'remember_me' => 'Məni xatırla',
'user_setting' => 'İstifadəçi ayarları',
'avatar' => 'Profil şəkli',
'list' => 'List',
'new' => 'Yeni',
'create' => 'Yarat',
'delete' => 'Sil',
'remove' => 'Kənarlaşdırın',
'edit' => 'Yenilə',
'view' => 'Bax',
'detail' => 'Detallar',
'browse' => 'Göz atın',
'reset' => 'Təmizlə',
'export' => 'İxrac edin',
'batch_delete' => 'Hamısını sil',
'save' => 'Yaddaşa ver',
'refresh' => 'Yenile',
'order' => 'Sırala',
'expand' => 'Genişlət',
'collapse' => 'Daralt',
'filter' => 'Filtrlə',
'search' => 'axtarış',
'close' => 'Bağla',
'show' => 'Göstər',
'entries' => 'qeydlər',
'captcha' => 'Doğrulama',
'action' => 'Fəaliyyət',
'title' => 'Başlıq',
'description' => 'Açıqlama',
'back' => 'Geri',
'back_to_list' => 'Listə geri qayıt',
'submit' => 'Göndər',
'continue_editing' => 'Redaktəyə davam et',
'continue_creating' => 'Yaratmağa davam et',
'menu' => 'Menyu',
'input' => 'Giriş',
'succeeded' => 'Uğurlu',
'failed' => 'Xəta baş verdi',
'delete_confirm' => 'Silmək istədiyinizə əminsiniz?',
'delete_succeeded' => 'Uğurla silindi!',
'delete_failed' => 'Silinərkən xəta baş verdi!',
'update_succeeded' => 'Uğurla yeniləndi!',
'save_succeeded' => 'Uğurla yadda saxlanıldı!',
'refresh_succeeded' => 'Uğurla yeniləndi!',
'login_successful' => 'Giriş uğurlu oldu',
'choose' => 'Seçin',
'choose_file' => 'Fayl seçin',
'choose_image' => 'Şəkil seçin',
'more' => 'Daha çox',
'deny' => 'İcazə yoxdur',
'administrator' => 'Rəhbər',
'roles' => 'Rollar',
'permissions' => 'İcazələr',
'slug' => 'Qalıcı link',
'created_at' => 'Yaradılma tarixi',
'updated_at' => 'Yenilənmə tarixi',
'alert' => 'Xəbərdarlıq',
'parent_id' => 'Valideyn',
'icon' => 'İkon',
'uri' => 'URL',
'operation_log' => 'Əməliyyat tarixçəsi',
'parent_select_error' => 'Üst xəta',
'pagination' => [
'range' => ':total qeyd içindən :first dən :last -ə kimi',
],
'role' => 'Rol',
'permission' => 'İcazə',
'route' => 'Yol',
'confirm' => 'Təsdiqlə',
'cancel' => 'Ləğv',
'http' => [
'method' => 'HTTP methodu',
'path' => 'HTTP qovluğu',
],
'all_methods_if_empty' => 'Bütün metodlar boşdursa',
'all' => 'Hamısı',
'current_page' => 'Cari səhifə',
'selected_rows' => 'Seçilənlər',
'upload' => 'Yüklə',
'new_folder' => 'Yeni qovluq',
'time' => 'Zaman',
'size' => 'Ölçü',
'listbox' => [
'text_total' => 'Ümumi {0} qeyd',
'text_empty' => 'Boş list',
'filtered' => '{0} / {1}',
'filter_clear' => 'Hamısını göstər',
'filter_placeholder' => 'Filtrlə',
],
'menu_titles' => [],
];
| php | MIT | 67c441eb78ecc5437e59775d89770cd9c2cb1e05 | 2026-01-04T15:05:15.717211Z | false |
z-song/laravel-admin | https://github.com/z-song/laravel-admin/blob/67c441eb78ecc5437e59775d89770cd9c2cb1e05/resources/lang/bn/admin.php | resources/lang/bn/admin.php | <?php
return [
'online' => 'অনলাইন',
'login' => 'লগিন',
'logout' => 'লগ আউট',
'setting' => 'সেটিংস',
'name' => 'নাম',
'username' => 'ব্যবহারকারীর নাম',
'password' => 'পাসওয়ার্ড',
'password_confirmation' => 'পাসওয়ার্ড নিশ্চিতকরণ',
'remember_me' => 'আমাকে মনে রাখুন',
'user_setting' => 'ব্যবহারকারীর সেটিংস',
'avatar' => 'ছবি',
'list' => 'তালিকা',
'new' => 'নতুন',
'create' => 'তৈরি করুন',
'delete' => 'মুছে ফেলুন',
'remove' => 'সরান',
'edit' => 'সম্পাদনা',
'view' => 'দেখুন',
'continue_editing' => 'সম্পাদনা অব্যাহত রাখুন',
'continue_creating' => 'তৈরি অব্যাহত রাখুন',
'detail' => 'বিস্তারিত',
'browse' => 'ব্রাউজ করুন',
'reset' => 'রিসেট',
'export' => 'এক্সপোর্ট',
'batch_delete' => 'গুচ্ছ আকারে মুছুন',
'save' => 'সংরক্ষণ',
'refresh' => 'রিফ্রেশ',
'order' => 'ক্রম',
'expand' => 'বর্ধিত',
'collapse' => 'বন্ধ',
'filter' => 'ফিল্টার',
'search' => 'খুঁজুন',
'close' => 'বন্ধ',
'show' => 'দেখান',
'entries' => 'অন্তর্ভুক্তিগুলি',
'captcha' => 'ক্যাপচা',
'action' => 'একশন',
'title' => 'শিরোনাম',
'description' => 'বর্ণনা',
'back' => 'ফিরে যান',
'back_to_list' => 'তালিকায় ফিরে যান',
'submit' => 'সাবমিট করন',
'menu' => 'মেন্যু',
'input' => 'ইনপুট',
'succeeded' => 'সফল হয়েছে',
'failed' => 'ব্যর্থ হয়েছে',
'delete_confirm' => 'আপনি কি এই আইটেমটি মুছে ফেলার বিষয়ে নিশ্চিত?',
'delete_succeeded' => 'মুছে ফেলতে সক্ষম হয়েছে।',
'delete_failed' => 'মুছে ফেলতে ব্যর্থ হয়েছে',
'update_succeeded' => 'সফলভবে আপডেট হয়েছে।',
'save_succeeded' => 'সফলভবে সংরক্ষণ হয়েছে।',
'refresh_succeeded' => 'সফলভবে রিফ্রেশ হয়েছে।',
'login_successful' => 'লগিন সফল হয়ছে',
'choose' => 'বাছাই করুন',
'choose_file' => 'ফাইল নির্বাচন করুন',
'choose_image' => 'ছবি সফলভবে সংরক্ষণ হয়েছে।',
'more' => 'আরও',
'deny' => 'অনুমতি অগ্রাহ্য হয়েছে',
'administrator' => 'এডমিনিস্ট্রেটর',
'roles' => 'রোলসমূহ',
'permissions' => 'পারমিশন সমূহ',
'slug' => 'স্লাগ',
'created_at' => 'তৈরি করা হয়েছে',
'updated_at' => 'আপডেট করা হয়েছে',
'alert' => 'সতর্কীকরণ',
'parent_id' => 'প্যারেন্ট',
'icon' => 'আইকন',
'uri' => 'URI',
'operation_log' => 'অপারেশন লগ',
'parent_select_error' => 'প্যারেন্ট নির্বাচন ভুল',
'pagination' => [
'range' => ':total টি রেকর্ডের মধ্যে :first থেকে :last টি দেখানো হচ্ছে',
],
'role' => 'রোল',
'permission' => 'পারমিশন',
'route' => 'রাউট',
'confirm' => 'নিশ্চিত করুন',
'cancel' => 'বাতিল',
'http' => [
'method' => 'HTTP method',
'path' => 'HTTP path',
],
'all_methods_if_empty' => 'All methods if empty',
'all' => 'সকল',
'current_page' => 'বর্তমান পৃষ্ঠা',
'selected_rows' => 'নির্বাচিত সারিগুলি',
'upload' => 'আপলোড',
'new_folder' => 'নতুন ফোল্ডার',
'time' => 'স্ময়',
'size' => 'সাইজ',
'listbox' => [
'text_total' => 'সবগুলি দেখানো হচ্ছে {0}',
'text_empty' => 'খালি তালিকা',
'filtered' => '{0} / {1}',
'filter_clear' => 'সবগুলি দেখান',
'filter_placeholder' => 'ফিল্টার',
],
'grid_items_selected' => '{n} টি আইটেম নির্বাচিত হয়েছে',
'menu_titles' => [],
'prev' => 'পূর্ববর্তী',
'next' => 'পরবর্তী',
'quick_create' => 'দ্রুত তৈরি করুন',
];
| php | MIT | 67c441eb78ecc5437e59775d89770cd9c2cb1e05 | 2026-01-04T15:05:15.717211Z | false |
z-song/laravel-admin | https://github.com/z-song/laravel-admin/blob/67c441eb78ecc5437e59775d89770cd9c2cb1e05/resources/lang/ms/admin.php | resources/lang/ms/admin.php | <?php
return [
'online' => 'Online',
'login' => 'Masuk',
'logout' => 'Log keluar',
'setting' => 'Menetapkan',
'name' => 'Nama',
'username' => 'Nama pengguna',
'password' => 'Kata laluan',
'password_confirmation' => 'Sahkan kata laluan',
'remember_me' => 'Ingat saya',
'user_setting' => 'Tetapan pengguna',
'avatar' => 'Avatar',
'list' => 'Senarai',
'new' => 'Tambah',
'create' => 'Buat',
'delete' => 'Padam',
'remove' => 'Keluarkan',
'edit' => 'Edit',
'continue_editing' => 'Teruskan mengedit',
'continue_creating' => 'Terus mencipta',
'view' => 'Lihat',
'detail' => 'Terperinci',
'browse' => 'Semak imbas',
'reset' => 'Tetapkan semula',
'export' => 'Eksport',
'batch_delete' => 'Padam tanggal',
'save' => 'Simpan',
'refresh' => 'Muat semula',
'order' => 'Isih',
'expand' => 'Perluas',
'collapse' => 'Runtuh',
'filter' => 'Pemeriksaan',
'search' => 'Carian',
'close' => 'Tutup',
'show' => 'Paparan',
'entries' => 'Perkara',
'captcha' => 'Kod pengesahan',
'action' => 'Operasi',
'title' => 'Tajuk',
'description' => 'Pengenalan',
'back' => 'Kembali',
'back_to_list' => 'Senarai pemulangan',
'submit' => 'Hantar',
'menu' => 'Menu',
'input' => 'Input',
'succeeded' => 'Kejayaan',
'failed' => 'Kegagalan',
'delete_confirm' => 'Sahkan pemadaman?',
'delete_succeeded' => 'Dihapuskan berjaya!',
'delete_failed' => 'Padam gagal!',
'update_succeeded' => 'Berjaya dikemas kini!',
'save_succeeded' => 'Disimpan berjaya!',
'refresh_succeeded' => 'Segarkan semula!',
'login_successful' => 'Log masuk yang berjaya!',
'choose' => 'Pilih',
'choose_file' => 'Pilih fail',
'choose_image' => 'Pilih gambar',
'more' => 'Lebih banyak',
'deny' => 'Tiada akses',
'administrator' => 'Pentadbir',
'roles' => 'Peranan',
'permissions' => 'Kebenaran',
'slug' => 'Pengenalan',
'created_at' => 'Dicipta pada',
'updated_at' => 'Dikemaskini pada',
'alert' => 'Perhatian',
'parent_id' => 'Menu ibu bapa',
'icon' => 'Ikon',
'uri' => 'Jalan',
'operation_log' => 'Log operasi',
'parent_select_error' => 'Ralat pemilihan ibu bapa',
'pagination' => [
'range' => 'Dari :first Untuk :last ,Jumlah :total Perkara',
],
'role' => 'Peranan',
'permission' => 'Kebenaran',
'route' => 'Routing',
'confirm' => 'Sahkan',
'cancel' => 'Batalkan',
'http' => [
'method' => 'Kaedah HTTP',
'path' => 'Laluan HTTP',
],
'all_methods_if_empty' => 'Kosongkan mungkir kepada semua kaedah',
'all' => 'Semua',
'current_page' => 'Halaman semasa',
'selected_rows' => 'Barisan terpilih',
'upload' => 'Muat naik',
'new_folder' => 'Folder baru',
'time' => 'Masa',
'size' => 'Saiz',
'listbox' => [
'text_total' => 'Jumlah {0} Perkara',
'text_empty' => 'Senarai kosong',
'filtered' => '{0} / {1}',
'filter_clear' => 'Tunjukkan semua',
'filter_placeholder' => 'Penapis',
],
'menu_titles' => [],
];
| php | MIT | 67c441eb78ecc5437e59775d89770cd9c2cb1e05 | 2026-01-04T15:05:15.717211Z | false |
z-song/laravel-admin | https://github.com/z-song/laravel-admin/blob/67c441eb78ecc5437e59775d89770cd9c2cb1e05/resources/lang/tr/admin.php | resources/lang/tr/admin.php | <?php
return [
'online' => 'Aktif',
'login' => 'Giriş',
'logout' => 'Çıkış',
'setting' => 'Ayarlar',
'name' => 'İsim',
'username' => 'Kullanıcı adı',
'password' => 'Parola',
'password_confirmation' => 'Parola tekrar',
'remember_me' => 'Beni hatırla',
'user_setting' => 'Kullanıcı ayarları',
'avatar' => 'Profil resmi',
'list' => 'Liste',
'new' => 'Yeni',
'create' => 'Oluştur',
'delete' => 'Sil',
'remove' => 'Kaldır',
'edit' => 'Düzenle',
'view' => 'Gör',
'detail' => 'Ayrıntılar',
'browse' => 'Gözat',
'reset' => 'Temizle',
'export' => 'Dışarı aktar',
'batch_delete' => 'Toplu sil',
'save' => 'Kaydet',
'refresh' => 'Yenile',
'order' => 'Sırala',
'expand' => 'Genişlet',
'collapse' => 'Daralt',
'filter' => 'Filtrele',
'search' => 'arama',
'close' => 'Kapat',
'show' => 'Göster',
'entries' => 'kayıtlar',
'captcha' => 'Doğrulama',
'action' => 'İşlem',
'title' => 'Başlık',
'description' => 'Açıklama',
'back' => 'Geri',
'back_to_list' => 'Listeye dön',
'submit' => 'Gönder',
'continue_editing' => 'Düzenlemeye devam et',
'continue_creating' => 'Oluşturmaya devam et',
'menu' => 'Menü',
'input' => 'Giriş',
'succeeded' => 'Başarılı',
'failed' => 'Hatalı',
'delete_confirm' => 'Silmek istediğinize emin misiniz?',
'delete_succeeded' => 'Silme başarılı!',
'delete_failed' => 'Silme hatalı!',
'update_succeeded' => 'Güncellemen başarılı!',
'save_succeeded' => 'Kaydetme başarılı!',
'refresh_succeeded' => 'Yenileme başarılı!',
'login_successful' => 'Giriş başarılı',
'choose' => 'Seçin',
'choose_file' => 'Dosya seçin',
'choose_image' => 'Resim seçin',
'more' => 'Daha',
'deny' => 'İzin yok',
'administrator' => 'Yönetici',
'roles' => 'Roller',
'permissions' => 'İzinler',
'slug' => 'Kalıcı link',
'created_at' => 'Oluşturulma tarihi',
'updated_at' => 'Güncellenme tarihi',
'alert' => 'Uyarı',
'parent_id' => 'Ebeveyn',
'icon' => 'İkon',
'uri' => 'URL',
'operation_log' => 'İşlem kayıtları',
'parent_select_error' => 'Üst hata',
'pagination' => [
'range' => ':total kayıt içinden :first den :last e kadar',
],
'role' => 'Rol',
'permission' => 'İzin',
'route' => 'Rota',
'confirm' => 'Onayla',
'cancel' => 'İptal',
'http' => [
'method' => 'HTTP metodu',
'path' => 'HTTP dizini',
],
'all_methods_if_empty' => 'Tüm metodlar boş ise',
'all' => 'Tümü',
'current_page' => 'Mevcut sayfa',
'selected_rows' => 'Seçilen kayıtlar',
'upload' => 'Yükle',
'new_folder' => 'Yeni dizin',
'time' => 'Zaman',
'size' => 'Boyut',
'listbox' => [
'text_total' => 'Toplam {0} kayıt',
'text_empty' => 'Boş liste',
'filtered' => '{0} / {1}',
'filter_clear' => 'Tümünü göster',
'filter_placeholder' => 'Filtrele',
],
'menu_titles' => [],
'grid_items_selected' => '{n} öğe seçildi',
'menu_titles' => [],
'prev' => 'Önceki',
'next' => 'Sonraki',
'quick_create' => 'Hemen oluştur',
];
| php | MIT | 67c441eb78ecc5437e59775d89770cd9c2cb1e05 | 2026-01-04T15:05:15.717211Z | false |
z-song/laravel-admin | https://github.com/z-song/laravel-admin/blob/67c441eb78ecc5437e59775d89770cd9c2cb1e05/resources/lang/he/admin.php | resources/lang/he/admin.php | <?php
return [
'online' => 'און ליין',
'login' => 'כניסה',
'logout' => 'יציאה',
'setting' => 'הגדרות',
'name' => 'שם',
'username' => 'שם משתמש',
'password' => 'סיסמא',
'password_confirmation' => 'שוב סיסמא',
'remember_me' => 'זכור אותי',
'user_setting' => 'הגדרות משתמש',
'avatar' => 'תמונה',
'list' => 'רשימה',
'new' => 'חדש',
'create' => 'יצירה',
'delete' => 'מחיקה',
'remove' => 'הסרה',
'edit' => 'עריכה',
'view' => 'צפייה',
'continue_editing' => 'המשך בעריכה',
'continue_creating' => 'המשך ליצור',
'detail' => 'פרט',
'browse' => 'דפדוף',
'reset' => 'אתחול',
'export' => 'ייצוא',
'batch_delete' => 'מחק מסומנים',
'save' => 'שמור',
'refresh' => 'רענן',
'order' => 'סדר',
'expand' => 'הרחב',
'collapse' => 'פתח',
'filter' => 'חיפוש',
'search' => 'לחפש',
'close' => 'סגור',
'show' => 'צפה',
'entries' => 'רשומות',
'captcha' => 'קאפצ\'ה',
'action' => 'פעולה',
'title' => 'כותרת',
'description' => 'תאור',
'back' => 'חזרה',
'back_to_list' => 'חזרה לרשימה',
'submit' => 'שלח',
'menu' => 'תפריט',
'input' => 'קלט',
'succeeded' => 'הצלחה',
'failed' => 'כשלון',
'delete_confirm' => 'אתה בטוח שאתה רוצה למחוק?',
'delete_succeeded' => 'מחיקה הצליחה',
'delete_failed' => 'מחיקה נכשלה',
'update_succeeded' => 'עודכן בהצלחה',
'save_succeeded' => 'נשמר בהצלחה',
'refresh_succeeded' => 'רענון הצליחה',
'login_successful' => 'כניסה הצליחה',
'choose' => 'בחר',
'choose_file' => 'בחר קובץ',
'choose_image' => 'בחר תמונה',
'more' => 'עוד',
'deny' => 'אין הרשאות',
'administrator' => 'מנהל מערכת',
'roles' => 'תפקידים',
'permissions' => 'הרשאות',
'slug' => 'טקסט',
'created_at' => 'נוצר ב',
'updated_at' => 'עודכן ב',
'alert' => 'אזהרה',
'parent_id' => 'אב',
'icon' => 'אייקון',
'uri' => 'כתובת',
'operation_log' => 'לוג מערכת',
'parent_select_error' => 'בעייה בבחירת האב',
'pagination' => [
'range' => ':last מ :total תוצאות',
],
'menu_titles' => [],
];
| php | MIT | 67c441eb78ecc5437e59775d89770cd9c2cb1e05 | 2026-01-04T15:05:15.717211Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.