Repository navigation
Expand file tree
/
Copy pathCities.php
More file actions
66 lines (55 loc) · 1.74 KB
/
Copy pathCities.php
File metadata and controls
66 lines (55 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php namespace XavieR\Events\Controllers;
use BackendMenu;
use Backend\Classes\Controller;
use XavieR\Events\Models\City;
/**
* Cities Back-end Controller
*/
class Cities extends Controller
{
public $implement = [
'Backend.Behaviors.FormController',
'Backend.Behaviors.ListController',
'Backend.Behaviors.RelationController',
];
public $formConfig = 'config_form.yaml';
public $listConfig = 'config_list.yaml';
public $relationConfig = 'config_relation.yaml';
public function __construct()
{
parent::__construct();
BackendMenu::setContext('October.System', 'system', 'settings');
}
public function listInjectRowClass($record, $definition = null)
{
if (!$record->is_enabled)
return 'safe disabled';
}
public function onLoadDisableForm()
{
try {
$this->vars['checked'] = post('checked');
}
catch (Exception $ex) {
$this->handleError($ex);
}
return $this->makePartial('disable_form');
}
public function onDisableLocations()
{
$enable = post('enable', false);
if (($checkedIds = post('checked')) && is_array($checkedIds) && count($checkedIds)) {
foreach ($checkedIds as $objectId) {
if (!$object = City::find($objectId))
continue;
$object->is_enabled = $enable;
$object->save();
}
}
if ($enable)
Flash::success(Lang::get('xavier.events::lang.locations.enable_success'));
else
Flash::success(Lang::get('xavier.events::lang.locations.disable_success'));
return Redirect::to(Backend::url('xavier/events/cities'));
}
}