diff --git a/src/CodeGenerator.php b/src/CodeGenerator.php
index 7637ebe7..aa82d063 100644
--- a/src/CodeGenerator.php
+++ b/src/CodeGenerator.php
@@ -168,7 +168,7 @@ public static function appendRoutes($config, $comm = null)
$templateDirectory = __DIR__ . '/stubs';
LAHelper::log("info", "Appending routes...", $comm);
- if(\Dwij\Laraadmin\Helpers\LAHelper::laravel_ver() == 5.3) {
+ if(\Dwij\Laraadmin\Helpers\LAHelper::is_recent_laravel_version()) {
$routesFile = base_path('routes/admin_routes.php');
} else {
$routesFile = app_path('Http/admin_routes.php');
diff --git a/src/Commands/LAInstall.php b/src/Commands/LAInstall.php
index f916a152..9c178bd6 100644
--- a/src/Commands/LAInstall.php
+++ b/src/Commands/LAInstall.php
@@ -6,16 +6,13 @@
* Developed by: Dwij IT Solutions
* Developer Website: http://dwijitsolutions.com
*/
-
namespace Dwij\Laraadmin\Commands;
-
use Exception;
use Illuminate\Console\Command;
use Illuminate\Filesystem\Filesystem;
use Dwij\Laraadmin\Helpers\LAHelper;
use Eloquent;
use DB;
-
/**
* Class LAInstall
* @package Dwij\Laraadmin\Commands
@@ -26,19 +23,19 @@ class LAInstall extends Command
{
// Model Names to be handled during Install
var $modelsInstalled = ["User", "Role", "Permission", "Employee", "Department", "Upload", "Organization", "Backup"];
-
+
// The command signature.
protected $signature = 'la:install';
-
+
// The command description.
protected $description = 'Install LaraAdmin Package. Generate whole structure for /admin.';
-
+
// Copy From Folder - Package Install Files
protected $from;
-
+
// Copy to Folder - Project Folder
protected $to;
-
+
/**
* Generates and Moves files to install LaraAdmin package.
* At the end runs migrations and ask to create Super Admin in order to complete the installation.
@@ -49,40 +46,40 @@ public function handle()
{
try {
$this->info('LaraAdmin installation started...');
-
+
$from = base_path('vendor/dwij/laraadmin/src/Installs');
$to = base_path();
-
+
$this->info('from: ' . $from . " to: " . $to);
-
+
$this->line("\nDB Assistant:");
- if($this->confirm("Want to set your Database config in the .env file ?", true)) {
+ if($this->confirm("Want to set your Database config in the .env file?", true)) {
$this->line("DB Assistant Initiated....");
$db_data = array();
-
- if(LAHelper::laravel_ver() == 5.3) {
+
+ if(LAHelper::is_recent_laravel_version()) {
$db_data['host'] = $this->ask('Database Host', '127.0.0.1');
$db_data['port'] = $this->ask('Database Port', '3306');
}
$db_data['db'] = $this->ask('Database Name', 'laraadmin1');
$db_data['dbuser'] = $this->ask('Database User', 'root');
$dbpass = $this->ask('Database Password', false);
-
+
if($dbpass !== FALSE) {
$db_data['dbpass'] = $dbpass;
} else {
$db_data['dbpass'] = "";
}
-
+
$default_db_conn = env('DB_CONNECTION', 'mysql');
-
- if(LAHelper::laravel_ver() == 5.3) {
+
+ if(LAHelper::is_recent_laravel_version()) {
config(['database.connections.' . $default_db_conn . '.host' => $db_data['host']]);
config(['database.connections.' . $default_db_conn . '.port' => $db_data['port']]);
LAHelper::setenv("DB_HOST", $db_data['host']);
LAHelper::setenv("DB_PORT", $db_data['port']);
}
-
+
config(['database.connections.' . $default_db_conn . '.database' => $db_data['db']]);
config(['database.connections.' . $default_db_conn . '.username' => $db_data['dbuser']]);
config(['database.connections.' . $default_db_conn . '.password' => $db_data['dbpass']]);
@@ -90,24 +87,27 @@ public function handle()
LAHelper::setenv("DB_USERNAME", $db_data['dbuser']);
LAHelper::setenv("DB_PASSWORD", $db_data['dbpass']);
}
-
+
if(env('CACHE_DRIVER') != "array") {
config(['cache.default' => 'array']);
LAHelper::setenv("CACHE_DRIVER", "array");
}
-
+ $mix_file = 'gulpfile.js';
+ if (LAHelper::laravel_ver() > 5.3) {
+ $mix_file = 'webpack.mix.js';
+ }
if($this->confirm("This process may change/append to the following of your existing project files:"
. "\n\n\t app/Http/routes.php"
. "\n\t app/User.php"
. "\n\t database/migrations/2014_10_12_000000_create_users_table.php"
- . "\n\t gulpfile.js"
+ . "\n\t $mix_file"
. "\n\n Please take backup or use git. Do you wish to continue ?", true)
) {
-
+
// Controllers
$this->line("\n" . 'Generating Controllers...');
$this->copyFolder($from . "/app/Controllers/Auth", $to . "/app/Http/Controllers/Auth");
- if(LAHelper::laravel_ver() == 5.3) {
+ if(LAHelper::is_recent_laravel_version()) {
// Delete Redundant Controllers
unlink($to . "/app/Http/Controllers/Auth/PasswordController.php");
unlink($to . "/app/Http/Controllers/Auth/AuthController.php");
@@ -118,23 +118,23 @@ public function handle()
unlink($to . "/app/Http/Controllers/Auth/ResetPasswordController.php");
}
$this->replaceFolder($from . "/app/Controllers/LA", $to . "/app/Http/Controllers/LA");
- if(LAHelper::laravel_ver() == 5.3) {
- $this->copyFile($from . "/app/Controllers/Controller.5.3.php", $to . "/app/Http/Controllers/Controller.php");
- } else {
+ if(LAHelper::is_recent_laravel_version()) {
$this->copyFile($from . "/app/Controllers/Controller.php", $to . "/app/Http/Controllers/Controller.php");
+ } else {
+ $this->copyFile($from . "/app/Controllers/Legacy.Controller.php", $to . "/app/Http/Controllers/Controller.php");
}
$this->copyFile($from . "/app/Controllers/HomeController.php", $to . "/app/Http/Controllers/HomeController.php");
-
+
// Middleware
- if(LAHelper::laravel_ver() == 5.3) {
+ if(LAHelper::is_recent_laravel_version()) {
$this->copyFile($from . "/app/Middleware/RedirectIfAuthenticated.php", $to . "/app/Http/Middleware/RedirectIfAuthenticated.php");
}
-
-
+
+
// Config
$this->line('Generating Config...');
$this->copyFile($from . "/config/laraadmin.php", $to . "/config/laraadmin.php");
-
+
// Models
$this->line('Generating Models...');
if(!file_exists($to . "/app/Models")) {
@@ -143,10 +143,10 @@ public function handle()
}
foreach($this->modelsInstalled as $model) {
if($model == "User") {
- if(LAHelper::laravel_ver() == 5.3) {
- $this->copyFile($from . "/app/Models/" . $model . "5.3.php", $to . "/app/" . $model . ".php");
- } else {
+ if(LAHelper::is_recent_laravel_version()) {
$this->copyFile($from . "/app/Models/" . $model . ".php", $to . "/app/" . $model . ".php");
+ } else {
+ $this->copyFile($from . "/app/Models/Legacy." . $model . ".php", $to . "/app/" . $model . ".php");
}
} else if($model == "Role" || $model == "Permission") {
$this->copyFile($from . "/app/Models/" . $model . ".php", $to . "/app/" . $model . ".php");
@@ -154,7 +154,7 @@ public function handle()
$this->copyFile($from . "/app/Models/" . $model . ".php", $to . "/app/Models/" . $model . ".php");
}
}
-
+
// Custom Admin Route
/*
$this->line("\nDefault admin url route is /admin");
@@ -167,7 +167,7 @@ public function handle()
config(['laraadmin.adminRoute' => $custom_admin_route]);
}
*/
-
+
// Generate Uploads / Thumbnails folders in /storage
$this->line('Generating Uploads / Thumbnails folders...');
if(!file_exists($to . "/storage/uploads")) {
@@ -178,12 +178,12 @@ public function handle()
$this->info("mkdir: (" . $to . "/storage/thumbnails)");
mkdir($to . "/storage/thumbnails");
}
-
+
// la-assets
$this->line('Generating LaraAdmin Public Assets...');
$this->replaceFolder($from . "/la-assets", $to . "/public/la-assets");
// Use "git config core.fileMode false" for ignoring file permissions
-
+
// check CACHE_DRIVER to be array or else
// It is required for Zizaco/Entrust
// https://github.com/Zizaco/entrust/issues/468
@@ -192,24 +192,24 @@ public function handle()
throw new Exception("Please set Cache Driver to array in .env (Required for Zizaco\Entrust) and run la:install again:"
. "\n\n\tCACHE_DRIVER=array\n\n", 1);
}
-
+
// migrations
$this->line('Generating migrations...');
$this->copyFolder($from . "/migrations", $to . "/database/migrations");
-
+
$this->line('Copying seeds...');
$this->copyFile($from . "/seeds/DatabaseSeeder.php", $to . "/database/seeds/DatabaseSeeder.php");
-
-
+
+
// resources
$this->line('Generating resources: assets + views...');
$this->copyFolder($from . "/resources/assets", $to . "/resources/assets");
$this->copyFolder($from . "/resources/views", $to . "/resources/views");
-
+
// Checking database
$this->line('Checking database connectivity...');
DB::connection()->reconnect();
-
+
// Running migrations...
$this->line('Running migrations...');
$this->call('clear-compiled');
@@ -223,35 +223,35 @@ public function handle()
$composer_path = "composer";
}
$this->info(exec($composer_path . ' dump-autoload'));
-
+
$this->call('migrate:refresh');
// $this->call('migrate:refresh', ['--seed']);
-
+
// $this->call('db:seed', ['--class' => 'LaraAdminSeeder']);
-
+
// $this->line('Running seeds...');
// $this->info(exec('composer dump-autoload'));
$this->call('db:seed');
// Install Spatie Backup
$this->call('vendor:publish', ['--provider' => 'Spatie\Backup\BackupServiceProvider']);
-
+
// Edit config/database.php for Spatie Backup Configuration
if(LAHelper::getLineWithString('config/database.php', "dump_command_path") == -1) {
$newDBConfig = " 'driver' => 'mysql',\n"
. " 'dump_command_path' => '/opt/lampp/bin', // only the path, so without 'mysqldump' or 'pg_dump'\n"
. " 'dump_command_timeout' => 60 * 5, // 5 minute timeout\n"
. " 'dump_using_single_transaction' => true, // perform dump using a single transaction\n";
-
+
$envfile = $this->openFile('config/database.php');
$mysqldriverline = LAHelper::getLineWithString('config/database.php', "'driver' => 'mysql'");
$envfile = str_replace($mysqldriverline, $newDBConfig, $envfile);
file_put_contents('config/database.php', $envfile);
}
-
+
// Routes
$this->line('Appending routes...');
//if(!$this->fileContains($to."/app/Http/routes.php", "laraadmin.adminRoute")) {
- if(LAHelper::laravel_ver() == 5.3) {
+ if(LAHelper::is_recent_laravel_version()) {
if(LAHelper::getLineWithString($to . "/routes/web.php", "require __DIR__.'/admin_routes.php';") == -1) {
$this->appendFile($from . "/app/routes.php", $to . "/routes/web.php");
}
@@ -262,30 +262,30 @@ public function handle()
}
$this->copyFile($from . "/app/admin_routes.php", $to . "/app/Http/admin_routes.php");
}
-
+
// tests
$this->line('Generating tests...');
$this->copyFolder($from . "/tests", $to . "/tests");
- if(LAHelper::laravel_ver() == 5.3) {
+ if(LAHelper::is_recent_laravel_version()) {
unlink($to . '/tests/TestCase.php');
rename($to . '/tests/TestCase5.3.php', $to . '/tests/TestCase.php');
} else {
unlink($to . '/tests/TestCase5.3.php');
}
-
+
// Utilities
$this->line('Generating Utilities...');
// if(!$this->fileContains($to."/gulpfile.js", "admin-lte/AdminLTE.less")) {
- if(LAHelper::getLineWithString($to . "/gulpfile.js", "mix.less('admin-lte/AdminLTE.less', 'public/la-assets/css');") == -1) {
- $this->appendFile($from . "/gulpfile.js", $to . "/gulpfile.js");
+ if(LAHelper::getLineWithString($to . '/'.$mix_file, "mix.less('admin-lte/AdminLTE.less', 'public/la-assets/css');") == -1) {
+ $this->appendFile($from . '/'.$mix_file, $to . '/'.$mix_file);
}
// Creating Super Admin User
-
+
$user = \App\User::where('context_id', "1")->first();
if(!isset($user['id'])) {
-
+
$this->line('Creating Super Admin User...');
-
+
$data = array();
$data['name'] = $this->ask('Super Admin name', 'Super Admin');
$data['email'] = $this->ask('Super Admin email', 'user@example.com');
@@ -293,10 +293,10 @@ public function handle()
$data['context_id'] = "1";
$data['type'] = "Employee";
$user = \App\User::create($data);
-
+
// TODO: This is Not Standard. Need to find alternative
Eloquent::unguard();
-
+
\App\Models\Employee::create([
'name' => $data['name'],
'designation' => "Super Admin",
@@ -313,7 +313,7 @@ public function handle()
'date_left' => date("Y-m-d"),
'salary_cur' => 0,
]);
-
+
$this->info("Super Admin User '" . $data['name'] . "' successfully created. ");
} else {
$this->info("Super Admin User '" . $user['name'] . "' exists. ");
@@ -322,7 +322,7 @@ public function handle()
$user->attachRole($role);
$this->info("\nLaraAdmin successfully installed.");
$this->info("You can now login from yourdomain.com/" . config('laraadmin.adminRoute') . " !!!\n");
-
+
} else {
$this->error("Installation aborted. Please try again after backup / git. Thank you...");
}
@@ -336,7 +336,7 @@ public function handle()
}
}
}
-
+
/**
* Copy Folder contents
*
@@ -348,7 +348,7 @@ private function copyFolder($from, $to)
// $this->info("copyFolder: ($from, $to)");
LAHelper::recurse_copy($from, $to);
}
-
+
/**
* Replace Folder contents by deleting content of to folder first
*
@@ -363,7 +363,7 @@ private function replaceFolder($from, $to)
}
LAHelper::recurse_copy($from, $to);
}
-
+
/**
* Copy file contents. If file not exists create it.
*
@@ -379,7 +379,7 @@ private function copyFile($from, $to)
}
copy($from, $to);
}
-
+
/**
* Get file contents
*
@@ -391,7 +391,7 @@ private function openFile($from)
$md = file_get_contents($from);
return $md;
}
-
+
/**
* Append content of 'from' file to 'to' file
*
@@ -401,12 +401,12 @@ private function openFile($from)
private function appendFile($from, $to)
{
// $this->info("appendFile: ($from, $to)");
-
+
$md = file_get_contents($from);
-
+
file_put_contents($to, $md, FILE_APPEND);
}
-
+
/**
* Copy contents from one file to another
*
@@ -418,7 +418,7 @@ private function writeFile($from, $to)
$md = file_get_contents($from);
file_put_contents($to, $md);
}
-
+
/**
* does file contains given text
*
@@ -429,7 +429,7 @@ private function writeFile($from, $to)
private function fileContains($filePath, $text)
{
// TODO: Method not working properly
-
+
$fileData = file_get_contents($filePath);
if(strpos($fileData, $text) === false) {
return true;
diff --git a/src/Commands/Packaging.php b/src/Commands/Packaging.php
index 08a6be0d..57e5b37e 100644
--- a/src/Commands/Packaging.php
+++ b/src/Commands/Packaging.php
@@ -71,7 +71,7 @@ public function handle()
// Routes
$this->line('Exporting Routes...');
- if(LAHelper::laravel_ver() == 5.3) {
+ if(LAHelper::is_recent_laravel_version()) {
// $this->copyFile($from."/routes/web.php", $to."/app/routes.php"); // Not needed anymore
$this->copyFile($from . "/routes/admin_routes.php", $to . "/app/admin_routes.php");
} else {
diff --git a/src/Controllers/ModuleController.php b/src/Controllers/ModuleController.php
index 1844b6ce..b201130f 100644
--- a/src/Controllers/ModuleController.php
+++ b/src/Controllers/ModuleController.php
@@ -165,7 +165,7 @@ public function destroy($id)
}
// Delete Admin Routes
- if(LAHelper::laravel_ver() == 5.3) {
+ if(LAHelper::is_recent_laravel_version()) {
$file_admin_routes = base_path("/routes/admin_routes.php");
} else {
$file_admin_routes = base_path("/app/Http/admin_routes.php");
diff --git a/src/Helpers/LAHelper.php b/src/Helpers/LAHelper.php
index 3cf4703e..feeaf303 100644
--- a/src/Helpers/LAHelper.php
+++ b/src/Helpers/LAHelper.php
@@ -22,6 +22,8 @@
*/
class LAHelper
{
+
+ const RECENT_LARAVEL = 5.3;
/**
* Gives various names of Module in Object like label, table, model, controller, singular
*
@@ -36,7 +38,7 @@ public static function generateModuleNames($module_name, $icon)
$array = array();
$module_name = trim($module_name);
$module_name = str_replace(" ", "_", $module_name);
-
+
$array['module'] = ucfirst(str_plural($module_name));
$array['label'] = ucfirst(str_plural($module_name));
$array['table'] = strtolower(str_plural($module_name));
@@ -45,10 +47,10 @@ public static function generateModuleNames($module_name, $icon)
$array['controller'] = $array['module'] . "Controller";
$array['singular_l'] = strtolower(str_singular($module_name));
$array['singular_c'] = ucfirst(str_singular($module_name));
-
+
return (object)$array;
}
-
+
/**
* Get list of Database tables excluding LaraAdmin Context tables like
* backups, la_configs, la_menus, migrations, modules, module_fields, module_field_types
@@ -84,7 +86,7 @@ public static function getDBTables($remove_tables = [])
} else {
$tables = DB::select('SHOW TABLES');
}
-
+
$tables_out = array();
foreach($tables as $table) {
$table = (Array)$table;
@@ -112,15 +114,15 @@ public static function getDBTables($remove_tables = [])
$remove_tables = array_merge($remove_tables, $remove_tables2);
$remove_tables = array_unique($remove_tables);
$tables_out = array_diff($tables_out, $remove_tables);
-
+
$tables_out2 = array();
foreach($tables_out as $table) {
$tables_out2[$table] = $table;
}
-
+
return $tables_out2;
}
-
+
/**
* Get Array of All Modules
*
@@ -132,21 +134,21 @@ public static function getDBTables($remove_tables = [])
public static function getModuleNames($remove_modules = [])
{
$modules = Module::all();
-
+
$modules_out = array();
foreach($modules as $module) {
$modules_out[] = $module->name;
}
$modules_out = array_diff($modules_out, $remove_modules);
-
+
$modules_out2 = array();
foreach($modules_out as $module) {
$modules_out2[$module] = $module;
}
-
+
return $modules_out2;
}
-
+
/**
* Method to parse the dropdown, Multiselect, Taginput and radio values which are linked with
* either other tables via "@" e.g. "@employees" or string array of values
@@ -182,7 +184,7 @@ public static function parseValues($value)
}
return $valueOut;
}
-
+
/**
* Log method to log either in command line or in Log file depending on $type.
*
@@ -203,7 +205,7 @@ public static function log($type, $text, $commandObject)
Log::$type($text);
}
}
-
+
/**
* Method copies folder recursively into another
*
@@ -230,7 +232,7 @@ public static function recurse_copy($src, $dst)
}
closedir($dir);
}
-
+
/**
* Method deletes folder and its content
*
@@ -253,7 +255,7 @@ public static function recurse_delete($dir)
rmdir($dir);
}
}
-
+
/**
* Generate Random Password
*
@@ -283,7 +285,7 @@ public static function gen_password($chars_min = 6, $chars_max = 8, $use_upper_c
}
return $password;
}
-
+
/**
* Get url of image by using $upload_id
*
@@ -301,7 +303,7 @@ public static function img($upload_id)
return "";
}
}
-
+
/**
* Get Thumbnail image path of Uploaded image
*
@@ -355,7 +357,7 @@ public static function createThumbnail($filepath, $thumbpath, $thumbnail_width,
$imgt($new_image, $thumbpath);
return file_exists($thumbpath);
}
-
+
/**
* Print the menu editor view.
* This needs to be done recursively
@@ -367,9 +369,11 @@ public static function createThumbnail($filepath, $thumbpath, $thumbnail_width,
*/
public static function print_menu_editor($menu)
{
+
$editing = \Collective\Html\FormFacade::open(['route' => [config('laraadmin.adminRoute') . '.la_menus.destroy', $menu->id], 'method' => 'delete', 'style' => 'display:inline']);
$editing .= '';
$editing .= \Collective\Html\FormFacade::close();
+
if($menu->type != "module") {
$info = (object)array();
$info->id = $menu->id;
@@ -377,15 +381,16 @@ public static function print_menu_editor($menu)
$info->url = $menu->url;
$info->type = $menu->type;
$info->icon = $menu->icon;
-
+
$editing .= '';
+ // dd($editing);
}
$str = '
' . $menu->name . ' ' . $editing . '
';
-
+
$childrens = \Dwij\Laraadmin\Models\Menu::where("parent", $menu->id)->orderBy('hierarchy', 'asc')->get();
-
+
if(count($childrens) > 0) {
$str .= '';
foreach($childrens as $children) {
@@ -394,9 +399,10 @@ public static function print_menu_editor($menu)
$str .= '
';
}
$str .= '';
+
return $str;
}
-
+
/**
* Print the sidebar menu view.
* This needs to be done recursively
@@ -420,9 +426,9 @@ public static function print_menu($menu, $active = false)
if($active) {
$active_str = 'class="active"';
}
-
+
$str = 'url) . '"> ' . LAHelper::real_module_name($menu->name) . ' ' . $subviewSign . '';
-
+
if(count($childrens)) {
$str .= '';
return $str;
}
-
+
/**
* Print the top navbar menu view.
* This needs to be done recursively
@@ -450,7 +456,7 @@ public static function print_menu($menu, $active = false)
public static function print_menu_topnav($menu, $active = false)
{
$childrens = \Dwij\Laraadmin\Models\Menu::where("parent", $menu->id)->orderBy('hierarchy', 'asc')->get();
-
+
$treeview = "";
$treeview2 = "";
$subviewSign = "";
@@ -463,9 +469,9 @@ public static function print_menu_topnav($menu, $active = false)
if($active) {
$active_str = 'class="active"';
}
-
+
$str = 'url) . '">' . LAHelper::real_module_name($menu->name) . $subviewSign . '';
-
+
if(count($childrens)) {
$str .= '';
return $str;
}
-
- /**
+ public static function is_recent_laravel_version()
+ {
+ return self::laravel_ver() >= self::RECENT_LARAVEL;
+ }
+ /**
* Get laravel version. very important in installation and handling Laravel 5.3 changes.
*
* LAHelper::laravel_ver()
@@ -487,19 +496,22 @@ public static function print_menu_topnav($menu, $active = false)
public static function laravel_ver()
{
$var = \App::VERSION();
-
+
if(starts_with($var, "5.2")) {
return 5.2;
} else if(starts_with($var, "5.3")) {
return 5.3;
- } else if(substr_count($var, ".") == 3) {
+ } else if(starts_with($var, "5.4")) {
+ return 5.4;
+ }
+ else if(substr_count($var, ".") == 3) {
$var = substr($var, 0, strrpos($var, "."));
return $var . "-str";
} else {
return floatval($var);
}
}
-
+
/**
* Get real Module name by replacing underscores within name
*
@@ -511,7 +523,7 @@ public static function real_module_name($name)
$name = str_replace('_', ' ', $name);
return $name;
}
-
+
/**
* Get complete line within file by comparing passed substring $str
*
@@ -531,7 +543,7 @@ public static function getLineWithString($fileName, $str)
}
return -1;
}
-
+
/**
* Get complete line within given file contents by comparing passed substring $str
*
@@ -551,7 +563,7 @@ public static function getLineWithString2($content, $str)
}
return -1;
}
-
+
/**
* Method sets parameter in ".env" file as well as into php environment.
*
@@ -562,16 +574,16 @@ public static function getLineWithString2($content, $str)
*/
public static function setenv($param, $value)
{
-
+
$envfile = LAHelper::openFile('.env');
$line = LAHelper::getLineWithString('.env', $param . '=');
$envfile = str_replace($line, $param . "=" . $value . "\n", $envfile);
file_put_contents('.env', $envfile);
-
+
$_ENV[$param] = $value;
putenv($param . "=" . $value);
}
-
+
/**
* Get file contents
*
@@ -583,7 +595,7 @@ public static function openFile($from)
$md = file_get_contents($from);
return $md;
}
-
+
/**
* Delete file
*
@@ -597,7 +609,7 @@ public static function deleteFile($file_path)
unlink($file_path);
}
}
-
+
/**
* Get Migration file name by passing matching table name
*
@@ -619,7 +631,7 @@ public static function get_migration_file($file_name)
}
return "";
}
-
+
/**
* Check if passed array is associative
*
@@ -630,7 +642,7 @@ public static function is_assoc_array(array $array)
{
// Keys of the array
$keys = array_keys($array);
-
+
// If the array keys of the keys match the keys, then the array must
// not be associative (e.g. the keys array looked like {0:0, 1:1...}).
return array_keys($keys) !== $keys;
diff --git a/src/Installs/app/Controllers/Controller.php b/src/Installs/app/Controllers/Controller.php
index d492e0b3..03e02a23 100644
--- a/src/Installs/app/Controllers/Controller.php
+++ b/src/Installs/app/Controllers/Controller.php
@@ -6,9 +6,8 @@
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
-use Illuminate\Foundation\Auth\Access\AuthorizesResources;
class Controller extends BaseController
{
- use AuthorizesRequests, AuthorizesResources, DispatchesJobs, ValidatesRequests;
+ use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
}
diff --git a/src/Installs/app/Controllers/Controller.5.3.php b/src/Installs/app/Controllers/Legacy.Controller.php
similarity index 67%
rename from src/Installs/app/Controllers/Controller.5.3.php
rename to src/Installs/app/Controllers/Legacy.Controller.php
index 03e02a23..d492e0b3 100644
--- a/src/Installs/app/Controllers/Controller.5.3.php
+++ b/src/Installs/app/Controllers/Legacy.Controller.php
@@ -6,8 +6,9 @@
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
+use Illuminate\Foundation\Auth\Access\AuthorizesResources;
class Controller extends BaseController
{
- use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
+ use AuthorizesRequests, AuthorizesResources, DispatchesJobs, ValidatesRequests;
}
diff --git a/src/Installs/app/Models/User5.3.php b/src/Installs/app/Models/Legacy.User.php
similarity index 81%
rename from src/Installs/app/Models/User5.3.php
rename to src/Installs/app/Models/Legacy.User.php
index 38738f03..d35f7da8 100644
--- a/src/Installs/app/Models/User5.3.php
+++ b/src/Installs/app/Models/Legacy.User.php
@@ -6,28 +6,22 @@
* Developed by: Dwij IT Solutions
* Developer Website: http://dwijitsolutions.com
*/
-
namespace App;
-
-use Illuminate\Notifications\Notifiable;
-use Illuminate\Foundation\Auth\User as Authenticatable;
+use Illuminate\Auth\Authenticatable;
use Illuminate\Auth\Passwords\CanResetPassword;
+use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
use Illuminate\Contracts\Auth\Access\Authorizable as AuthorizableContract;
use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract;
-
use Illuminate\Database\Eloquent\Model;
// use Illuminate\Database\Eloquent\SoftDeletes;
use Zizaco\Entrust\Traits\EntrustUserTrait;
-
-class User extends Authenticatable implements AuthorizableContract, CanResetPasswordContract
+class User extends Model implements AuthenticatableContract, AuthorizableContract, CanResetPasswordContract
{
- use Notifiable;
- use CanResetPassword;
+ use Authenticatable, CanResetPassword;
// use SoftDeletes;
use EntrustUserTrait;
-
protected $table = 'users';
-
+
/**
* The attributes that are mass assignable.
*
@@ -36,7 +30,7 @@ class User extends Authenticatable implements AuthorizableContract, CanResetPass
protected $fillable = [
'name', 'email', 'password', "role", "context_id", "type"
];
-
+
/**
* The attributes that should be hidden for arrays.
*
@@ -45,9 +39,8 @@ class User extends Authenticatable implements AuthorizableContract, CanResetPass
protected $hidden = [
'password', 'remember_token',
];
-
- // protected $dates = ['deleted_at'];
+ // protected $dates = ['deleted_at'];
/**
* @return mixed
*/
diff --git a/src/Installs/app/Models/User.php b/src/Installs/app/Models/User.php
index 5a49490d..045f151f 100644
--- a/src/Installs/app/Models/User.php
+++ b/src/Installs/app/Models/User.php
@@ -6,27 +6,23 @@
* Developed by: Dwij IT Solutions
* Developer Website: http://dwijitsolutions.com
*/
-
namespace App;
-
-use Illuminate\Auth\Authenticatable;
+use Illuminate\Notifications\Notifiable;
+use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Auth\Passwords\CanResetPassword;
-use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
use Illuminate\Contracts\Auth\Access\Authorizable as AuthorizableContract;
use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract;
-
use Illuminate\Database\Eloquent\Model;
// use Illuminate\Database\Eloquent\SoftDeletes;
use Zizaco\Entrust\Traits\EntrustUserTrait;
-
-class User extends Model implements AuthenticatableContract, AuthorizableContract, CanResetPasswordContract
+class User extends Authenticatable implements AuthorizableContract, CanResetPasswordContract
{
- use Authenticatable, CanResetPassword;
+ use Notifiable;
+ use CanResetPassword;
// use SoftDeletes;
use EntrustUserTrait;
-
protected $table = 'users';
-
+
/**
* The attributes that are mass assignable.
*
@@ -35,7 +31,7 @@ class User extends Model implements AuthenticatableContract, AuthorizableContrac
protected $fillable = [
'name', 'email', 'password', "role", "context_id", "type"
];
-
+
/**
* The attributes that should be hidden for arrays.
*
@@ -44,9 +40,8 @@ class User extends Model implements AuthenticatableContract, AuthorizableContrac
protected $hidden = [
'password', 'remember_token',
];
-
- // protected $dates = ['deleted_at'];
+ // protected $dates = ['deleted_at'];
/**
* @return mixed
*/
diff --git a/src/Installs/app/admin_routes.php b/src/Installs/app/admin_routes.php
index 3814dd63..90c9903a 100644
--- a/src/Installs/app/admin_routes.php
+++ b/src/Installs/app/admin_routes.php
@@ -15,7 +15,7 @@
*/
$as = "";
-if(\Dwij\Laraadmin\Helpers\LAHelper::laravel_ver() == 5.3) {
+if(\Dwij\Laraadmin\Helpers\LAHelper::is_recent_laravel_version()) {
$as = config('laraadmin.adminRoute').'.';
// Routes for Laravel 5.3
diff --git a/src/Installs/gulpfile.js b/src/Installs/gulpfile.js
deleted file mode 100644
index 676c74f4..00000000
--- a/src/Installs/gulpfile.js
+++ /dev/null
@@ -1,22 +0,0 @@
-// var elixir = require('laravel-elixir');
-
-elixir(function(mix) {
- mix.less('admin-lte/AdminLTE.less', 'public/la-assets/css');
- mix.less('bootstrap/bootstrap.less', 'public/la-assets/css');
-});
-
-/*
-var minify = require('gulp-minify');
-gulp.task('compress', function() {
- gulp.src('lib/*.js')
- .pipe(minify({
- ext:{
- src:'-debug.js',
- min:'.js'
- },
- exclude: ['tasks'],
- ignoreFiles: ['.combo.js', '-min.js']
- }))
- .pipe(gulp.dest('dist'))
-});
-*/
\ No newline at end of file
diff --git a/src/Installs/migrations/2014_05_26_060000_create_module_fields_table.php b/src/Installs/migrations/2014_05_26_060000_create_module_fields_table.php
index e62d497f..8cd35b26 100644
--- a/src/Installs/migrations/2014_05_26_060000_create_module_fields_table.php
+++ b/src/Installs/migrations/2014_05_26_060000_create_module_fields_table.php
@@ -24,12 +24,12 @@ public function up()
$table->increments('id');
$table->string('colname', 30);
$table->string('label', 100);
- $table->integer('module')->unsigned();
+ $table->unsignedInteger('module')->nullable();
$table->foreign('module')->references('id')->on('modules')->onUpdate('cascade')->onDelete('cascade');
- $table->integer('field_type')->unsigned();
+ $table->unsignedInteger('field_type')->nullable();
$table->foreign('field_type')->references('id')->on('module_field_types')->onUpdate('cascade')->onDelete('cascade');
$table->boolean('unique')->default(false);
- $table->string('defaultvalue');
+ $table->string('defaultvalue')->nullable();
$table->integer('minlength')->unsigned()->default(0);
$table->integer('maxlength')->unsigned()->default(0);
$table->boolean('required')->default(false);
diff --git a/src/Installs/migrations/2016_07_05_115343_create_role_user_table.php b/src/Installs/migrations/2016_07_05_115343_create_role_user_table.php
index 4ca3fb60..c084353e 100644
--- a/src/Installs/migrations/2016_07_05_115343_create_role_user_table.php
+++ b/src/Installs/migrations/2016_07_05_115343_create_role_user_table.php
@@ -23,9 +23,9 @@ public function up()
Schema::create('role_user', function(Blueprint $table)
{
$table->increments('id');
- $table->integer('role_id')->unsigned();
+ $table->unsignedInteger('role_id')->nullable();
$table->foreign('role_id')->references('id')->on('roles')->onUpdate('cascade')->onDelete('cascade');
- $table->integer('user_id')->unsigned();
+ $table->unsignedInteger('user_id')->nullable();
$table->foreign('user_id')->references('id')->on('users')->onUpdate('cascade')->onDelete('cascade');
$table->timestamps();
});
diff --git a/src/Installs/migrations/2016_09_10_163520_create_permission_role_table.php b/src/Installs/migrations/2016_09_10_163520_create_permission_role_table.php
index 716a387b..e012d335 100644
--- a/src/Installs/migrations/2016_09_10_163520_create_permission_role_table.php
+++ b/src/Installs/migrations/2016_09_10_163520_create_permission_role_table.php
@@ -22,8 +22,8 @@ public function up()
{
// Create table for associating permissions to roles (Many-to-Many)
Schema::create('permission_role', function (Blueprint $table) {
- $table->integer('permission_id')->unsigned();
- $table->integer('role_id')->unsigned();
+ $table->unsignedInteger('permission_id')->nullable();
+ $table->unsignedInteger('role_id')->nullable();
$table->foreign('permission_id')->references('id')->on('permissions')
->onUpdate('cascade')->onDelete('cascade');
diff --git a/src/Installs/migrations/2016_09_22_105958_role_module_fields_table.php b/src/Installs/migrations/2016_09_22_105958_role_module_fields_table.php
index dfbdb4ec..0ab73c7c 100644
--- a/src/Installs/migrations/2016_09_22_105958_role_module_fields_table.php
+++ b/src/Installs/migrations/2016_09_22_105958_role_module_fields_table.php
@@ -23,9 +23,9 @@ public function up()
Schema::create('role_module_fields', function(Blueprint $table)
{
$table->increments('id');
- $table->integer('role_id')->unsigned();
+ $table->unsignedInteger('role_id')->nullable();
$table->foreign('role_id')->references('id')->on('roles')->onUpdate('cascade')->onDelete('cascade');
- $table->integer('field_id')->unsigned();
+ $table->unsignedInteger('field_id')->nullable();
$table->foreign('field_id')->references('id')->on('module_fields')->onUpdate('cascade')->onDelete('cascade');
$table->enum('access', ['invisible', 'readonly', 'write']);
$table->timestamps();
diff --git a/src/Installs/migrations/2016_09_22_110008_role_module_table.php b/src/Installs/migrations/2016_09_22_110008_role_module_table.php
index 5a05bd29..eecae3c8 100644
--- a/src/Installs/migrations/2016_09_22_110008_role_module_table.php
+++ b/src/Installs/migrations/2016_09_22_110008_role_module_table.php
@@ -23,9 +23,9 @@ public function up()
Schema::create('role_module', function(Blueprint $table)
{
$table->increments('id');
- $table->integer('role_id')->unsigned();
+ $table->unsignedInteger('role_id')->nullable();
$table->foreign('role_id')->references('id')->on('roles')->onUpdate('cascade')->onDelete('cascade');
- $table->integer('module_id')->unsigned();
+ $table->unsignedInteger('module_id')->nullable();
$table->foreign('module_id')->references('id')->on('modules')->onUpdate('cascade')->onDelete('cascade');
$table->boolean('acc_view');
$table->boolean('acc_create');
diff --git a/src/Installs/resources/views/la/modules/field_edit.blade.php b/src/Installs/resources/views/la/modules/field_edit.blade.php
index 09714f21..a27a0cb0 100644
--- a/src/Installs/resources/views/la/modules/field_edit.blade.php
+++ b/src/Installs/resources/views/la/modules/field_edit.blade.php
@@ -11,29 +11,29 @@
@section("main-content")
{!! Form::model($field, ['route' => [config('laraadmin.adminRoute') . '.module_fields.update', $field->id ], 'method'=>'PUT', 'id' => 'field-edit-form']) !!}
{{ Form::hidden("module_id", $module->id) }}
-
+
- {{ Form::text("label", null, ['class'=>'form-control', 'placeholder'=>'Field Label', 'data-rule-minlength' => 2, 'data-rule-maxlength'=>20, 'required' => 'required']) }}
+ {{ Form::text("label", null, ['class'=>'form-control', 'placeholder'=>'Field Label', 'data-rule-minlength' => 2, 'data-rule-maxlength'=>30, 'required' => 'required']) }}
-
+
- {{ Form::text("colname", null, ['class'=>'form-control', 'placeholder'=>'Column Name (lowercase)', 'data-rule-minlength' => 2, 'data-rule-maxlength'=>20, 'data-rule-banned-words' => 'true', 'required' => 'required']) }}
+ {{ Form::text("colname", null, ['class'=>'form-control', 'placeholder'=>'Column Name (lowercase)', 'data-rule-minlength' => 2, 'data-rule-maxlength'=>30, 'data-rule-banned-words' => 'true', 'required' => 'required']) }}
-
+
{{ Form::select("field_type", $ftypes, null, ['class'=>'form-control', 'required' => 'required']) }}
-
+
@@ -46,19 +46,19 @@
{{ Form::text("defaultvalue", null, ['class'=>'form-control', 'placeholder'=>'Default Value']) }}
-
+
{{ Form::number("minlength", null, ['class'=>'form-control', 'placeholder'=>'Default Value']) }}
-
+
{{ Form::number("maxlength", null, ['class'=>'form-control', 'placeholder'=>'Default Value']) }}
-
+
-
+
{{ Form::radio("popup_value_type", "list", $popup_value_type_list) }} From List
{{ Form::select("popup_vals_table", $tables, $default_val, ['class'=>'form-control', 'rel' => '']) }}
-
+
-
+
-
+
{!! Form::close() !!}
-
+
@if($errors->any())
@foreach($errors->all() as $error)
@@ -130,7 +130,7 @@
$("select.popup_vals_list").show();
$("select.popup_vals_list").next().show();
$("select[name='popup_vals_table']").hide();
-
+
function showValuesSection() {
var ft_val = $("select[name='field_type']").val();
if(ft_val == 7 || ft_val == 15 || ft_val == 18 || ft_val == 20) {
@@ -138,12 +138,12 @@ function showValuesSection() {
} else {
$(".form-group.values").hide();
}
-
+
$('#length_div').removeClass("hide");
if(ft_val == 2 || ft_val == 4 || ft_val == 5 || ft_val == 7 || ft_val == 9 || ft_val == 11 || ft_val == 12 || ft_val == 15 || ft_val == 18 || ft_val == 21 || ft_val == 24 ) {
$('#length_div').addClass("hide");
}
-
+
$('#unique_val').removeClass("hide");
if(ft_val == 1 || ft_val == 2 || ft_val == 3 || ft_val == 7 || ft_val == 9 || ft_val == 11 || ft_val == 12 || ft_val == 15 || ft_val == 18 || ft_val == 20 || ft_val == 21 || ft_val == 24 ) {
$('#unique_val').addClass("hide");
@@ -167,7 +167,7 @@ function showValuesTypes() {
$("select.popup_vals_list").next().hide();
}
}
-
+
$("input[name='popup_value_type']").on("change", function() {
showValuesTypes();
});
@@ -178,8 +178,8 @@ function showValuesTypes() {
}, "Column name not allowed.");
$("#field-edit-form").validate({
-
+
});
});
-@endpush
\ No newline at end of file
+@endpush
diff --git a/src/Installs/resources/views/la/modules/index.blade.php b/src/Installs/resources/views/la/modules/index.blade.php
index 0603d8b8..3b3f9f4b 100644
--- a/src/Installs/resources/views/la/modules/index.blade.php
+++ b/src/Installs/resources/views/la/modules/index.blade.php
@@ -30,7 +30,7 @@
Actions |
-
+
@foreach ($modules as $module)
@@ -63,8 +63,8 @@
+ {{ Form::text("name", null, ['class'=>'form-control', 'placeholder'=>'Module Name', 'data-rule-minlength' => 2, 'data-rule-maxlength'=>30, 'required' => 'required']) }}
+
-->
@@ -221,7 +221,7 @@
success: function(data) {
var files = data.files;
var filesList = "";
- for ($i = 0; $i < files.length; $i++) {
+ for ($i = 0; $i < files.length; $i++) {
filesList += "- " + files[$i] + "
";
}
filesList += "
";
@@ -231,11 +231,11 @@
});
$('.update_module').on("click", function () {
- var module_id = $(this).attr('module_id');
+ var module_id = $(this).attr('module_id');
var module_label = $(this).attr('module_label');
var module_icon = $(this).attr('module_icon');
$(".module_label_edit").val(module_label);
- $(".module_icon_edit").val(module_icon);
+ $(".module_icon_edit").val(module_icon);
$("#module_update").modal('show');
$(".update-icon").html('');
@@ -252,13 +252,13 @@
});
});
});
-
+
$('input[name=icon]').iconpicker();
$("#dt_modules").DataTable({
-
+
});
$("#module-add-form").validate({
-
+
});
});
diff --git a/src/Installs/resources/views/la/modules/show.blade.php b/src/Installs/resources/views/la/modules/show.blade.php
index b9f13b6d..dd8dacc2 100644
--- a/src/Installs/resources/views/la/modules/show.blade.php
+++ b/src/Installs/resources/views/la/modules/show.blade.php
@@ -40,7 +40,7 @@
@endif
-
+
@if($module->view_col != "")
@if(isset($module->is_gen) && $module->is_gen)
@@ -48,14 +48,14 @@
@else
-
+
@endif
@else
To generate Migration or CRUD, set the view column using the icon next to a column
@endif
-
+
@@ -63,19 +63,19 @@
@@ -105,7 +105,7 @@
|
-
+
@foreach ($module->fields as $field)
{{ $field['sort'] }} |
@@ -173,7 +173,7 @@
@foreach($roles as $role)
{{ $role->name }} |
-
+
view == 1) { echo 'checked="checked"'; } ?> > |
create == 1) { echo 'checked="checked"'; } ?> > |
edit == 1) { echo 'checked="checked"'; } ?> > |
@@ -241,7 +241,7 @@
{{ Form::open(['route' => [config('laraadmin.adminRoute') . '.modules.destroy', 0], 'id' => 'module_del_form', 'method' => 'delete', 'style'=>'display:inline']) }}
{{ Form::close() }}
- No
+ No
@@ -262,9 +262,9 @@
- {{ Form::text("label", null, ['class'=>'form-control', 'placeholder'=>'Field Label', 'data-rule-minlength' => 2, 'data-rule-maxlength'=>20, 'required' => 'required']) }}
+ {{ Form::text("label", null, ['class'=>'form-control', 'placeholder'=>'Field Label', 'data-rule-minlength' => 2, 'data-rule-maxlength'=>30, 'required' => 'required']) }}
-
+
getDefault();
- }
- $col_list[$col] = $col." - ".$column->getType().' - '.$column->getLength().' - '.$default;
+ }
+ $col_list[$col] = $col." - ".$column->getType().' - '.$column->getLength().' - '.$default;
}
}
if($module->is_gen == 0 && count($col_list) > 0) { ?>
{{ Form::select("colname", $col_list, $col_list, ['class'=>'form-control', 'required' => 'required']) }}
- {{ Form::text("colname", null, ['class'=>'form-control', 'placeholder'=>'Column Name (lowercase)', 'data-rule-minlength' => 2, 'data-rule-maxlength'=>20, 'data-rule-banned-words' => 'true', 'required' => 'required']) }}
+ {{ Form::text("colname", null, ['class'=>'form-control', 'placeholder'=>'Column Name (lowercase)', 'data-rule-minlength' => 2, 'data-rule-maxlength'=>30, 'data-rule-banned-words' => 'true', 'required' => 'required']) }}
-
+
{{ Form::select("field_type", $ftypes, null, ['class'=>'form-control', 'required' => 'required']) }}
-
+
-
+
+
@@ -317,19 +317,19 @@
{{ Form::number("minlength", null, ['class'=>'form-control', 'placeholder'=>'Minimum Value']) }}
-
+
{{ Form::number("maxlength", null, ['class'=>'form-control', 'placeholder'=>'Maximum Value']) }}
-
+
-
+
{{ Form::checkbox("listing_col", "listing_col", false, []) }}
@@ -341,7 +341,7 @@
{{-- Form::text("popup_vals", null, ['class'=>'form-control', 'placeholder'=>'Popup Values (Only for Radio, Dropdown, Multiselect, Taginput)']) --}}
-->
-
+
-
+