parent
f03862b523
commit
1a43060996
42 changed files with 1160 additions and 83 deletions
77
app/Http/Controllers/CountryController.php
Executable file
77
app/Http/Controllers/CountryController.php
Executable file
|
|
@ -0,0 +1,77 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
|
||||
|
||||
use App\Models\Country;
|
||||
use Input;
|
||||
|
||||
|
||||
class CountryController extends Controller
|
||||
{
|
||||
protected $userRepo;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('admin');
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$data = [
|
||||
'values' => Country::all(),
|
||||
];
|
||||
return view('admin.country.index', $data);
|
||||
}
|
||||
|
||||
|
||||
public function edit($id)
|
||||
{
|
||||
if($id === "new"){
|
||||
$model = new Country();
|
||||
$model->active = true;
|
||||
}else{
|
||||
$model = Country::findOrFail($id);
|
||||
}
|
||||
$data = [
|
||||
'country' => $model,
|
||||
'trans' => array_keys(config('localization.supportedLocales')),
|
||||
|
||||
];
|
||||
return view('admin.country.edit', $data);
|
||||
}
|
||||
|
||||
public function store()
|
||||
{
|
||||
|
||||
$data = Input::all();
|
||||
if(!isset($data['attr'])){
|
||||
$data['attr'] = [];
|
||||
}
|
||||
if($data['id'] === "new"){
|
||||
$model = Country::create([
|
||||
/* 'parent_id' => null,
|
||||
'name' => $data['name'],
|
||||
'pos' => $data['pos'],
|
||||
'active' => isset($data['active']) ? true : false,
|
||||
*/
|
||||
]);
|
||||
}else{
|
||||
$model = Country::find($data['id']);
|
||||
$model->fill($data);
|
||||
$model->save();
|
||||
}
|
||||
|
||||
|
||||
\Session()->flash('alert-save', '1');
|
||||
return redirect(route('admin_country_edit', $model->id));
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue