51 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			PHP
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			51 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			PHP
		
	
	
		
			Executable File
		
	
	
	
	
| <?php
 | |
| 
 | |
| namespace App\Models;
 | |
| 
 | |
| use Illuminate\Database\Eloquent\Model;
 | |
| use Illuminate\Support\Facades\DB;
 | |
| 
 | |
| class OrdersAccidents extends Model
 | |
| {
 | |
|     public static function getAccidents()
 | |
|     {
 | |
|         return DB::select("SELECT * FROM t_orders_accidents WHERE dlt is null;");
 | |
|     }
 | |
| 
 | |
|     public static function getAccidentById($id)
 | |
|     {
 | |
|         return DB::select("SELECT * FROM t_orders_accidents WHERE dlt is null AND id = ? LIMIT 1;", [$id]);
 | |
|     }
 | |
| 
 | |
| 	public static function getAccidentByOrdId($ord_id)
 | |
|     {
 | |
|         return DB::select("SELECT * FROM t_orders_accidents WHERE dlt is null AND ord_id = ? LIMIT 1;", [$ord_id]);
 | |
|     }
 | |
| 
 | |
|     public static function addAccident($data)
 | |
|     {
 | |
|         $id = DB::table("t_orders_accidents")->insertGetId($data);
 | |
|         return $id;
 | |
|     }
 | |
| 
 | |
|     public static function updateAccident($id, $data)
 | |
|     {
 | |
|         return DB::table("t_orders_accidents")->where("id", $id)->update($data);
 | |
|     }
 | |
| 
 | |
|     public static function updateAccidentByOrdId($ord_id, $data)
 | |
|     {
 | |
|         return DB::table("t_orders_accidents")->where("ord_id", $ord_id)->update($data);
 | |
|     }
 | |
| 
 | |
|     public static function deleteAccident($id)
 | |
|     {
 | |
|         return DB::table("t_orders_accidents")->where("id", $id)->delete();
 | |
|     }
 | |
| 
 | |
|     public static function deleteAccidentByOrdId($ord_id)
 | |
|     {
 | |
|         return DB::table("t_orders_accidents")->where("ord_id", $ord_id)->delete();
 | |
|     }
 | |
| }
 | 
