initializeFields(); } protected function initializeFields() { self::$imageFields = array( 'image', 'logo', 'signature', 'cover_photo', 'featured_image', 'image_thumb', 'primary_logo', 'secondary_logo', 'thumb_image', 'thumb', 'cover', 'photo', 'passport_copy', 'icon', 'favicon', 'og_image', 'no_image' ); self::$textEditorFields = array('details', 'description', 'text', 'qualification', 'experience', 'required_documents', 'biodata', 'privacy_policy', 'content1', 'content2', 'content3'); self::$textAreaFields = array('copyright', 'remarks', 'seo_keywords', 'seo_description', 'seo_descriptions', 'intro', 'meta_tags', 'google_map', 'og_tags'); self::$dateFields = array('dob', 'postedon', 'valid_till', 'startdate', 'enddate', 'from', 'to', 'starts', 'ends'); self::$passwordFields = array('password'); self::$HiddenCols = array("createdby", "updatedby", "updated_at", "created_at", "status", "alias", "display_order", "is_main", 'email_verified_at'); } protected function getImageFields() { return $this->imageFields; } protected function gettextEditorFields() { return $this->textEditorFields; } public function create() { $tables = DB::select('SHOW TABLES'); try { $databasdeName = DB::connection()->getDatabaseName(); $allTables = []; foreach ($tables as $table) { $table_field = "Tables_in_$databasdeName"; // dd($table->$table_field); if(strpos($table->$table_field,"_logs")){continue;} $allTables[$table->$table_field] = $table->$table_field; } return view('crud.form.create', compact('allTables')); } catch (Exception $e) { dd($e->getMessage()); } } public function store(Request $request) { // dd($request->all()); $request->validate([ 'type' => 'required', 'tableName' => 'required', ]); $name = trim($request->type); $command = $name; $tableName = trim($request->tableName); $directoryName = trim($request->directoryName); switch ($command) { case 'dictonary': $data['tableName'] = "tbl_dictonary"; if ($tableName != "") { switch ($tableName) { case 'add': $data['TableCols'] = DB::select("describe " . $data['tableName']); return view("crud.settings.dictonary/add", $data); default: $data['TableRows'] = DB::select("select * from " . $data['tableName']); return view("crud.settings.dictonary.list", $data); } } $data['TableName'] = "tbl_dictonary"; $data['TableRows'] = DB::select("select * from " . $data['TableName']); return view("crud.settings.dictonary", $data); case 'curd': $data['tableName'] = $tableName; $data['directoryName'] = $directoryName; return view("crud.settings.curd", $data); break; case 'ajax-curd': $data['tableName'] = $tableName; $data['directoryName'] = $directoryName; $columns = DB::select("describe $tableName"); // users table return view("crud.settings.ajax-curd", $data); break; default: return view("crud.settings.home"); } } public function getTableNullablecreate() { return view("crud.settings.ajax-curd"); } public function tables() { $AllTables = DB::select('SHOW TABLES'); try { $databasdeName = DB::connection()->getDatabaseName(); $allTables = []; foreach ($AllTables as $table) { $myTable = new stdClass; //$allTables[]=$table['Tables_in_'.$databasdeName]; $key = "Tables_in_" . $databasdeName; $table->columns = DB::select("SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = '" . $table->$key . "'"); $myTable->tablename = $table->$key; $myTable->tablecolumns = $table->columns; $allTables[] = $myTable; } return view('crud.form.tables', compact('allTables')); } catch (Exception $e) { dd($e->getMessage()); } } public static function getForeignTable($all_columns) { $string = '_id'; $foreign = []; foreach ($all_columns as $key => $column) { if (str_contains($column, $string) !== FALSE) { // Yoshi version $foreign[] = $column; } } unset($foreign[0]); $strArray = []; foreach ($foreign as $key => $foreignKey) { $strArray[$key] = explode('_id', $foreignKey); unset($strArray[$key][1]); } if ($strArray) { $all_Foreign_Key_Table = call_user_func_array('array_merge', $strArray); foreach ($all_Foreign_Key_Table as $column) { $tableName[] = "tbl_" . $column; } return $tableName; } else { return []; } } public static function getTableColumns($TableName) { return array_column(DB::select("SHOW COLUMNS FROM $TableName"), 'Field'); } public static function ajaxShowContent($TableName, $directoryName) { $TableName = strtolower($TableName); $TableCols = DB::select("describe " . $TableName); $TableRows = DB::select("select * from " . $TableName); $folder = ''; $routeName = ''; if (!empty($directoryName)) { $folder .= strtolower($directoryName) . '/'; $routeName .= strtolower($directoryName) . '.'; } $routeName .= strtolower(str_replace("tbl_", "", $TableName)); $folder .= str_replace("tbl_", "", $TableName); $Table_pk = str_replace("tbl_", "", $TableName) . "_id"; $title = ucwords(str_replace("tbl_", "", $TableName)); $showContent = " "; foreach ($TableCols as $key => $TableCol): $TableCol = $TableCol->Field; if ($key == 0 || $TableCol == 'createdOn' || $TableCol == 'createdBy' || $TableCol == 'updatedBy' || $TableCol == 'created_at' || $TableCol == 'updated_at') continue; $TableColLabel = ucwords(str_replace("_", " ", $TableCol)); if ($TableCol == 'status') $showContent .= "
Status : $TableCol == 1 ? 'text-success' : 'text-danger'}}\">{{\$data->$TableCol == 1 ? 'Active' : 'Inactive'}}
"; else $showContent .= '' . $TableColLabel . " : {{\$data->$TableCol}}
"; endforeach; $showContent .= "Created On : {{\$data->created_at}}
Created By : {{\$data->createdBy}}
Updated On : {{\$data->updated_at}}
Updated By : {{\$data->updatedBy}}