"; print_r($array); echo ""; } public static function addButton($path, $text) { ?>
  • "; BibClass::addButton("edit/$pk", 'Edit'); BibClass::addButton("view/$pk", 'View'); BibClass::addButton("destroy/$pk", 'Delete'); } public static function getController() { $routeArray = app('request')->route()->getAction(); $controllerAction = class_basename($routeArray['controller']); list($controller, $action) = explode('@', $controllerAction); print_r($controller); } public static function createSidebarMenu($link, $name, $target = "") { ?>
  • >
  • Field . "',\n"; endforeach; $contentString = "status == 1 ? ' Active ' : 'Inactive'; } protected function createdBy(): Attribute { return Attribute::make( get: fn (\$value) => User::find(\$value) ? User::find(\$value)->name : '', ); } protected function updatedBy(): Attribute { return Attribute::make( get: fn (\$value) => User::find(\$value) ? User::find(\$value)->name : '', ); } }"; $modelPath = ''; if (!empty($directoryName)) { $modelPath .= ucfirst($directoryName) . '/'; } if (!file_exists(base_path() .'/app/Models/' . $modelPath)) { mkdir(base_path() .'/app/Models/' . $modelPath, 0777, true); } $filename = $modelClass . ".php"; if (!file_exists(base_path() ."/app/Models/" . $modelPath . $filename)) { $file = fopen(base_path() ."/app/Models/" . $modelPath . $filename, 'w'); fwrite($file, $contentString); fclose($file); } return $contentString; } public static function controllerContent($tableName, $directoryName) { $tableFields = DB::select("describe $tableName"); $pkField = str_replace("tbl_", "", $tableName) . "_id"; $controllerName = ucfirst(str_replace("tbl_", "", $tableName)) . "Controller"; $viewName = ''; $controllerPath = ''; $modelName = ''; if (!empty($directoryName)) { $viewName .= strtolower($directoryName) . '.'; $controllerPath .= "\\" . ucfirst($directoryName); $modelName .= ucfirst($directoryName) . '\\'; } $modelName .= ucfirst(str_replace("tbl_", "", $tableName)); $viewName .= strtolower(str_replace("tbl_", "", $tableName)); $modelClass = ucfirst(str_replace("tbl_", "", $tableName)); $tableAliasColumnName = str_replace("tbl_", "", $tableName) . 'Name'; $contentString = "modelService = new CommonModelService(\$model); } public function index(Request \$request) { createActivityLog($controllerName::class, 'index', '$directoryName $modelClass index'); \$data = $modelClass::where('status','<>',-1)->orderBy('created_at','desc')->get(); if (\$request->ajax()) { \$html = view(\"dftqc.$viewName.ajax_index\", compact('data'))->render(); return response()->json(['status' => true, 'content' => \$html], 200); } return view(\"dftqc.$viewName.index\", compact('data')); } public function create(Request \$request) { createActivityLog($controllerName::class, 'create', '$directoryName $modelClass create'); if (\$request->ajax()) { \$html = view(\"dftqc.$viewName.ajax.create\")->render(); return response()->json(['status' => true, 'content' => \$html], 200); } return view(\"dftqc.$viewName.create\"); } public function store(Request \$request) { createActivityLog($controllerName::class, 'store', '$directoryName $modelClass store'); \$validator = Validator::make(\$request->all(), [ //ADD REQUIRED FIELDS FOR VALIDATION ]); if (\$validator->fails()) { return response()->json([ 'error' => \$validator->errors(), ],500); } \$request->request->add(['alias' => slugify(\$request->$tableAliasColumnName)]); DB::beginTransaction(); try { \$operationNumber = getOperationNumber(); \$this->modelService->create(\$operationNumber, \$operationNumber, null, \$request->all()); } catch (\Exception \$e) { DB::rollBack(); Log::info(\$e->getMessage()); createErrorLog($controllerName::class, 'store', \$e->getMessage()); return response()->json(['status' => false, 'message' => \$e->getMessage()], 500); } DB::commit(); if (\$request->ajax()) { return response()->json(['status' => true, 'message' => 'The $modelClass Created Successfully.'], 200); } return redirect()->route('$viewName.index')->with('success','The $modelClass created Successfully.'); } public function show(Request \$request, \$id) { createActivityLog($controllerName::class, 'show', '$directoryName $modelClass show'); \$data = $modelClass::findOrFail(\$id); if (\$request->ajax()) { \$html = view(\"dftqc.$viewName.ajax.show\", compact('data'))->render(); return response()->json(['status' => true, 'content' => \$html], 200); } return view(\"dftqc.$viewName.show\", compact('data')); } public function edit(Request \$request, \$id) { createActivityLog($controllerName::class, 'edit', '$directoryName $modelClass edit'); \$data = $modelClass::findOrFail(\$id); if (\$request->ajax()) { \$html = view(\"dftqc.$viewName.ajax.edit\", compact('data'))->render(); return response()->json(['status' => true, 'content' => \$html], 200); } return view(\"dftqc.$viewName.edit\", compact('data')); } public function update(Request \$request, \$id) { createActivityLog($controllerName::class, 'update', '$directoryName $modelClass update'); \$validator = Validator::make(\$request->all(), [ //ADD VALIDATION FOR REQIRED FIELDS ]); if (\$validator->fails()) { return response()->json([ 'error' => \$validator->errors(), ],500); } \$request->request->add(['alias' => slugify(\$request->$tableAliasColumnName)]); DB::beginTransaction(); try { \$OperationNumber = getOperationNumber(); \$this->modelService->update(\$OperationNumber, \$OperationNumber, null, \$request->all(), \$id); } catch (Exception \$e) { DB::rollBack(); Log::info(\$e->getMessage()); createErrorLog($controllerName::class, 'update', \$e->getMessage()); return response()->json(['status' => false, 'message' => \$e->getMessage()], 500); } DB::commit(); if (\$request->ajax()) { return response()->json(['status' => true, 'message' => 'The $modelClass updated Successfully.'], 200); } return redirect()->route('$viewName.index')->with('success','The $modelClass updated Successfully.'); } public function destroy(Request \$request,\$id) { createActivityLog($controllerName::class, 'destroy', '$directoryName $modelClass destroy'); DB::beginTransaction(); try { \$OperationNumber = getOperationNumber(); \$this->modelService->destroy(\$OperationNumber, \$OperationNumber, \$id); } catch (Exception \$e) { DB::rollBack(); Log::info(\$e->getMessage()); createErrorLog($controllerName::class, 'destroy', \$e->getMessage()); return response()->json(['status' => false, 'message' => \$e->getMessage()], 500); } DB::commit(); return response()->json(['status'=>true,'message'=>'The $modelClass Deleted Successfully.'],200); } public static function getAjaxContent(\$type, \$id = '', \$option = '') { switch (\$type) { case 'index': \$data = $modelClass::where('status', '<>', -1)->get(); return view(\"dftqc.$viewName.ajax.index\", compact('data'))->render(); break; case 'create': return view(\"dftqc.$viewName.ajax.create\")->render(); break; case 'edit': \$data = $modelClass::findOrFail(\$id); return view(\"dftqc.$viewName.ajax.edit\", compact('data'))->render(); break; default: return 'Not Found'; } } public function api(Request \$request, \$action, \$authCode = null) { \$id = \$request->primary_id; \$route = \$request->route()->uri; \$route = explode('/', \$route); if (\$route[0] == 'api') { switch (\$action) { case 'index': \$data = $modelClass::where('status', '<>', -1)->get(); \$html = view(\"dftqc.$viewName.ajax.index\", compact('data'))->render(); return response()->json(['status' => true, 'content' => \$html], 200); break; case 'store': $modelClass::create(\$request->all()); if (\$request->ajax()) { return response()->json(['status' => true, 'message' => 'The $modelClass Created Successfully.'], 200); } break; case 'edit': \$data = $modelClass::findOrFail(\$id); \$html = view(\"dftqc.$viewName.ajax.edit\", compact('data'))->render(); return response()->json(['status' => true, 'content' => \$html], 200); break; case 'update': \$data = $modelClass::findOrFail(\$id); \$data->update(\$request->all()); return response()->json(['status' => true, 'message' => 'The $modelClass updated Successfully.'], 200); break; case 'delete': \$data = $modelClass::findOrFail(\$id); \$data->status = -1; \$data->save(); return response()->json(['status' => true, 'message' => 'The $modelClass Deleted Successfully.'], 200); break; } } else { } } } "; // $filename = ($controllerPath != "") ? $controllerPath . "/" : ""; $controllerDirectory = ''; if (!empty($controllerPath)) { $controllerDirectory = ucfirst($directoryName) . '/'; } $filename = $controllerName . ".php"; if (!file_exists($filename)) { if (!file_exists(base_path() . '/app/Http/Controllers/' . $controllerDirectory)) { mkdir(base_path() . '/app/Http/Controllers/' . $controllerDirectory, 0777, true); } $file = fopen(base_path() . "/app/Http/Controllers/" . $controllerDirectory . $filename, 'w'); fwrite($file, $contentString); fclose($file); } return $contentString; } public static function migrationContent($tableName) { $columns = Schema::getColumnListing($tableName); $tableFields = DB::select("describe $tableName"); // foreach($tableFields as $tableField){ // dd($tableField->Field); // } $pkField = str_replace("tbl_", "", $tableName) . "_id"; //BibClass::pre($tableFields); $contentString = "Type; //WRITE CODE HERE TO IDENTIFY THE TYPES OF FIELDS switch ($Type) { case 'int(11)': if ($tableField->Field == $pkField) : $contentString .= "\$table->integer(\"$tableField->Field\")->autoIncrement();\n"; else : $contentString .= "\$table->integer(\"$tableField->Field\")->default(0);\n"; endif; break; case 'varchar(255)': $contentString .= "\$table->string(\"$tableField->Field\")->nullable();\n"; break; case 'datetime': $contentString .= "\$table->datetime(\"$tableField->Field\")->nullable();\n"; break; case 'text': $contentString .= "\$table->text(\"$tableField->Field\")->nullable();\n"; break; case 'timestamp': $contentString .= "\$table->text(\"$tableField->Field\")->nullable();\n"; break; default: } } $contentString .= "\$table->timestamps();\n });\n }\n public function down()\n {\n Schema::dropIfExists(\"$tableName\");\n }\n};"; // dd(base_path()); $file = fopen(base_path() . "/database/migrations/" . date('Y_m_d_his') . "_create_" . $tableName . "_table.php", 'w'); fwrite($file, $contentString); fclose($file); return $contentString; // return $tableFields; } public static function routeContent($TableName, $directoryName) { $TableName = str_replace("tbl_", "", $TableName); $routePrefixName = ''; $ControllerName = ''; if (!empty($directoryName)) { // $ControllerName .= ucwords($directoryName) . '/'; $routePrefixName .= strtolower($directoryName) . '.'; } $ControllerName .= ucwords($TableName) . "Controller"; $routePrefixName .= strtolower($TableName); $RouteContent = "Route::prefix(\"$TableName\")->group(function () { Route::get('/', [$ControllerName::class, 'index'])->name('$routePrefixName.index'); Route::get('/create', [$ControllerName::class, 'create'])->name('$routePrefixName.create'); Route::post('/store', [$ControllerName::class, 'store'])->name('$routePrefixName.store'); Route::get('/show/{id}', [$ControllerName::class, 'show'])->name('$routePrefixName.show'); Route::get('/edit/{id}', [$ControllerName::class, 'edit'])->name('$routePrefixName.edit') ; Route::put('/update/{id}', [$ControllerName::class, 'update'])->name('$routePrefixName.update'); Route::delete('/destroy/{id}', [$ControllerName::class, 'destroy'])->name('$routePrefixName.destroy'); });"; return $RouteContent; } public static function listContent($TableName, $directoryName) { $TableCols = DB::select("describe " . $TableName); $TableRows = DB::select("select * from " . $TableName); $folder = ''; $routeName = ''; if (!empty($directoryName)) { $folder .= strtolower($directoryName) . '/'; $routeName .= strtolower($directoryName) . '.'; } $folder .= str_replace("tbl_", "", $TableName); $Table_pk = str_replace("tbl_", "", $TableName) . "_id"; $title = ucwords(str_replace("tbl_", "", $TableName)); $routeName .= strtolower(str_replace("tbl_", "", $TableName)) . '.'; $columns = Schema::getColumnListing($TableName); $primaryKey = $columns[0]; $tableFields = DB::select("describe $TableName"); $translated = trans('lang.' . $title); $listContent = '@extends(\'dftqc.partials.layouts\') @section(\'content\')

    {{ __("lang.' . $title . ' List") }}

    ' . PHP_EOL; foreach ($columns as $key => $column) { if ($key == 0 || $column == 'remarks' || $column == 'createdOn' || $column == 'createdBy' || $column == 'updatedBy' || $column == 'created_at' || $column == 'updated_at') continue; $listContent .= '' . PHP_EOL; } $listContent .= ' @php $i = 1; @endphp @foreach ($data as $item) '; foreach ($columns as $key => $column) { if ($key == 0 || $column == 'remarks' || $column == 'createdOn' || $column == 'createdBy' || $column == 'updatedBy' || $column == 'created_at' || $column == 'updated_at') continue; if ($column == 'status') $listContent .= '' . PHP_EOL; else $listContent .= '' . PHP_EOL; } $listContent .= ' @endforeach
    S.N.{{ __("lang.' . $column . '") }}{{ __("lang.Action") }}
    {{ $i++ }}{!! $item->status_name !!}{{ $item->' . $column . ' }}
    @endsection '; $path = base_path() . "/resources/views/dftqc/$folder/"; $file = $path . "index.blade.php"; if (!file_exists("$path")) { mkdir("$path", 0777, true); } if (!file_exists($file)) { $file = fopen($file, 'w'); fwrite($file, $listContent); fclose($file); } return $listContent; } //End of list code content //ajax complete List public static function ajaxCompleteListContent($TableName, $directoryName) { $folder = ''; $routeName = ''; $controllerName = ''; if (!empty($directoryName)) { $folder .= strtolower($directoryName) . '/'; $routeName .= strtolower($directoryName) . '.'; $controllerName .= ucwords($directoryName) . '\\'; } $folder .= str_replace("tbl_", "", $TableName); $title = ucwords(str_replace("tbl_", "", $TableName)); $controllerName .= $title . 'Controller'; $routeName .= strtolower(str_replace("tbl_", "", $TableName)) . '.'; $columns = Schema::getColumnListing($TableName); $primaryKey = $columns[0]; $tableFields = DB::select("describe $TableName"); $listContent = '@extends(\'dftqc.partials.layouts\') @section(\'content\')

    {{ __("lang.' . $title . ' List") }}

      {!!createCanvasButton("customBtnAdd","","' . $title . '","' . $routeName . 'create") !!}
    ' . PHP_EOL; foreach ($columns as $key => $column) { if ($key == 0 || $column == 'remarks' || $column == 'createdOn' || $column == 'createdBy' || $column == 'updatedBy' || $column == 'created_at' || $column == 'updated_at') continue; $listContent .= '' . PHP_EOL; } $listContent .= ' @php $i = 1; @endphp @foreach ($data as $item) '; foreach ($columns as $key => $column) { if ($key == 0 || $column == 'remarks' || $column == 'createdOn' || $column == 'createdBy' || $column == 'updatedBy' || $column == 'created_at' || $column == 'updated_at') continue; if ($column == 'status') $listContent .= '' . PHP_EOL; else $listContent .= '' . PHP_EOL; } $listContent .= ' @endforeach
    S.N.{{ __("lang.' . $column . '") }}{{ __("lang.Action") }}
    {{ $i++ }}{!! $item->status_name !!}{{ $item->' . $column . ' }}
    • {!! actionCanvasButton("","btn-showCanvas","showoffcanvas","eye",' . "'" . $routeName . 'show' . "'" . ',$item->' . $primaryKey . ') !!}
    • {!! actionCanvasButton("","btn-editCanvas","editoffcanvas","edit",' . "'" . $routeName . 'edit' . "'" . ',$item->' . $primaryKey . ') !!}
    • {!! deleteCanvasButton("","btn-hover-danger",' . "'" . $routeName . 'destroy' . "'" . ',$item->' . $primaryKey . ') !!}
    {{-- Add Modal --}}
    {{ __("lang.Add ' . $title . '") }}
    {{-- Edit Modal --}}
    {{ __("lang.Edit ' . $title . '") }}
    {{-- Edit Modal --}} {{-- Edit Modal --}}
    {{-- Edit Modal --}}
    @endsection '; $path = base_path() . "/resources/views/dftqc/$folder/"; $file = $path . "ajax_index.blade.php"; if (!file_exists("$path")) { mkdir("$path", 0777, true); } if (!file_exists($file)) { $file = fopen($file, 'w'); fwrite($file, $listContent); fclose($file); } return $listContent; } //End of ajax complete list code content public static function ajaxListContent($TableName, $directoryName) { $TableCols = DB::select("describe " . $TableName); $TableRows = DB::select("select * from " . $TableName); $folder = ''; $routeName = ''; if (!empty($directoryName)) { $folder .= strtolower($directoryName) . '/'; $routeName .= strtolower($directoryName) . '.'; } $folder .= str_replace("tbl_", "", $TableName); $Table_pk = str_replace("tbl_", "", $TableName) . "_id"; $title = ucwords(str_replace("tbl_", "", $TableName)); $routeName .= strtolower(str_replace("tbl_", "", $TableName)) . '.'; $columns = Schema::getColumnListing($TableName); $primaryKey = $columns[0]; $tableFields = DB::select("describe $TableName"); $listContent = '' . PHP_EOL; foreach ($columns as $key => $column) { if ($key == 0 || $column == 'remarks' || $column == 'createdOn' || $column == 'createdBy' || $column == 'updatedBy' || $column == 'created_at' || $column == 'updated_at') continue; $listContent .= '' . PHP_EOL; } $listContent .= ' @php $i = 1; @endphp @foreach ($data as $item) '; foreach ($columns as $key => $column) { if ($key == 0 || $column == 'remarks' || $column == 'createdOn' || $column == 'createdBy' || $column == 'updatedBy' || $column == 'created_at' || $column == 'updated_at') continue; if ($column == 'status') $listContent .= '' . PHP_EOL; else $listContent .= '' . PHP_EOL; } $listContent .= ' @endforeach
    {{__("lang.SN")}}{{__("lang.' . $column . '")}}Action
    {{ $i++ }}{!! $item->status_name !!}{{ $item->' . $column . ' }}
    '; $path = base_path() . "/resources/views/dftqc/$folder/ajax/"; $file = $path . "index.blade.php"; if (!file_exists("$path")) { mkdir("$path", 0777, true); } if (!file_exists($file)) { $file = fopen($file, 'w'); fwrite($file, $listContent); fclose($file); } return $listContent; } public static function addContent($TableName, $directoryName) { $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)); $addContent = "@extends('dftqc.partials.layouts') @section('content')

    {{ label('Add $title') }}

    "; $addContent .= "@include('dftqc.".$routeName.".ajax.create')"; $addContent .= "
    \n@endsection"; $path = base_path() . "/resources/views/dftqc/$folder/"; $file = $path . "create.blade.php"; if (!file_exists("$path")) { mkdir("$path", 0777, true); } if (!file_exists($file)) { $file = fopen($file, 'w'); fwrite($file, $addContent); fclose($file); } return $addContent; } //End of addContent public static function ajaxAddContent($TableName, $directoryName) { $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)); $all_columns = master_getColumn($TableName); $all_foreign_table = getForeignTable($all_columns); $all_foreignKey = []; if ($all_foreign_table) foreach ($all_foreign_table as $key => $tablename) { $all_foreignKey[$tablename] = master_getColumn($tablename); $all_foreignKey[$tablename] = $all_foreignKey[$tablename][0] ?? null; } $addContent = "
    \n @csrf \n"; $addContent .= '
    '; foreach ($TableCols as $key => $TableCol) : $TableCol = $TableCol->Field; if ($key == 0 || $TableCol == 'alias' || $TableCol == 'createdOn' || $TableCol == 'createdBy' || $TableCol == 'updatedBy' || $TableCol == 'created_at' || $TableCol == 'updated_at') continue; $TableColLabel = ucwords(str_replace("_", " ", $TableCol)); $addContent .= '
    '; if ($TableCol == 'status'){ $addContent .= "{{customCreateSelect(\"$TableCol\",\"$TableCol\",'',\"$TableColLabel\",['1'=>'Active','0'=>'Inactive'])}}\n"; $addContent .= "{{createErrorParagraph('$TableCol','')}}\n"; }else { $status = true; foreach ($all_foreignKey as $ctable => $cPK) { if ($TableCol == $cPK) { $baseName = str_replace("tbl_", "", $ctable) . 'Name'; $addContent .= "{!! getSelectForForeignColumn(\"$ctable\",\"$cPK\",\"$baseName\",'') !!}\n"; $addContent .= "{{createErrorParagraph('$cPK','')}}\n"; $status = false; break; } } if ($status){ $addContent .= "{{createText(\"$TableCol\",\"$TableCol\",\"$TableColLabel\")}}\n"; $addContent .= "{{createErrorParagraph('$TableCol','')}}"; } } $addContent .= "
    "; endforeach; $addContent .= '
    '; $addContent .= "\n"; $addContent .= "
    "; $addContent .= " "; $path = base_path() . "/resources/views/dftqc/$folder/ajax/"; $file = $path . "create.blade.php"; if (!file_exists("$path")) { mkdir("$path", 0777, true); } if (!file_exists($file)) { $file = fopen($file, 'w'); fwrite($file, $addContent); fclose($file); } return $addContent; } //End of ajax addContent public static function editContent($TableName, $directoryName) { $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)); $editContent = "@extends('dftqc.partials.layouts') @section('content')

    {{ __('Edit $title') }}

    "; $editContent .="@include('dftqc.".$routeName.".ajax.edit')"; $editContent .= "
    \n@endsection"; $path = base_path() . "/resources/views/dftqc/$folder/"; $file = $path . "edit.blade.php"; if (!file_exists("$path")) { mkdir("$path", 0777, true); } if (!file_exists($file)) { $file = fopen($file, 'w'); fwrite($file, $editContent); fclose($file); } return $editContent; } //end of editContent method public static function ajaxEditContent($TableName, $directoryName) { $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)); $all_columns = master_getColumn($TableName); $all_foreign_table = getForeignTable($all_columns); $all_foreignKey = []; if ($all_foreign_table) foreach ($all_foreign_table as $key => $tablename) { $all_foreignKey[$tablename] = master_getColumn($tablename); $all_foreignKey[$tablename] = $all_foreignKey[$tablename][0] ?? null; } $editContent = "
    $Table_pk])}}\" id=\"updateCustomForm\">\n @csrf \n @method('PUT')\n"; $editContent .= '
    '; foreach ($TableCols as $key => $TableCol) : $TableCol = $TableCol->Field; if ($key == 0 || $TableCol == 'alias' || $TableCol == 'createdOn' || $TableCol == 'createdBy' || $TableCol == 'updatedBy' || $TableCol == 'created_at' || $TableCol == 'updated_at') continue; $TableColLabel = ucwords(str_replace("_", " ", $TableCol)); $editContent .= '
    '; if ($TableCol == 'status'){ $editContent .= "{{customCreateSelect(\"$TableCol\",\"$TableCol\",'',\"$TableColLabel\",['1'=>'Active','0'=>'Inactive'],\$data->$TableCol)}}\n"; $editContent .= "{{createErrorParagraph('$TableCol','')}}\n"; } else { $status = true; foreach ($all_foreignKey as $ctable => $cPK) { if ($TableCol == $cPK) { $baseName = str_replace("tbl_", "", $ctable) . 'Name'; $editContent .= "{!! getSelectForForeignColumn(\"$ctable\",\"$cPK\",\"$baseName\",'',\$data) !!}\n"; $editContent .= "{{createErrorParagraph('$cPK','')}}\n"; $status = false; break; } } if ($status){ $editContent .= "{{createText(\"$TableCol\",\"$TableCol\",\"$TableColLabel\",'',\$data->$TableCol)}}\n"; $editContent .= "{{createErrorParagraph('$TableCol','')}}\n"; } } $editContent .= "
    "; endforeach; $editContent .= '
    '; $editContent .= "\n"; $editContent .= "
    "; $editContent .= " "; $path = base_path() . "/resources/views/dftqc/$folder/ajax/"; $file = $path . "edit.blade.php"; if (!file_exists("$path")) { mkdir("$path", 0777, true); } if (!file_exists($file)) { $file = fopen($file, 'w'); fwrite($file, $editContent); fclose($file); } return $editContent; } //end of ajaxEditContent method public static function ajaxEditSimpleContent($TableName, $directoryName) { $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)); $editContent = "
    \n @csrf \n @method('PUT')\n"; $editContent .= '
    '; 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)); $editContent .= '
    '; if ($TableCol == 'status') $editContent .= "{{customCreateSelect(\"$TableCol\",\"$TableCol\",'',\"$TableColLabel\",['1'=>'Active','0'=>'Inactive'],\$data->$TableCol)}}\n"; else $editContent .= "{{createText(\"$TableCol\",\"$TableCol\",\"$TableColLabel\",'',\$data->$TableCol)}}\n"; $editContent .= "
    "; endforeach; $editContent .= '
    '; $editContent .= "\n"; $editContent .= "
    "; $editContent .= " "; $path = base_path() . "/resources/views/dftqc/$folder/ajax/"; $file = $path . "simple_edit.blade.php"; if (!file_exists("$path")) { mkdir("$path", 0777, true); } if (!file_exists($file)) { $file = fopen($file, 'w'); fwrite($file, $editContent); fclose($file); } return $editContent; } //end of ajaxEditContent method public static function showContent($TableName, $directoryName){ $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 = "@extends('dftqc.partials.layouts') @section('content')
    \n"; $showContent .= "@include('dftqc.".$routeName.".ajax.show')"; $showContent .= "
    @endSection"; $path = base_path() . "/resources/views/dftqc/$folder/"; $file = $path . "show.blade.php"; if (!file_exists("$path")) { mkdir("$path", 0777, true); } if (!file_exists($file)) { $file = fopen($file, 'w'); fwrite($file, $showContent); fclose($file); } return $showContent; } public static function ajaxShowContent($TableName, $directoryName) { $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 = "

    {{ label('$title Details') }}

    {{-- --}}

    {{\$data['" . $TableCols['1']->Field . "']}}

    "; 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}}

    "; $path = base_path() . "/resources/views/dftqc/$folder/ajax/"; $file = $path . "show.blade.php"; if (!file_exists("$path")) { mkdir("$path", 0777, true); } if (!file_exists($file)) { $file = fopen($file, 'w'); fwrite($file, $showContent); fclose($file); } return $showContent; } public static function dataTable($TableRows, $TableName) { $Table_pk = str_replace("tbl_", "", $TableName) . "_id"; $TableCols = array_keys((array)$TableRows[0]); //BibClass::pre($TableCols); ?>
    $TableCol; ?>
    Field; switch ($tableField) { case $Table_pk: case 'status': case 'created_at': case 'updated_at': break; default: createInput("text", $tableField, $tableField, $tableField, "", "", ""); } } } }