ソースを参照

Support for multi condition for sub-entity loading, support for bool fields

Vijayakrishnan 5 年 前
コミット
f16af1cc93

+ 33 - 5
app/Console/Commands/GenerateTreeCommand.php

@@ -339,18 +339,41 @@ class GenController {
                     $input = ["'record'"];
                     // if sub-index controller, load subRecords
                     if($method->type === 'sub' && count($method->data)) {
-                        $dbParts = explode("=", $method->data[0]);
+                        $parts = explode(",", $method->data[0]);
+
+                        $loadingLine = [];
+
+                        // first 'where'
+                        $dbParts = explode("=", $parts[0]);
                         $localField = $dbParts[0];
                         $dbParts = explode(".", $dbParts[1]);
                         $foreignTable = $dbParts[0];
                         $foreignField = $dbParts[1];
-                        $code[] = "\t\t\$subRecords = DB::table('$foreignTable')->where('$foreignField', \$record->$localField)->get();";
+                        $loadingLine[] = "\t\t\$subRecords = DB::table('$foreignTable')";
+                        $loadingLine[] = "->where('$foreignField', \$record->$localField)";
+
+                        // other 'where's
+                        if(count($parts) > 1) {
+                            for ($i = 1; $i < count($parts); $i++) {
+                                $dbParts = explode("=", $parts[$i]);
+                                $field = $dbParts[0];
+                                $value = $dbParts[1];
+                                $loadingLine[] = "->where('$field', $value)";
+                            }
+                        }
+
+                        $loadingLine[] = "->get();";
+
+                        $code[] = implode("", $loadingLine);
+
+                        // $code[] = "\t\t\$subRecords = DB::table('$foreignTable')->where('$foreignField', \$record->$localField)->get();";
                         $input[] = "'subRecords'";
                     }
                     $code[] = "\t\treturn view('{$this->root}/{$this->name}/{$method->name}', " .
                         "compact(" . implode(", ", $input) . "));";
                 }
                 else {
+                    $loadingLine = [];
                     $loadingLine[] = "\t\t\$records = DB::table('{$this->dbTable}')";
                     if($this->condition) {
                         $loadingLine[] = "->where('{$this->condition['field']}', {$this->condition['value']})";
@@ -700,7 +723,7 @@ class GenController {
                     break;
             }
         }
-        if($type !== 'hidden') {
+        if($type !== 'hidden' && $type !== 'bool') {
             $code[] = "<div class='form-group mb-3'>";
             $code[] = "<label class='control-label'>{$this->camelToTitleCase($this->snakeToTitleCase($display))}</label>";
         }
@@ -729,9 +752,14 @@ class GenController {
                 $code[] = "<?php endforeach; ?>";
                 $code[] = "</select>";
                 break;
+            case "bool":
+                $code[] = "<div class='form-group mb-3'>";
+                $code[] = "<label class='control-label'>{$this->camelToTitleCase($this->snakeToTitleCase($display))} ";
+                $code[] = "<input class='form-control' type='checkbox' name='$name'>";
+                $code[] = "</label>";
+                break;
             default:
-                $code[] = "<input class='form-control' type='$type' name='$name' " . $valueLine .
-                    ">";
+                $code[] = "<input class='form-control' type='$type' name='$name' " . $valueLine . ">";
         }
         if($type !== 'hidden') {
             $code[] = "</div>";

+ 2 - 2
app/Http/Controllers/care_months_SINGLE_Controller.php

@@ -133,14 +133,14 @@ class care_months_SINGLE_Controller extends Controller
 	// GET /care_months/view/{uid}/SUB_cm_time_entries
 	public function SUB_cm_time_entries(Request $request, $uid) {
 		$record = DB::table('care_month')->where('uid', $uid)->first();
-		$subRecords = DB::table('care_month_entry')->where('care_month_id', $record->id)->get();
+		$subRecords = DB::table('care_month_entry')->where('care_month_id', $record->id)->where('cm_or_rm', 'CM')->get();
 		return view('pro/care_months_SINGLE/SUB_cm_time_entries', compact('record', 'subRecords'));
 	}
 
 	// GET /care_months/view/{uid}/SUB_rm_time_entries
 	public function SUB_rm_time_entries(Request $request, $uid) {
 		$record = DB::table('care_month')->where('uid', $uid)->first();
-		$subRecords = DB::table('care_month_entry')->where('care_month_id', $record->id)->get();
+		$subRecords = DB::table('care_month_entry')->where('care_month_id', $record->id)->where('cm_or_rm', 'RM')->get();
 		return view('pro/care_months_SINGLE/SUB_rm_time_entries', compact('record', 'subRecords'));
 	}
 

+ 1 - 1
app/Http/Controllers/facilities_Controller.php

@@ -18,7 +18,7 @@ class facilities_Controller extends Controller
 
 	// GET /facilities/add_new
 	public function add_new(Request $request) {
-		$records = DB::table('facility')->get();		$records = DB::table('facility')->get();
+		$records = DB::table('facility')->get();
 		return view('admin/facilities/add_new', compact('records'));
 	}
 

+ 1 - 1
app/Http/Controllers/my_clients_Controller.php

@@ -18,7 +18,7 @@ class my_clients_Controller extends Controller
 
 	// GET /my_clients/add_new
 	public function add_new(Request $request) {
-		$records = DB::table('client')->get();		$records = DB::table('client')->get();
+		$records = DB::table('client')->get();
 		return view('pro/my_clients/add_new', compact('records'));
 	}
 

+ 1 - 1
app/Http/Controllers/my_teams_Controller.php

@@ -18,7 +18,7 @@ class my_teams_Controller extends Controller
 
 	// GET /my_teams/add_new
 	public function add_new(Request $request) {
-		$records = DB::table('team')->get();		$records = DB::table('team')->get();
+		$records = DB::table('team')->get();
 		return view('pro/my_teams/add_new', compact('records'));
 	}
 

+ 1 - 1
app/Http/Controllers/pros_Controller.php

@@ -18,7 +18,7 @@ class pros_Controller extends Controller
 
 	// GET /pros/add_new
 	public function add_new(Request $request) {
-		$records = DB::table('pro')->get();		$records = DB::table('pro')->get();
+		$records = DB::table('pro')->get();
 		return view('admin/pros/add_new', compact('records'));
 	}
 

+ 7 - 9
generatecv/tree.txt

@@ -308,28 +308,26 @@ PRO
             dashboard
 # :: need remove
             cm_time_entries
-# :: where cm_or_rm = cm
-                id=care_month_entry.care_month_id
+                id=care_month_entry.care_month_id,cm_or_rm='CM'
                 add_new:care_month_entry:createForCm
                     careMonthUid:hidden=uid
                     proUid:record:pro:uid,name_display
                     effectiveDate:date
                     timeInSeconds:number
-                    isTimeSpecific
+                    isTimeSpecific:bool
                     startingTime:time
                     endingTime:time
                     contentText
                     contentDetail
 # :: need remove
             rm_time_entries
-# :: where cm_or_rm = rm
-                id=care_month_entry.care_month_id
+                id=care_month_entry.care_month_id,cm_or_rm='RM'
                 add_new:care_month_entry:createForRm
                     careMonthUid:hidden=uid
                     proUid:record:pro:uid,name_display
                     effectiveDate:date
                     timeInSeconds:number
-                    isTimeSpecific
+                    isTimeSpecific:bool
                     startingTime:time
                     endingTime:time
                     contentText
@@ -344,7 +342,7 @@ PRO
             updateTiming
                 effectiveDate
                 timeInSeconds
-                isTimeSpecific
+                isTimeSpecific:bool
                 startingTime
                 endingTime
         SUB
@@ -432,7 +430,7 @@ ADMIN
         nameLast
         nameSuffix
         nameCredential
-        isHcp
+        isHcp:bool
         hcpNpi
         previousProfessionCategory
         currentProfessionCategory
@@ -458,7 +456,7 @@ ADMIN
                 nameSuffix
                 nameCredential
             updateProfession
-                isHcp
+                isHcp:bool
                 hcpNpi
                 previousProfessionCategory
                 currentProfessionCategory

+ 3 - 2
resources/views/admin/pros/add_new.blade.php

@@ -60,8 +60,9 @@
 <input class='form-control' type='text' name='nameCredential' value='{{ old('nameCredential') ? old('nameCredential') : '' }}' >
 </div>
 <div class='form-group mb-3'>
-<label class='control-label'>Is Hcp</label>
-<input class='form-control' type='text' name='isHcp' value='{{ old('isHcp') ? old('isHcp') : '' }}' >
+<label class='control-label'>Is Hcp 
+<input class='form-control' type='checkbox' name='isHcp'>
+</label>
 </div>
 <div class='form-group mb-3'>
 <label class='control-label'>Hcp Npi</label>

+ 3 - 2
resources/views/admin/pros_SINGLE/ACTION_updateProfession.blade.php

@@ -19,8 +19,9 @@
         <input type="hidden" name="_success" value="{{route('pros-view', ['uid' => $record->uid])}}">
         <input type="hidden" name="_return" value="{{route('pros_SINGLE-ACTION_updateProfession', ['uid' => $record->uid])}}">
         <div class='form-group mb-3'>
-<label class='control-label'>Is Hcp</label>
-<input class='form-control' type='text' name='isHcp' value='{{ old('isHcp') ? old('isHcp') : '' }}' >
+<label class='control-label'>Is Hcp 
+<input class='form-control' type='checkbox' name='isHcp'>
+</label>
 </div>
 <div class='form-group mb-3'>
 <label class='control-label'>Hcp Npi</label>

+ 3 - 2
resources/views/pro/care_month_entries_SINGLE/ACTION_updateTiming.blade.php

@@ -27,8 +27,9 @@
 <input class='form-control' type='text' name='timeInSeconds' value='{{ old('timeInSeconds') ? old('timeInSeconds') : '' }}' >
 </div>
 <div class='form-group mb-3'>
-<label class='control-label'>Is Time Specific</label>
-<input class='form-control' type='text' name='isTimeSpecific' value='{{ old('isTimeSpecific') ? old('isTimeSpecific') : '' }}' >
+<label class='control-label'>Is Time Specific 
+<input class='form-control' type='checkbox' name='isTimeSpecific'>
+</label>
 </div>
 <div class='form-group mb-3'>
 <label class='control-label'>Starting Time</label>

+ 3 - 2
resources/views/pro/care_months_SINGLE/ACTION_cm_time_entriesAddNew.blade.php

@@ -38,8 +38,9 @@
 <input class='form-control' type='number' name='timeInSeconds' value='{{ old('timeInSeconds') ? old('timeInSeconds') : '' }}' >
 </div>
 <div class='form-group mb-3'>
-<label class='control-label'>Is Time Specific</label>
-<input class='form-control' type='text' name='isTimeSpecific' value='{{ old('isTimeSpecific') ? old('isTimeSpecific') : '' }}' >
+<label class='control-label'>Is Time Specific 
+<input class='form-control' type='checkbox' name='isTimeSpecific'>
+</label>
 </div>
 <div class='form-group mb-3'>
 <label class='control-label'>Starting Time</label>

+ 3 - 2
resources/views/pro/care_months_SINGLE/ACTION_rm_time_entriesAddNew.blade.php

@@ -38,8 +38,9 @@
 <input class='form-control' type='number' name='timeInSeconds' value='{{ old('timeInSeconds') ? old('timeInSeconds') : '' }}' >
 </div>
 <div class='form-group mb-3'>
-<label class='control-label'>Is Time Specific</label>
-<input class='form-control' type='text' name='isTimeSpecific' value='{{ old('isTimeSpecific') ? old('isTimeSpecific') : '' }}' >
+<label class='control-label'>Is Time Specific 
+<input class='form-control' type='checkbox' name='isTimeSpecific'>
+</label>
 </div>
 <div class='form-group mb-3'>
 <label class='control-label'>Starting Time</label>