softDelete relations

This commit is contained in:
Shohrat 2023-10-30 00:54:41 +05:00
parent 8aa3108887
commit a26469f63d
10 changed files with 178 additions and 84 deletions

View File

@ -39,6 +39,11 @@ class MachineProduction extends ComponentBase
$allSpent = 0; $allSpent = 0;
$allLeft = 0; $allLeft = 0;
// var_dump(count($productions));
if (count($productions) == 0) {
$html_data = '';
} {
$html_data = '<div class="modal-header"> $html_data = '<div class="modal-header">
<h5 class="modal-title" id="mySmallModalLabel">#Rulon' . $machinProdId . ' Agramy: ' . $productions[0]->machin_production->produced_weight . ' kg</h5> <h5 class="modal-title" id="mySmallModalLabel">#Rulon' . $machinProdId . ' Agramy: ' . $productions[0]->machin_production->produced_weight . ' kg</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" <button type="button" class="btn-close" data-bs-dismiss="modal"
@ -91,6 +96,87 @@ class MachineProduction extends ComponentBase
</tr>'; </tr>';
$html_data .= '</table></div>'; $html_data .= '</table></div>';
}
return [
'#modal-form' => $html_data,
];
}
public function onSetFormUpdate()
{
$data = post();
$machinProdId = $data["machineProdId"];
$production = ProductionMachineModel::where("id", $machinProdId)->first();
$html_data = '<div class="modal-header">
<h5 class="modal-title" id="mySmallModalLabel">#Rulon' . $machinProdId . ' Agramy: ' . $production->produced_weight . ' kg</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal"
aria-label="Close"></button>
</div>
<div class="modal-body">';
$html_data .= '<form data-request="onUpdateMachineProduction" data-request-flash>
<div class="row">
<div class="col">
<select class="form-control select2" name="machine_id">
<option value="0">Enjam Saýla</option>
{% for machine in machines %}
<option value="{{machine.id}}">{{machine.name}}</option>
{% endfor %}
</select>
</div>
<div class="col">
<!-- <input type="date" name="date" class="form-control" placeholder="Sene"> -->
<div class="input-group" id="datepicker2">
<input type="text" class="form-control" name="date" placeholder="Sene"
data-date-format="d.m.yyyy" data-date-container="#datepicker2"
data-provide="datepicker" data-date-autoclose="true">
<span class="input-group-text"><i class="mdi mdi-calendar"></i></span>
</div>
</div>
<div class="col">
<select class="form-control select2" name="size_id">
<option value="0">Ölçeg Saýla</option>
{% for size in sizes %}
<option value="{{size.id}}">{{size.name}}</option>
{% endfor %}
</select>
</div>
<div class="col">
<select class="form-control select2" name="type_id">
<option value="0">Görnüş Saýla</option>
{% for type in types %}
<option value="{{type.id}}">{{type.name}}</option>
{% endfor %}
</select>
</div>
<div class="col">
<select class="form-control select2" name="color_id">
<option value="0">Reňk Saýla</option>
{% for color in colors %}
<option value="{{color.id}}">{{color.name}}</option>
{% endfor %}
</select>
</div>
<div class="col">
<input type="number" name="produced_weight" class="form-control"
placeholder="Mukdar (kg)">
</div>
<div class="col">
<input type="text" name="note" class="form-control" placeholder="Bellik">
</div>
<div class="col">
<button type="submit" class="btn btn-primary waves-effect waves-light"
style="width: 100%;">Goş</button>
</div>
</div>
</form>';
$html_data .= '</div>';
return [ return [
'#modal-form' => $html_data, '#modal-form' => $html_data,
@ -113,7 +199,7 @@ class MachineProduction extends ComponentBase
<td style="font-weight: bold;">' . ($x + 1) . '</td> <td style="font-weight: bold;">' . ($x + 1) . '</td>
<td style="font-weight: bold;"><a type="button" data-request="onModalSetMachineData" <td style="font-weight: bold;"><a type="button" data-request="onModalSetMachineData"
data-request-data="machineProdId: ' . $machineProductions[$x]->id . '" data-request-data="machineProdId: ' . $machineProductions[$x]->id . '"
data-bs-toggle="modal" data-bs-target=".bs-example-modal-lg"> #Rulon' . ($machineProductions[$x]->id) . '</a></td> data-bs-toggle="modal" data-bs-target=".bs-example-modal-lg" style="color: darkblue;"> #Rulon' . ($machineProductions[$x]->id) . '</a></td>
<td><a href="#">' . ($machineProductions[$x]->date == null ? "" : Carbon::parse($machineProductions[$x]->date)->format('d.m.Y')) . '</a></td> <td><a href="#">' . ($machineProductions[$x]->date == null ? "" : Carbon::parse($machineProductions[$x]->date)->format('d.m.Y')) . '</a></td>
<td><a href="#" style="font-weight: bold;">' . $machineProductions[$x]->building_name . '</a></td> <td><a href="#" style="font-weight: bold;">' . $machineProductions[$x]->building_name . '</a></td>
<td>' . $machineProductions[$x]->machine->name . '</td> <td>' . $machineProductions[$x]->machine->name . '</td>
@ -126,6 +212,7 @@ class MachineProduction extends ComponentBase
<td>' . $machineProductions[$x]->employee_name . '</td> <td>' . $machineProductions[$x]->employee_name . '</td>
<td>' . $machineProductions[$x]->mechanic_name . '</td> <td>' . $machineProductions[$x]->mechanic_name . '</td>
<td>' . $machineProductions[$x]->note . '</td> <td>' . $machineProductions[$x]->note . '</td>
<td> <a href="#" data-request="onSetFormUpdate" data-bs-toggle="modal" data-bs-target=".bs-example-modal-lg" data-request-data="machineProdId: ' . $machineProductions[$x]->id . '" style="font-weight: bold;color: darkred;"> ÜÝTGET </a> </td>
</tr>'; </tr>';
} }
@ -309,8 +396,6 @@ class MachineProduction extends ComponentBase
} else { } else {
Flash::error("Yalnyshlyk bar!!"); Flash::error("Yalnyshlyk bar!!");
} }
} }
public function onCreateMachineProduction() public function onCreateMachineProduction()

View File

@ -609,18 +609,18 @@ class Production extends ComponentBase
return ActionModel::where('id', $id)->first(); return ActionModel::where('id', $id)->first();
} }
// public function onDeleteProduction() public function onDeleteProduction()
// { {
// $id = post('id'); $id = post('id');
// $item = ActionModel::Find($id); $item = ProductionModel::Find($id);
// $item->delete(); $item->delete();
// if ($item) { if ($item) {
// Flash::success("Action Ustunlikli Pozuldy"); Flash::success("Hasabat Ustunlikli Pozuldy");
// return Redirect::refresh(); return Redirect::refresh();
// } }
// } }

View File

@ -27,11 +27,13 @@ class Order extends Model
public $hasMany = [ public $hasMany = [
'order_items' => [ 'order_items' => [
'Romanah\Gokbakja\Models\OrderItem', 'Romanah\Gokbakja\Models\OrderItem',
'key' => 'order_id' 'key' => 'order_id',
'softDelete' => true
], ],
'payment' => [ 'payment' => [
'Romanah\Gokbakja\Models\Payment', 'Romanah\Gokbakja\Models\Payment',
'key' => 'order_id' 'key' => 'order_id',
'softDelete' => true
], ],
]; ];

View File

@ -16,15 +16,14 @@ class PivotProduction extends Model
public $hasMany = [ public $hasMany = [
'pivot_production_calculate' => [ 'pivot_production_calculate' => [
'Romanah\Gokbakja\Models\ProductionCalculate', 'Romanah\Gokbakja\Models\ProductionCalculate',
'key' => 'prev_pivot_id', 'key' => 'prev_pivot_id'
'delete' => true
] ]
]; ];
public $belongsTo = [ public $belongsTo = [
'production' => [ 'production' => [
'Romanah\Gokbakja\Models\Production', 'Romanah\Gokbakja\Models\Production',
'key' => 'production_id' 'key' => 'production_id',
], ],
'product' => [ 'product' => [
'Romanah\Gokbakja\Models\Product', 'Romanah\Gokbakja\Models\Product',

View File

@ -18,12 +18,12 @@ class Production extends Model
'pivot_production' => [ 'pivot_production' => [
'Romanah\Gokbakja\Models\PivotProduction', 'Romanah\Gokbakja\Models\PivotProduction',
'key' => 'production_id', 'key' => 'production_id',
'delete' => true 'softDelete' => true
], ],
'pivot_production_calculation' => [ 'pivot_production_calculation' => [
'Romanah\Gokbakja\Models\ProductionCalculate', 'Romanah\Gokbakja\Models\ProductionCalculate',
'key' => 'production_id', 'key' => 'production_id',
'delete' => true 'softDelete' => true
] ]
]; ];

View File

@ -16,11 +16,13 @@ class ProductionMachine extends Model
public $hasMany = [ public $hasMany = [
'sewer_productions' => [ 'sewer_productions' => [
'Romanah\Gokbakja\Models\SewerProduction', 'Romanah\Gokbakja\Models\SewerProduction',
'key' => 'machine_production_id' 'key' => 'machine_production_id',
'softDelete' => true
], ],
'pivot_sewer' => [ 'pivot_sewer' => [
'Romanah\Gokbakja\Models\PivotSewer', 'Romanah\Gokbakja\Models\PivotSewer',
'key' => 'machine_production_id' 'key' => 'machine_production_id',
'softDelete' => true
], ],
]; ];

View File

@ -16,7 +16,8 @@ class SewerProduction extends Model
public $hasMany = [ public $hasMany = [
'pivot_sewer' => [ 'pivot_sewer' => [
'Romanah\Gokbakja\Models\PivotSewer', 'Romanah\Gokbakja\Models\PivotSewer',
'key' => 'sewer_production_id' 'key' => 'sewer_production_id',
'softDelete' => true
], ],
]; ];

View File

@ -79,14 +79,10 @@ items:
cssClass: '' cssClass: ''
isExternal: '0' isExternal: '0'
- -
title: 'Çig mallar boýunça' title: 'Ekstrudor boýunça'
nesting: null
type: url type: url
url: /w url: /w
code: '' code: ''
reference: null
cmsPage: null
replace: null
viewBag: viewBag:
isHidden: '0' isHidden: '0'
cssClass: ri-stack-line cssClass: ri-stack-line
@ -146,9 +142,13 @@ items:
isExternal: '0' isExternal: '0'
- -
title: 'Rulonlar Boýunça' title: 'Rulonlar Boýunça'
nesting: null
type: url type: url
url: /ee url: /ee
code: '' code: ''
reference: null
cmsPage: null
replace: null
viewBag: viewBag:
isHidden: '0' isHidden: '0'
cssClass: 'ri-bar-chart-2-line ' cssClass: 'ri-bar-chart-2-line '

View File

@ -187,6 +187,7 @@ pageNumber = "{{ :page }}"
<th>Ady Familiýasy</th> <th>Ady Familiýasy</th>
<th>Mehanik</th> <th>Mehanik</th>
<th>Bellik</th> <th>Bellik</th>
<th>Sazlama</th>
<!-- <th>Настройки</th> --> <!-- <th>Настройки</th> -->
</tr> </tr>
</thead> </thead>
@ -207,6 +208,7 @@ pageNumber = "{{ :page }}"
<th>Ady Familiýasy</th> <th>Ady Familiýasy</th>
<th>Mehanik</th> <th>Mehanik</th>
<th>Bellik</th> <th>Bellik</th>
<th>Sazlama</th>
</tr> </tr>
</tfoot> </tfoot>
</table> </table>

View File

@ -185,6 +185,7 @@ function onStart(){
<th>{{record.name}}</th> <th>{{record.name}}</th>
{% endfor %} {% endfor %}
<th>Bellik</th> <th>Bellik</th>
<th>Sazlama</th>
<!-- <th>Настройки</th> --> <!-- <th>Настройки</th> -->
</tr> </tr>
</thead> </thead>
@ -241,6 +242,7 @@ function onStart(){
{% endfor %} {% endfor %}
<td style="font-weight: bold;color: #0005c5;">{{report.note}}</td> <td style="font-weight: bold;color: #0005c5;">{{report.note}}</td>
<td><a href="#" data-request="onDeleteProduction" data-request-data="id: {{report.id}}" data-request-confirm="Hasabat # {{report.id}} pozmak isleýäňizmi?" style="font-weight: bold;color: darkred;">POZ</a></td>
</tr> </tr>
@ -260,6 +262,7 @@ function onStart(){
<th>{{record.name}}</th> <th>{{record.name}}</th>
{% endfor %} {% endfor %}
<th>Bellik</th> <th>Bellik</th>
<th>Sazlama</th>
</tr> </tr>
</tfoot> </tfoot>
</table> </table>