81 lines
2 KiB
PHP
Executable file
81 lines
2 KiB
PHP
Executable file
<?php
|
|
|
|
namespace App\Http\Controllers\CMS;
|
|
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Models\CMSContent;
|
|
use App\Models\TravelCountry;
|
|
use App\Models\TravelNationality;
|
|
use Request;
|
|
use Validator;
|
|
|
|
|
|
class CMSContentCountryController extends Controller
|
|
{
|
|
|
|
/*
|
|
* Create a new controller instance.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function __construct()
|
|
{
|
|
$this->middleware('admin');
|
|
|
|
}
|
|
|
|
public function index($step = false)
|
|
{
|
|
$data = [
|
|
'travel_countries' => TravelCountry::all(),
|
|
];
|
|
return view('cms.content.country.index', $data);
|
|
}
|
|
|
|
public function detail($id, $step = false)
|
|
{
|
|
$model = TravelCountry::findOrFail($id);
|
|
$id = $model->id;
|
|
|
|
$data = [
|
|
'model' => $model,
|
|
'id' => $id,
|
|
'step' => $step,
|
|
'travel_nationalities' => TravelNationality::where('active', true)->get(),
|
|
];
|
|
return view('cms.content.country.detail', $data);
|
|
}
|
|
|
|
|
|
|
|
public function store($id)
|
|
{
|
|
|
|
$data = Request::all();
|
|
if(!isset($data['contact_lands'])){
|
|
$data['contact_lands'] = null;
|
|
}
|
|
$model = TravelCountry::findOrFail($id);
|
|
$model->fill($data);
|
|
$model->save();
|
|
|
|
//travel_nationality_requirement
|
|
if (isset($data['travel_nationality_requirement'])) {
|
|
foreach ($data['travel_nationality_requirement'] as $travel_nationality_id => $text) {
|
|
$model->setNationalityRequirement($travel_nationality_id, $text);
|
|
}
|
|
}
|
|
|
|
//TODO for this time
|
|
if ($data['action'] == 'contact') {
|
|
//we need an update in the old CRM v1 system DB
|
|
$tc = \App\Models\Sym\TravelCountry::findOrFail($model->crm_id);
|
|
$tc->fill($data);
|
|
$tc->save();
|
|
}
|
|
\Session()->flash('alert-save', '1');
|
|
return redirect(route('cms_content_country_detail', [$model->id, $data['action']]));
|
|
}
|
|
|
|
}
|