diff --git a/Modules/User/app/Http/Controllers/UserController.php b/Modules/User/app/Http/Controllers/UserController.php index 8d68047..b1a101a 100644 --- a/Modules/User/app/Http/Controllers/UserController.php +++ b/Modules/User/app/Http/Controllers/UserController.php @@ -6,12 +6,20 @@ use App\Http\Controllers\Controller; use App\Models\User; use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; +use Modules\User\Repositories\UserRepository; class UserController extends Controller { /** * Display a listing of the resource. */ + + protected $userRepository; + + public function __construct(UserRepository $userRepository){ + $this->userRepository = $userRepository; + } + public function index() { $data = User::latest()->get(); @@ -25,6 +33,7 @@ class UserController extends Controller public function create() { $data['title'] = "Create User"; + $data['users'] = User::latest()->get(); return view('user::create', $data); } @@ -33,12 +42,21 @@ class UserController extends Controller */ public function store(Request $request): RedirectResponse { - // + $validatedData = $request->validate([ + 'name' => 'required|min:5', + 'email' => 'required', + 'password' => 'required', + ]); + + $user = $this->userRepository->create($validatedData, $request->role); + toastr()->success('User has been created!'); + return redirect()->route('users.index'); } /** * Show the specified resource. */ + public function show($id) { return view('user::show'); diff --git a/Modules/User/app/Repositories/UserInterface.php b/Modules/User/app/Repositories/UserInterface.php new file mode 100644 index 0000000..dc8f48b --- /dev/null +++ b/Modules/User/app/Repositories/UserInterface.php @@ -0,0 +1,12 @@ +roles()->attach($role); + } + + public function update($userId, array $newDetails) + { + return User::whereId($userId)->update($newDetails); + } + +} diff --git a/Modules/User/database/migrations/2024_04_07_095204_add_employee_id_to_users_table.php b/Modules/User/database/migrations/2024_04_07_095204_add_employee_id_to_users_table.php new file mode 100644 index 0000000..f28ac96 --- /dev/null +++ b/Modules/User/database/migrations/2024_04_07_095204_add_employee_id_to_users_table.php @@ -0,0 +1,28 @@ +unsignedInteger('employee_id'); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('users', function (Blueprint $table) { + + }); + } +}; diff --git a/Modules/User/resources/views/create.blade.php b/Modules/User/resources/views/create.blade.php index 166da0d..ca29ca4 100644 --- a/Modules/User/resources/views/create.blade.php +++ b/Modules/User/resources/views/create.blade.php @@ -15,13 +15,12 @@ -
-
+
diff --git a/Modules/User/resources/views/index.blade.php b/Modules/User/resources/views/index.blade.php index f279725..cff2cde 100644 --- a/Modules/User/resources/views/index.blade.php +++ b/Modules/User/resources/views/index.blade.php @@ -6,56 +6,46 @@
-
-

{{ label('Users List') }}

- {{ label('Create New') }} +
+
User Lists
+ Add New
- - - - - - - - - + + + + + {{-- --}} + - @php - $i = 1; - @endphp - @foreach ($data as $item) - $user) + - - - - - + + + + + diff --git a/Modules/User/resources/views/partials/action.blade.php b/Modules/User/resources/views/partials/action.blade.php index 973a5f3..91c485e 100644 --- a/Modules/User/resources/views/partials/action.blade.php +++ b/Modules/User/resources/views/partials/action.blade.php @@ -1,23 +1,33 @@ -
- - -
- Please enter employee name. +
+ +
+ {{ html()->label('For Employee')->class('form-label') }} + {{ html()->select('employee_id', ['1', '2'])->class('form-select')->placeholder('Select Employee')->required() }}
-
-
- - -
+
+ {{ html()->label('Role')->class('form-label') }} + {{ html()->select('role_id', ['1', '2'])->class('form-select')->placeholder('Select Role')->required() }} +
+
+ {{ html()->label('Username')->class('form-label') }} + {{ html()->text('name')->class('form-control')->placeholder('Enter Username')->required() }} +
+ +
+ {{ html()->label('Email')->class('form-label') }} + {{ html()->email('email')->class('form-control')->placeholder('Enter Email')->required() }} +
+ + +
+ {{ html()->label('Password')->class('form-label') }} + {{ html()->password('password')->class('form-control')->placeholder('Enter Password')->required() }} +
+ +
- -@push('js') - -@endpush diff --git a/app/Helpers/OMIS.php b/app/Helpers/OMIS.php index e799df7..f25a4bc 100644 --- a/app/Helpers/OMIS.php +++ b/app/Helpers/OMIS.php @@ -51,7 +51,7 @@ class OMIS -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}}

- -
-
- "; - - return $showContent; - } - public static function ajaxEditContent($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); - - $title = ucwords(str_replace("tbl_", "", $TableName)); - - $all_columns = self::getTableColumns($TableName); - $Table_pk = $all_columns[0]; - $all_foreign_table = self::getForeignTable($all_columns); - $all_foreignKey = []; - if ($all_foreign_table) { - foreach ($all_foreign_table as $key => $tablename) { - $all_foreignKey[$tablename] = self::getTableColumns($tablename); - $all_foreignKey[$tablename] = $all_foreignKey[$tablename][0] ?? null; - } - } - - $editContent = " - $Table_pk]):route('$routeName.store')}}\" id=\"updateCustomForm\" method=\"POST\" >\n @csrf "; - $editContent .= "" . PHP_EOL; - $editContent .= '
'; - foreach ($TableCols as $key => $TableCol): - - $TableCol = $TableCol->Field; - if (!in_array($TableCol, self::$HiddenCols)) { - $TableColLabel = ucwords(str_replace("_", " ", $TableCol)); - - switch ($TableCol) { - case $TableCols[0]->Field: - break; - - case (strpos($TableCol, "parent_") !== false): - $editContent .= '
'; - $editContent .= "{{createCustomSelect('$TableName', 'title', '" . $TableCols[0]->Field . "', \$editable?\$data->$TableCol:'', '" . $TableColLabel . "','$TableCol', 'form-control select2','status<>-1')}}"; - $editContent .= "
"; - break; - case (strpos($TableCol, "s_id") !== false): //CASE TO HANDLE FOREIGN TABLE - $FTNameRaw = str_replace("s_id", "s", $TableCol); - $FTName = "tbl_" . str_replace("s_id", "s", $TableCol); - $FTCols = DB::select("describe " . $FTName); - $editContent .= '
'; - //createCustomSelect($tableName, $fieldNameToDisplay, $fieldNameForValue, $defaultValueSelected, $displayTextForLabel, $HTMLElementName, $additionalClass = "form-control", $defaultCondition = null) - $editContent .= "{{createCustomSelect('$FTName', 'title', '" . $FTCols[0]->Field . "', \$editable?\$data->$TableCol:'', '" . $TableColLabel . "','$TableCol', 'form-control select2','status<>-1')}}"; - $editContent .= "
"; - break; - case (in_array($TableCol, self::$textEditorFields)): - $editContent .= '
'; - //function createTextArea($name, $class = "", $display = "", $default = "",$row = "") - $editContent .= "{{createTextarea(\"$TableCol\",\"$TableCol ckeditor-classic\",\"$TableColLabel\",\$editable?\$data->$TableCol:'')}}\n"; - $editContent .= "
"; - break; - case (in_array($TableCol, self::$imageFields)): - $editContent .= '
'; - $editContent .= "{{createImageInput(\"$TableCol\",\"$TableColLabel\",'',\$editable?\$data->$TableCol:'')}}\n"; - $editContent .= "
"; - break; - case (in_array($TableCol, self::$dateFields)): - $editContent .= '
'; - $editContent .= "{{createDate(\"$TableCol\",\"$TableColLabel\",'',\$editable?\$data->$TableCol:'')}}\n"; //createDate($name, $display = "",$class = "datepicker", $default = "") - $editContent .= "
"; - break; - case (in_array($TableCol, self::$passwordFields)): - $editContent .= '
'; - $editContent .= "{{createPassword(\"$TableCol\",\"$TableColLabel\",'',\$editable?\$data->$TableCol:'')}}\n"; //createDate($name, $display = "",$class = "datepicker", $default = "") - $editContent .= "
"; - break; - case (in_array($TableCol, self::$textAreaFields)): - $editContent .= '
'; - $editContent .= "{{createPlainTextArea(\"$TableCol\",'',\"$TableColLabel\",\$editable?\$data->$TableCol:'')}}\n"; //createDate($name, $display = "",$class = "datepicker", $default = "") - $editContent .= "
"; - break; - default: - $editContent .= '
'; - $editContent .= "{{createText(\"$TableCol\",\"$TableCol\",\"$TableColLabel\",'',\$editable?\$data->$TableCol:'')}}\n"; - $editContent .= "
"; - } - } - - endforeach; - $editContent .= '
'; - $editContent .= "\n"; - $editContent .= "\n"; - $editContent .= "
"; - $editContent .= " "; - - return $editContent; - } //end of ajaxEditContent method - public static function editContent($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)); - $editContent = "@extends('layouts.app') - @section('content') -
-
-

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

- \n -
-
"; - $editContent .= self::ajaxEditContent($TableName, $directoryName); - $editContent .= "
\n@endsection"; - $path = base_path() . "/resources/views/crud/generated/$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 addContent($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)); - - $addContent = "@extends('layouts.app') - @section('content') -
-
-

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

- \n -
-
"; - $addContent .= self::ajaxEditContent($TableName, $directoryName); - $addContent .= "
\n@endsection"; - $path = base_path() . "/resources/views/crud/generated/$folder/"; - $file = $path . "edit.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) - { - $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)); - - $all_columns = self::getTableColumns($TableName); - $all_foreign_table = self::getForeignTable($all_columns); - $all_foreignKey = []; - if ($all_foreign_table) - foreach ($all_foreign_table as $key => $tablename) { - $all_foreignKey[$tablename] = self::getTableColumns($tablename); - $all_foreignKey[$tablename] = $all_foreignKey[$tablename][0] ?? null; - } - - $addContent = " -
$Table_pk]):route('$routeName.store')}}\" id=\"storeCustomForm\" method=\"POST\">\n @csrf \n"; - $addContent .= '
'; - foreach ($TableCols as $key => $TableCol): - $TableCol = $TableCol->Field; - if (!in_array($TableCol, self::$HiddenCols)) { - $TableColLabel = ucwords(str_replace("_", " ", $TableCol)); - - switch ($TableCol) { - case $TableCols[0]->Field: - break; - case (strpos($TableCol, "parent_") !== false): - $addContent .= '
'; - $addContent .= "{{createCustomSelect('$TableName', 'title', '" . $TableCols[0]->Field . "', '', '" . $TableColLabel . "','$TableCol', 'form-control select2','status<>-1')}}"; - $addContent .= "
"; - break; - case (strpos($TableCol, "s_id") !== false): //CASE TO HANDLE FOREIGN TABLE - $FTNameRaw = str_replace("s_id", "s", $TableCol); - $FTName = "tbl_" . str_replace("s_id", "s", $TableCol); - $FTCols = DB::select("describe " . $FTName); - $addContent .= '
'; - //createCustomSelect($tableName, $fieldNameToDisplay, $fieldNameForValue, $defaultValueSelected, $displayTextForLabel, $HTMLElementName, $additionalClass = "form-control", $defaultCondition = null) - $addContent .= "{{createCustomSelect('$FTName', 'title', '" . $FTCols[0]->Field . "', '', '" . $TableColLabel . "','$TableCol', 'form-control select2','status<>-1')}}"; - $addContent .= "
"; - break; - case (in_array($TableCol, self::$textEditorFields)): - $addContent .= '
'; - $addContent .= "{{createTextarea(\"$TableCol\",\"$TableCol ckeditor-classic\",\"$TableColLabel\")}}\n"; - $addContent .= "
"; - break; - case (in_array($TableCol, self::$textAreaFields)): - $addContent .= '
'; - $addContent .= "{{createPlainTextArea(\"$TableCol\",\"$TableCol \",\"$TableColLabel\")}}\n"; - $addContent .= "
"; - break; - case (in_array($TableCol, self::$imageFields)): - $addContent .= '
'; - $addContent .= "{{createImageInput(\"$TableCol\",\"$TableColLabel\")}}\n"; - $addContent .= "
"; - break; - case (in_array($TableCol, self::$dateFields)): - $addContent .= '
'; - $addContent .= "{{createDate(\"$TableCol\",\"$TableColLabel\",'',date('Y-m-d'))}}\n"; //createDate($name, $display = "",$class = "datepicker", $default = "") - $addContent .= "
"; - break; - case (in_array($TableCol, self::$passwordFields)): - $addContent .= '
'; - $addContent .= "{{createPassword(\"$TableCol\",\"$TableColLabel\",'')}}\n"; //createDate($name, $display = "",$class = "datepicker", $default = "") - $addContent .= "
"; - break; - default: - $addContent .= '
'; - $addContent .= "{{createText(\"$TableCol\",\"$TableCol\",\"$TableColLabel\")}}\n"; - $addContent .= "
"; - } - } - endforeach; - $addContent .= '
'; - $addContent .= "\n"; - $addContent .= "\n"; - $addContent .= "
"; - $addContent .= " "; - - return $addContent; - } //End of ajax addContent - */ - public static function showContent($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 = "@extends('layouts.app') - @section('content') -
-
-

- \n -
-
- "; - $showContent .= self::ajaxShowContent($TableName, $directoryName); - $showContent .= " -
-
- -@endSection"; - - $path = base_path() . "/resources/views/crud/generated/$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 migrationContent($tableName) - { - $tableName = strtolower($tableName); - $columns = self::getTableColumns($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};"; - /* - $file = fopen(base_path() . "/database/migrations/" . date('Y_m_d_his') . "_create_" . $tableName . "_table.php", 'w'); - fwrite($file, $contentString); - fclose($file); - */ - return $contentString; - } - - public static function routeContent($TableName, $directoryName) - { - $TableName = strtolower($TableName); - $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::post('/sort', [$ControllerName::class, 'sort'])->name('$routePrefixName.sort'); - Route::post('/updatealias', [$ControllerName::class, 'updatealias'])->name('$routePrefixName.updatealias'); - Route::get('/show/{id}', [$ControllerName::class, 'show'])->name('$routePrefixName.show'); - Route::get('/edit/{id}', [$ControllerName::class, 'edit'])->name('$routePrefixName.edit') ; - Route::post('/update/{id}', [$ControllerName::class, 'update'])->name('$routePrefixName.update'); - Route::get('/destroy/{id}', [$ControllerName::class, 'destroy'])->name('$routePrefixName.destroy'); - Route::get('/toggle/{id}', [$ControllerName::class, 'toggle'])->name('$routePrefixName.toggle'); - Route::get('/clone/{id}', [$ControllerName::class, 'clone'])->name('$routePrefixName.clone'); - });"; - - $path = base_path() . "/routes/CRUDgenerated/"; - $file = $path . "route." . $routePrefixName . ".php"; - if (!file_exists($path)) { - mkdir($path, 0777, true); - } - if (!file_exists($file)) { - $file = fopen($file, 'w'); - fwrite($file, " -
-

{{ label("' . $title . ' List") }}

- {{label("Create New")}} -
-
-
{{ label('Sn.') }}{{ label('Name') }}{{ label('Email') }}{{ label('User Name') }}{{ label('Role') }}{{ label('Branch') }}{{ label('Employee') }}{{ label('Action') }} + S.NNameEmailEmployeeRoleBranchAction
{{ $i++ }}{{ $item->name }}{{ $item->email }}{{ $item->username }}{!! getFieldData('tbl_roles', 'title', 'role_id', $item->roles_id) !!} - {!! getFieldData('tbl_branches', 'title', 'branch_id', $item->branches_id) !!} - - {!! getFieldData('tbl_employees', 'title', 'employee_id', $item->employees_id) !!} - {{ $index + 1 }}{{ $user->name }}{{ $user->email }}{{ optional($user->employee)->employee_id }}{{ $user->roles->first()->id }}
- - - -
- - - ' . PHP_EOL; - - foreach ($columns as $key => $column) { - - if (!in_array($column, $HiddenColumns)) { - switch ($column) { - case (strpos($column, "parent_") !== false): - $listContent .= '' . PHP_EOL; - break; - case (strpos($column, "s_id") !== false): - $ParentName = str_replace("s_id", "s", $column); - $listContent .= '' . PHP_EOL; - break; - default: - $listContent .= '' . PHP_EOL; - } - } - - } - $listContent .= ' - - - - @php - $i = 1; - @endphp - @foreach ($data as $item) - - "> - '; - foreach ($columns as $key => $column) { - if (!in_array($column, $HiddenColumns)) { - - switch ($column) { - case (strpos($column, "parent_") !== false): - $listContent .= '' . PHP_EOL; - break; - case (strpos($column, "s_id") !== false): //CASE TO HANDLE FOREIGN TABLE - $FTNameRaw = str_replace("s_id", "s", $column); - $FTName = "tbl_" . str_replace("s_id", "s", $column); - $FTCols = DB::select("describe " . $FTName); - $listContent .= '"; - break; - case 'alias': - $listContent .= '' . PHP_EOL; - break; - case (in_array($column, self::$imageFields)): - $listContent .= '' . PHP_EOL; - break; - case (in_array($column, self::$dateFields)): - $listContent .= '' . PHP_EOL; - break; - case 'status': - $listContent .= '' . PHP_EOL; - break; - default: - $listContent .= '' . PHP_EOL; - } - } - } - $listContent .= ' - - - @endforeach - - -
{{label("Sn.")}}{{ label("Parent") }}{{ label("' . $ParentName . '") }}{{ label("' . $column . '") }}{{ label("Action") }} -
{{ $i++ }}' . PHP_EOL; - $listContent .= '{!! getFieldData("' . $TableName . '", "title", "' . $columns[0] . '", $item->' . $column . ') !!}' . PHP_EOL; - $listContent .= '' . PHP_EOL; - //function getFieldData($tableName, $returnField, $referenceFieldName, $referenceValue) - $listContent .= '{!! getFieldData("' . $FTName . '", "title", "' . $FTCols[0]->Field . '", $item->' . $column . ') !!}' . PHP_EOL; - $listContent .= " -
- {{ $item->alias }} - -
- change alias -
{{ showImageThumb($item->' . $column . ') }}{{ myDate($item->' . $column . ') }}{!! $item->status_name !!}{{ $item->' . $column . ' }} - - - -
- - -
-
- - @endsection - -@push("css") - - -@endpush -@push("js") - - - - - - - - - - - - -@endpush - '; - - $path = base_path() . "/resources/views/crud/generated/$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 modelContent($tableName, $directoryName) - { - $tableName = strtolower($tableName); - $modelPath = ''; - if (!empty($directoryName)) { - $modelPath .= "\\" . ucfirst($directoryName); - } - - $modelClass = ucfirst(str_replace("tbl_", "", $tableName)); - - $tableFields = DB::select("describe $tableName"); - $pkField = $tableFields[0]->Field; - - $skipPRimaryKey = 1; - $tableColumns = ''; - foreach ($tableFields as $tableField): - if ($skipPRimaryKey == 1) { - $skipPRimaryKey = 2; - continue; - } - $tableColumns .= "'" . $tableField->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) - { - $tableName = strtolower($tableName); - $tableFields = DB::select("describe $tableName"); - $pkField = $tableFields[0]->Field; - $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 = "title"; - - $contentString = "modelService = new CommonModelService(\$model); - } - public function index(Request \$request) - { - createActivityLog($controllerName::class, 'index', '$directoryName $modelClass index'); - \$data = $modelClass::where('status','<>',-1)->orderBy('display_order')->get(); - - return view(\"crud.generated.$viewName.index\", compact('data')); - } - - public function create(Request \$request) - { - createActivityLog($controllerName::class, 'create', '$directoryName $modelClass create'); - \$TableData = $modelClass::where('status','<>',-1)->orderBy('display_order')->get(); - \$editable=false; - return view(\"crud.generated.$viewName.edit\",compact('TableData','editable')); - } - - 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)]); - \$request->request->add(['display_order' => getDisplayOrder('" . $tableName . "')]); - \$request->request->add(['created_at' => date(\"Y-m-d h:i:s\")]); - \$request->request->add(['updated_at' => date(\"Y-m-d h:i:s\")]); - \$requestData=\$request->all(); - array_walk_recursive(\$requestData, function (&\$value) { - \$value = str_replace(env('APP_URL').'/', '', \$value); - }); - array_walk_recursive(\$requestData, function (&\$value) { - \$value = str_replace(env('APP_URL'), '', \$value); - }); - DB::beginTransaction(); - try { - \$operationNumber = getOperationNumber(); - \$this->modelService->create(\$operationNumber, \$operationNumber, null, \$requestData); - } 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 sort(Request \$request) - { - \$idOrder = \$request->input('id_order'); - - foreach (\$idOrder as \$index => \$id) { - \$companyArticle = $modelClass::find(\$id); - \$companyArticle->display_order = \$index + 1; - \$companyArticle->save(); - } - - return response()->json(['status' => true, 'content' => 'The articles sorted successfully.'], 200); - } - public function updatealias(Request \$request) - { - - \$articleId = \$request->input('articleId'); - \$newAlias = \$request->input('newAlias'); - \$companyArticle = $modelClass::find(\$articleId); - if (!\$companyArticle) { - return response()->json(['status' => false, 'content' => 'Company article not found.'], 404); - } - \$companyArticle->alias = \$newAlias; - \$companyArticle->save(); - return response()->json(['status' => true, 'content' => 'Alias updated successfully.'], 200); - } - - - - - public function show(Request \$request, \$id) - { - createActivityLog($controllerName::class, 'show', '$directoryName $modelClass show'); - \$data = $modelClass::findOrFail(\$id); - - return view(\"crud.generated.$viewName.show\", compact('data')); - } - - - public function edit(Request \$request, \$id) - { - createActivityLog($controllerName::class, 'edit', '$directoryName $modelClass edit'); - \$TableData = $modelClass::where('status','<>',-1)->orderBy('display_order')->get(); - \$data = $modelClass::findOrFail(\$id); - \$editable=true; - return view(\"crud.generated.$viewName.edit\", compact('data','TableData','editable')); - } - - - 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); - } - \$requestData=\$request->all(); - array_walk_recursive(\$requestData, function (&\$value) { - \$value = str_replace(env('APP_URL').'/', '', \$value); - }); - array_walk_recursive(\$requestData, function (&\$value) { - \$value = str_replace(env('APP_URL'), '', \$value); - }); - DB::beginTransaction(); - try { - \$OperationNumber = getOperationNumber(); - \$this->modelService->update(\$OperationNumber, \$OperationNumber, null, \$requestData, \$request->input('" . $pkField . "')); - } 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.'); - return redirect()->back()->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 function toggle(Request \$request,\$id) - { - createActivityLog($controllerName::class, 'destroy', '$directoryName $modelClass destroy'); - \$data = $modelClass::findOrFail(\$id); - \$requestData=['status'=>(\$data->status==1)?0:1]; - DB::beginTransaction(); - try { - \$OperationNumber = getOperationNumber(); - \$this->modelService->update(\$OperationNumber, \$OperationNumber, null, \$requestData, \$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 function clone(Request \$request,\$id) - { - createActivityLog($controllerName::class, 'clone', '$directoryName $modelClass clone'); - \$data = $modelClass::findOrFail(\$id); - unset(\$data['updatedby']); - unset(\$data['createdby']); - \$requestData=\$data->toArray(); - DB::beginTransaction(); - try { - \$OperationNumber = getOperationNumber(); - \$this->modelService->create(\$OperationNumber, \$OperationNumber, null, \$requestData); - } catch (Exception \$e) { - DB::rollBack(); - Log::info(\$e->getMessage()); - createErrorLog($controllerName::class, 'clone', \$e->getMessage()); - return response()->json(['status' => false, 'message' => \$e->getMessage()], 500); - } - DB::commit(); - return response()->json(['status'=>true,'message'=>'The $modelClass Clonned Successfully.'],200); - } - - - - } - "; - // $filename = ($controllerPath != "") ? $controllerPath . "/" : ""; - $controllerDirectory = ''; - if (!empty($controllerPath)) { - $controllerDirectory = ucfirst($directoryName) . '/'; - } - $filename = $controllerName . ".php"; - $filePath = base_path() . "/app/Http/Controllers/" . $controllerDirectory . $filename; - - if (!file_exists($filePath)) { - if (!file_exists(base_path() . '/app/Http/Controllers/' . $controllerDirectory)) { - mkdir(base_path() . '/app/Http/Controllers/' . $controllerDirectory, 0777, true); - } - $file = fopen($filePath, 'w'); - fwrite($file, $contentString); - fclose($file); - } - - return $contentString; - } -} diff --git a/app/Http/Controllers/PermissionsController.php b/app/Http/Controllers/PermissionsController.php.bak similarity index 100% rename from app/Http/Controllers/PermissionsController.php rename to app/Http/Controllers/PermissionsController.php.bak diff --git a/app/Http/Controllers/ProviencesController.php b/app/Http/Controllers/ProvinceController.php similarity index 69% rename from app/Http/Controllers/ProviencesController.php rename to app/Http/Controllers/ProvinceController.php index ed12e03..c4a68c8 100644 --- a/app/Http/Controllers/ProviencesController.php +++ b/app/Http/Controllers/ProvinceController.php @@ -2,39 +2,39 @@ namespace App\Http\Controllers; use App\Http\Controllers\Controller; use Illuminate\Http\Request; - use App\Models\Proviences; + use App\Models\Province; use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Validator; use App\Service\CommonModelService; use Log; use Exception; - class ProviencesController extends Controller + class ProvinceController extends Controller { protected $modelService; - public function __construct(Proviences $model) + public function __construct(Province $model) { $this->modelService = new CommonModelService($model); } public function index(Request $request) { - createActivityLog(ProviencesController::class, 'index', ' Proviences index'); - $data = Proviences::where('status','<>',-1)->orderBy('display_order')->get(); - - return view("crud.generated.proviences.index", compact('data')); + createActivityLog(ProvinceController::class, 'index', ' Province index'); + $data = Province::where('status','<>',-1)->orderBy('display_order')->get(); + + return view("crud.generated.province.index", compact('data')); } public function create(Request $request) { - createActivityLog(ProviencesController::class, 'create', ' Proviences create'); - $TableData = Proviences::where('status','<>',-1)->orderBy('display_order')->get(); + createActivityLog(ProvinceController::class, 'create', ' Province create'); + $TableData = Province::where('status','<>',-1)->orderBy('display_order')->get(); $editable=false; - return view("crud.generated.proviences.edit",compact('TableData','editable')); + return view("crud.generated.province.edit",compact('TableData','editable')); } public function store(Request $request) { - createActivityLog(ProviencesController::class, 'store', ' Proviences store'); + createActivityLog(ProvinceController::class, 'store', ' Province store'); $validator = Validator::make($request->all(), [ //ADD REQUIRED FIELDS FOR VALIDATION ]); @@ -45,7 +45,7 @@ ],500); } $request->request->add(['alias' => slugify($request->title)]); - $request->request->add(['display_order' => getDisplayOrder('tbl_proviences')]); + $request->request->add(['display_order' => getDisplayOrder('tbl_province')]); $request->request->add(['created_at' => date("Y-m-d h:i:s")]); $request->request->add(['updated_at' => date("Y-m-d h:i:s")]); $requestData=$request->all(); @@ -54,7 +54,7 @@ }); array_walk_recursive($requestData, function (&$value) { $value = str_replace(env('APP_URL'), '', $value); - }); + }); DB::beginTransaction(); try { $operationNumber = getOperationNumber(); @@ -62,34 +62,34 @@ } catch (\Exception $e) { DB::rollBack(); Log::info($e->getMessage()); - createErrorLog(ProviencesController::class, 'store', $e->getMessage()); + createErrorLog(ProvinceController::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 Proviences Created Successfully.'], 200); + return response()->json(['status' => true, 'message' => 'The Province Created Successfully.'], 200); } - return redirect()->route('proviences.index')->with('success','The Proviences created Successfully.'); + return redirect()->route('province.index')->with('success','The Province created Successfully.'); } - + public function sort(Request $request) { $idOrder = $request->input('id_order'); - + foreach ($idOrder as $index => $id) { - $companyArticle = Proviences::find($id); + $companyArticle = Province::find($id); $companyArticle->display_order = $index + 1; $companyArticle->save(); } - + return response()->json(['status' => true, 'content' => 'The articles sorted successfully.'], 200); } public function updatealias(Request $request) { - + $articleId = $request->input('articleId'); $newAlias = $request->input('newAlias'); - $companyArticle = Proviences::find($articleId); + $companyArticle = Province::find($articleId); if (!$companyArticle) { return response()->json(['status' => false, 'content' => 'Company article not found.'], 404); } @@ -97,32 +97,32 @@ $companyArticle->save(); return response()->json(['status' => true, 'content' => 'Alias updated successfully.'], 200); } - - - + + + public function show(Request $request, $id) { - createActivityLog(ProviencesController::class, 'show', ' Proviences show'); - $data = Proviences::findOrFail($id); - - return view("crud.generated.proviences.show", compact('data')); + createActivityLog(ProvinceController::class, 'show', ' Province show'); + $data = Province::findOrFail($id); + + return view("crud.generated.province.show", compact('data')); } public function edit(Request $request, $id) { - createActivityLog(ProviencesController::class, 'edit', ' Proviences edit'); - $TableData = Proviences::where('status','<>',-1)->orderBy('display_order')->get(); - $data = Proviences::findOrFail($id); + createActivityLog(ProvinceController::class, 'edit', ' Province edit'); + $TableData = Province::where('status','<>',-1)->orderBy('display_order')->get(); + $data = Province::findOrFail($id); $editable=true; - return view("crud.generated.proviences.edit", compact('data','TableData','editable')); + return view("crud.generated.province.edit", compact('data','TableData','editable')); } public function update(Request $request, $id) { - createActivityLog(ProviencesController::class, 'update', ' Proviences update'); + createActivityLog(ProvinceController::class, 'update', ' Province update'); $validator = Validator::make($request->all(), [ //ADD VALIDATION FOR REQIRED FIELDS ]); @@ -146,20 +146,20 @@ } catch (Exception $e) { DB::rollBack(); Log::info($e->getMessage()); - createErrorLog(ProviencesController::class, 'update', $e->getMessage()); + createErrorLog(ProvinceController::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 Proviences updated Successfully.'], 200); + return response()->json(['status' => true, 'message' => 'The Province updated Successfully.'], 200); } - // return redirect()->route('proviences.index')->with('success','The Proviences updated Successfully.'); - return redirect()->back()->with('success', 'The Proviences updated successfully.'); + // return redirect()->route('province.index')->with('success','The Province updated Successfully.'); + return redirect()->back()->with('success', 'The Province updated successfully.'); } public function destroy(Request $request,$id) { - createActivityLog(ProviencesController::class, 'destroy', ' Proviences destroy'); + createActivityLog(ProvinceController::class, 'destroy', ' Province destroy'); DB::beginTransaction(); try { $OperationNumber = getOperationNumber(); @@ -167,16 +167,16 @@ } catch (Exception $e) { DB::rollBack(); Log::info($e->getMessage()); - createErrorLog(ProviencesController::class, 'destroy', $e->getMessage()); + createErrorLog(ProvinceController::class, 'destroy', $e->getMessage()); return response()->json(['status' => false, 'message' => $e->getMessage()], 500); } DB::commit(); - return response()->json(['status'=>true,'message'=>'The Proviences Deleted Successfully.'],200); + return response()->json(['status'=>true,'message'=>'The Province Deleted Successfully.'],200); } public function toggle(Request $request,$id) { - createActivityLog(ProviencesController::class, 'destroy', ' Proviences destroy'); - $data = Proviences::findOrFail($id); + createActivityLog(ProvinceController::class, 'destroy', ' Province destroy'); + $data = Province::findOrFail($id); $requestData=['status'=>($data->status==1)?0:1]; DB::beginTransaction(); try { @@ -185,16 +185,16 @@ } catch (Exception $e) { DB::rollBack(); Log::info($e->getMessage()); - createErrorLog(ProviencesController::class, 'destroy', $e->getMessage()); + createErrorLog(ProvinceController::class, 'destroy', $e->getMessage()); return response()->json(['status' => false, 'message' => $e->getMessage()], 500); } DB::commit(); - return response()->json(['status'=>true,'message'=>'The Proviences Deleted Successfully.'],200); + return response()->json(['status'=>true,'message'=>'The Province Deleted Successfully.'],200); } public function clone(Request $request,$id) { - createActivityLog(ProviencesController::class, 'clone', ' Proviences clone'); - $data = Proviences::findOrFail($id); + createActivityLog(ProvinceController::class, 'clone', ' Province clone'); + $data = Province::findOrFail($id); unset($data['updatedby']); unset($data['createdby']); $requestData=$data->toArray(); @@ -205,14 +205,13 @@ } catch (Exception $e) { DB::rollBack(); Log::info($e->getMessage()); - createErrorLog(ProviencesController::class, 'clone', $e->getMessage()); + createErrorLog(ProvinceController::class, 'clone', $e->getMessage()); return response()->json(['status' => false, 'message' => $e->getMessage()], 500); } DB::commit(); - return response()->json(['status'=>true,'message'=>'The Proviences Clonned Successfully.'],200); + return response()->json(['status'=>true,'message'=>'The Province Clonned Successfully.'],200); } - - + + } - \ No newline at end of file diff --git a/app/Http/Controllers/RolepermissionsController.php b/app/Http/Controllers/RolepermissionsController.php.bak similarity index 100% rename from app/Http/Controllers/RolepermissionsController.php rename to app/Http/Controllers/RolepermissionsController.php.bak diff --git a/app/Http/Controllers/RolesController.php b/app/Http/Controllers/RolesController.php.bak similarity index 100% rename from app/Http/Controllers/RolesController.php rename to app/Http/Controllers/RolesController.php.bak diff --git a/app/Http/Controllers/Usercontroller.php.bak b/app/Http/Controllers/Usercontroller.php.bak deleted file mode 100644 index 749d1cd..0000000 --- a/app/Http/Controllers/Usercontroller.php.bak +++ /dev/null @@ -1,45 +0,0 @@ -validate([ - 'name' => 'required|min:5', - 'email' => 'required', - 'password' => 'required', - 'role' => 'required', - ]); - $user = User::create($validatedData); - $user->roles()->attach($request->role); - toastr()->success('User has been created!'); - return redirect()->route('users.index'); - } - - public function index() - { - $users = User::latest()->get(); - return view('users.index', compact('users')); - } - - public function destroy(string $id) - { - $user = User::findOrFail($id); - $user->delete(); - toastr()->success('Data has been deleted successfully!'); - return redirect()->back(); - } -} diff --git a/app/Models/Companytypes.php b/app/Models/Companytypes.php new file mode 100644 index 0000000..2d25c9c --- /dev/null +++ b/app/Models/Companytypes.php @@ -0,0 +1,16 @@ +hasMany(Registration::class,'preffered_location','slug'); - } - - -} diff --git a/app/Models/Municipality/Municipality.php b/app/Models/Municipality.php similarity index 78% rename from app/Models/Municipality/Municipality.php rename to app/Models/Municipality.php index 7abb7cb..682aaf3 100644 --- a/app/Models/Municipality/Municipality.php +++ b/app/Models/Municipality.php @@ -1,6 +1,6 @@ hasMany(Intake::class,'program_id','id'); - } - - public function fees() - { - return $this->hasMany(Fee::class,'program_id','id'); - } - - public function eligibilities() - { - return $this->hasMany(Eligibility::class,'program_id','id'); - } - - public function criterias() - { - return $this->hasMany(Criteria::class,'program_id','id'); - } - - -} diff --git a/app/Models/Province/Province.php b/app/Models/Province.php similarity index 94% rename from app/Models/Province/Province.php rename to app/Models/Province.php index 29f2ff3..586d0ce 100644 --- a/app/Models/Province/Province.php +++ b/app/Models/Province.php @@ -1,6 +1,6 @@ where('follow_up_type','registration')->where('refrence_id',$id)->latest()->first(); - } - - public static function getFollowUpCount($id) - { - return FollowUp::select('id','next_schedule','follow_up_name','follow_up_by','remarks')->where('follow_up_type','registration')->where('refrence_id',$id)->latest()->get(); - } - - public function leadcategory() - { - return $this->belongsTo(LeadCategory::class); - } - - public function campaign() - { - return $this->belongsTo(Campaign::class); - } - - public function enroll($id) { - return Student::select('id')->where('source_ref','registration')->where('ref_id',$id)->latest()->first(); - } -} diff --git a/app/Models/Role/Role.php b/app/Models/Role/Role.php deleted file mode 100644 index 5096dc3..0000000 --- a/app/Models/Role/Role.php +++ /dev/null @@ -1,49 +0,0 @@ -belongsToMany(Permission::class,'role_has_permissions'); - } - - function getVisibilityTextAttribute(){ - return ucwords(str_replace('_', ' ', $this->visibility)); - } - - function getStatusTextAttribute(){ - return ucwords(str_replace('_', ' ', $this->status)); - } - - function getAvailabilityTextAttribute(){ - return ucwords(str_replace('_', ' ', $this->availability)); - } - - function creator(){ - return $this->belongsTo(User::class,'created_by'); - } - - function getImagePathAttribute(){ - return $this->path.'/'. $this->image; - } - - function getThumbnailPathAttribute(){ - return $this->path.'/thumb/'. $this->image; - } -} diff --git a/app/Models/Setting/Setting.php b/app/Models/Setting.php similarity index 93% rename from app/Models/Setting/Setting.php rename to app/Models/Setting.php index d2d2e00..0f41fb6 100644 --- a/app/Models/Setting/Setting.php +++ b/app/Models/Setting.php @@ -1,6 +1,6 @@ belongsTo(Admission::class,'id','student_id'); - } - - public function educations() - { - return $this->hasMany(StudentEducation::class,'student_id','id'); - } - - public function languages() - { - return $this->hasMany(StudentLanguage::class,'student_id','id'); - } - - public function fields() - { - return $this->hasMany(StudentField::class,'student_id','id'); - } - - public function agent(){ - return $this->belongsTo(Agent::class,'ref_id','id'); - } - - public function location(){ - return $this->belongsTo(Location::class,'ref_id','id'); - } - - public function student_country(){ - return $this->belongsTo(Country::class,'country_id','id'); - } - - public function student_state(){ - return $this->belongsTo(State::class,'state_id','id'); - } - - public function student_district(){ - return $this->belongsTo(District::class,'district_id','id'); - } - -} diff --git a/app/Models/Student/StudentEducation.php b/app/Models/Student/StudentEducation.php deleted file mode 100644 index 0b06b37..0000000 --- a/app/Models/Student/StudentEducation.php +++ /dev/null @@ -1,37 +0,0 @@ -select('id','first_name','middle_name','last_name','gender','material_status','spouse_name','father_name','mother_name','mobile_no','alternate_mobile_no','email','dob','full_address','status','is_active')->get()->toArray(); - $records = DB::table('candidates') - ->join('candidate_passports','candidate_passports.candidate_id','candidates.id') - ->join('countries','countries.id','candidates.country_id') - ->join('provinces','provinces.id','candidates.province_id') - ->join('districts','districts.id','candidates.district_id') - ->join('districts AS cid','cid.id','candidate_passports.citizenship_issue_district') - ->select('candidates.id','candidates.first_name','candidates.middle_name','candidates.last_name','candidates.gender','candidates.spouse_name','candidates.father_name','candidates.mother_name','candidates.mobile_no','candidates.alternate_mobile_no','candidates.email','candidates.dob','countries.country_name','provinces.province_name','districts.district_name','candidates.municipality_name','candidates.ward_no','candidates.full_address','candidate_passports.passport_number','candidate_passports.passport_issue_date','candidate_passports.passport_expiry_date','candidate_passports.citizenship_number','candidate_passports.citizenship_issue_date','cid.district_name AS cid_name') - ->get() - ->toArray(); - return $records; - } - - -} diff --git a/app/Models/Student/StudentField.php b/app/Models/Student/StudentField.php deleted file mode 100644 index 765548e..0000000 --- a/app/Models/Student/StudentField.php +++ /dev/null @@ -1,16 +0,0 @@ - 'datetime', ]; + + // public function employee(){ + // return $this->belongsTo(Employee::class,'employee_id'); + // } } diff --git a/resources/views/layouts/partials/sidebar.blade.php b/resources/views/layouts/partials/sidebar.blade.php index 190bdd9..6d721b3 100644 --- a/resources/views/layouts/partials/sidebar.blade.php +++ b/resources/views/layouts/partials/sidebar.blade.php @@ -35,22 +35,23 @@ - + --}} @@ -62,6 +63,15 @@