89 lines
No EOL
2.3 KiB
PHP
89 lines
No EOL
2.3 KiB
PHP
<?php
|
|
|
|
namespace App\Repositories\IQ;
|
|
|
|
use App\Models\IQTravelGroup;
|
|
use App\Models\IQTravelGroupItem;
|
|
use App\Models\IQTravelItem;
|
|
use App\Models\IQTravelItemPlace;
|
|
use App\Repositories\BaseRepository;
|
|
|
|
class TravelRepository extends BaseRepository {
|
|
|
|
|
|
public function __construct()
|
|
{
|
|
$this->model = null;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function updateTravelGroup($id, $data)
|
|
{
|
|
|
|
if($id == "new"){
|
|
$this->model = IQTravelGroup::create($data);
|
|
}
|
|
else{
|
|
$this->model = IQTravelGroup::findOrFail($id);
|
|
$this->model->fill($data);
|
|
$this->model->save();
|
|
}
|
|
|
|
return $this->model;
|
|
}
|
|
|
|
public function updateTravelGroupItem($id, $data)
|
|
{
|
|
$data['pos'] = $data['pos'] ? intval($data['pos']) : 0;
|
|
$data['i_q_travel_group_id'] = $data['iq_travel_group_id'];
|
|
|
|
if($data['iq_travel_group_item_id'] == "new"){
|
|
$this->model = IQTravelGroupItem::create($data);
|
|
}
|
|
else{
|
|
$this->model = IQTravelGroupItem::findOrFail($data['iq_travel_group_item_id']);
|
|
$this->model->fill($data);
|
|
$this->model->save();
|
|
}
|
|
return $this->model;
|
|
}
|
|
|
|
|
|
|
|
public function updateTravelItem($id, $data)
|
|
{
|
|
$data['draft_type_id'] = $data['draft_type_id'] ? $data['draft_type_id'] : null;
|
|
$data['travel_country_id'] = $data['travel_country_id'] ? $data['travel_country_id'] : null;
|
|
|
|
if($id == "new"){
|
|
$this->model = IQTravelItem::create($data);
|
|
}
|
|
else{
|
|
$this->model = IQTravelItem::findOrFail($id);
|
|
$this->model->fill($data);
|
|
$this->model->save();
|
|
}
|
|
|
|
return $this->model;
|
|
}
|
|
|
|
public function updateTravelItemPlace($id, $data)
|
|
{
|
|
$data['pos'] = $data['pos'] ? intval($data['pos']) : 0;
|
|
$data['i_q_travel_item_id'] = $data['iq_travel_item_id'];
|
|
if($data['iq_travel_item_place_id'] == "new"){
|
|
$this->model = IQTravelItemPlace::create($data);
|
|
}
|
|
else{
|
|
$this->model = IQTravelItemPlace::findOrFail($data['iq_travel_item_place_id']);
|
|
$this->model->fill($data);
|
|
$this->model->save();
|
|
}
|
|
|
|
return $this->model;
|
|
}
|
|
|
|
} |