/**
  * Creates a new Module model.
  * For ajax request will return json object
  * and for non-ajax request if creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $request = Yii::$app->request;
     $model = new Module();
     if ($request->isAjax) {
         /*
          *   Process for ajax request
          */
         Yii::$app->response->format = Response::FORMAT_JSON;
         if ($request->isGet) {
             return ['title' => "Create new Module", 'content' => $this->renderPartial('create', ['model' => $model]), 'footer' => Html::button('Close', ['class' => 'btn btn-default pull-left', 'data-dismiss' => "modal"]) . Html::button('Save', ['class' => 'btn btn-primary', 'type' => "submit"])];
         } else {
             if ($model->load($request->post()) && $model->save()) {
                 return ['forceReload' => 'true', 'title' => "Create new Module", 'content' => '<span class="text-success">Create Module success</span>', 'footer' => Html::button('Close', ['class' => 'btn btn-default pull-left', 'data-dismiss' => "modal"]) . Html::a('Create More', ['create'], ['class' => 'btn btn-primary', 'role' => 'modal-remote'])];
             } else {
                 return ['title' => "Create new Module", 'content' => $this->renderPartial('create', ['model' => $model]), 'footer' => Html::button('Close', ['class' => 'btn btn-default pull-left', 'data-dismiss' => "modal"]) . Html::button('Save', ['class' => 'btn btn-primary', 'type' => "submit"])];
             }
         }
     } else {
         /*
          *   Process for non-ajax request
          */
         if ($model->load($request->post()) && $model->save()) {
             return $this->redirect(['view', 'id' => $model->id]);
         } else {
             return $this->render('create', ['model' => $model]);
         }
     }
 }
 /**
  * Creates a new Module model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Module();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
Exemple #3
0
 public function store(ModuleRequest $request)
 {
     $module = new Module();
     $module->name_en = $request->input('name_en');
     $module->name_bn = $request->input('name_bn');
     $module->component_id = $request->input('component_id');
     $module->icon = $request->input('icon');
     $module->description = $request->input('description');
     $module->ordering = $request->input('ordering');
     $module->created_by = Auth::user()->id;
     $module->created_at = time();
     $module->save();
     Session()->flash('flash_message', 'Module has been created!');
     return redirect('modules');
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(StoreModuleRequest $request)
 {
     //
     $input = $request->all();
     $module = new Module();
     $module->name = $input['name'];
     $module->address = $input['address'];
     $module->district = $input['district'];
     $module->province = $input['province'];
     $module->state = $input['state'];
     $module->phone = $input['phone'];
     $module->email = $input['email'];
     $module->initial_cash = 0;
     $module->actual_cash = 0;
     $module->openModule = false;
     $module->starTime = new Carbon($input['starTime']);
     $module->endTime = new Carbon($input['endTime']);
     //Control de subida de imagen
     $module->image = $this->file_service->upload($request->file('image'), 'module');
     $module->save();
     return redirect('admin/modules');
 }
Exemple #5
0
 public function save(Request $request)
 {
     $as = $request->input('as');
     $module = new Module();
     $permission = new Permission();
     $validator = \Validator::make($request->all(), $module->getRules());
     $results = new \StdClass();
     if ($validator->passes()) {
         if ($request->input('id') != "xxx") {
             $module = Module::find($request->input('id'));
             $module->name = $request->input('name');
             $module->route = $request->input('route');
             $module->description = $request->input('description');
             $module->save();
             $results->info = 'module create';
         } else {
             $module = new Module();
             $permission = new Permission();
             $module->name = $request->input('name');
             $module->route = $request->input('route');
             $module->description = $request->input('description');
             $module->save();
             $permission->name = "can-access-" . $request->input('name');
             $permission->display_name = "Dapat Mengakses " . $request->input('name');
             $results->info = 'module edit';
         }
         $results->status = 1;
         $results->result = $module;
     } else {
         $results->status = 0;
         $result = array();
         foreach ($validator->errors() as $key => $err) {
             array_push($result, $err);
         }
         $results->result = $result;
     }
     return response()->json($results);
 }
Exemple #6
0
 public function create($module)
 {
     $moduleObj = new Module();
     $moduleObj->fill($module);
     $moduleObj->save();
 }
Exemple #7
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $module = new Module();
     $module->name = 'Home Site';
     $module->route = "/";
     $module->save();
     $module = new Module();
     $module->name = 'Login';
     $module->route = "login";
     $module->save();
     $module = new Module();
     $module->name = 'Backend User';
     $module->route = "admin/user";
     $module->save();
     $module = new Module();
     $module->name = 'Backend Role';
     $module->route = "admin/role";
     $module->save();
     $module = new Module();
     $module->name = 'Backend Permission';
     $module->route = "admin/permission";
     $module->save();
     $module = new Module();
     $module->name = 'Backend Module';
     $module->route = "admin/module";
     $module->save();
     $module = new Module();
     $module->name = 'Backend Dashboard';
     $module->route = "admin/dashboard";
     $module->save();
     $module = new Module();
     $module->name = 'Backend Menu';
     $module->route = "admin/menu";
     $module->save();
     $module = new Module();
     $module->name = 'Backend Preference';
     $module->route = "admin/preference";
     $module->save();
     $module = new Module();
     $module->name = 'Backend Grid';
     $module->route = "admin/grid";
     $module->save();
     $module = new Module();
     $module->name = 'Backend Gambar';
     $module->route = "admin/gambar";
     $module->save();
     $module = new Module();
     $module->name = 'Backend Menu Child';
     $module->route = "admin/menu:child";
     $module->save();
     $module = new Module();
     $module->name = 'Backend Preference Image';
     $module->route = "admin/preference:image";
     $module->save();
     $module = new Module();
     $module->name = 'Backend Preference Background';
     $module->route = "admin/preference:background";
     $module->save();
     $module = new Module();
     $module->name = 'Backend Preference Logo';
     $module->route = "admin/preference:logo";
     $module->save();
     $module = new Module();
     $module->name = 'Backend Preference Footer';
     $module->route = "admin/preference:footer";
     $module->save();
     $modules = Module::all();
     $admin = Role::where('name', 'admin')->get()->first();
     $tech = Role::where('name', 'tech')->get()->first();
     foreach ($modules as $key => $m) {
         $permission = new Permission();
         $permission->name = "can-access-module-" . $m->name;
         $permission->display_name = 'Dapat mengakses ' . $m->name;
         $permission->access = 'access';
         $permission->action = $m->id;
         $permission->type = 'module';
         $permission->save();
         $result = DB::table('permission_role')->insert(['role_id' => $admin->id, 'permission_id' => $permission->id]);
         $result = DB::table('permission_role')->insert(['role_id' => $tech->id, 'permission_id' => $permission->id]);
     }
 }
Exemple #8
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $module = new Module();
     $module->name = 'Home';
     $module->route = "'/', 'PagesController@index'";
     $module->save();
     $module = new Module();
     $module->name = 'login';
     $module->route = "'login', ['uses'=>'UsersController@login', 'as'=>'users.login.get']";
     $module->save();
     $module = new Module();
     $module->name = 'admin/user';
     $module->route = "'admin/user', ['uses'=>'PagesController@user', 'as'=>'admin.user.get', 'middleware'=>'auth']";
     $module->save();
     $module = new Module();
     $module->name = 'admin/role';
     $module->route = "'admin/role', ['uses'=>'PagesController@role', 'as'=>'admin.role.get', 'middleware'=>'auth']";
     $module->save();
     $module = new Module();
     $module->name = 'admin/permission';
     $module->route = "'admin/permission', ['uses'=>'PagesController@permission', 'as'=>'admin.permission.get']";
     $module->save();
     $module = new Module();
     $module->name = 'admin/module';
     $module->route = "'admin/module', ['uses'=>'PagesController@module', 'as'=>'admin.permission.get', 'middleware'=>'auth']";
     $module->save();
     $module = new Module();
     $module->name = 'admin/tes';
     $module->route = "'admin/tes', ['uses'=>'PagesController@tes', 'as'=>'admin.user.get', 'middleware'=>'auth']";
     $module->save();
     $module = new Module();
     $module->name = 'admin/dashboard';
     $module->route = "'admin/dashboard', ['uses'=>'PagesController@dashboard', 'as'=>'admin.dashboard.get', 'middleware'=>'auth']";
     $module->save();
     $module = new Module();
     $module->name = 'admin/menu';
     $module->route = "'admin/menu', ['uses'=>'PagesController@menu', 'as'=>'admin.menu.get', 'middleware'=>'auth']";
     $module->save();
     $module = new Module();
     $module->name = 'admin/preference';
     $module->route = "'admin/preference', ['uses'=>'PagesController@preference', 'as'=>'admin.preference.get', 'middleware'=>'auth']";
     $module->save();
     $module = new Module();
     $module->name = 'admin/grid';
     $module->route = "'admin/grid', ['uses'=>'PagesController@grid', 'as'=>'admin.grid.get', 'middleware'=>'auth']";
     $module->save();
     $module = new Module();
     $module->name = 'admin/form:child';
     $module->route = "'admin/form:child', ['uses'=>'ChildController@formChild', 'as'=>'admin.grid.get', 'middleware'=>'auth']";
     $module->save();
     $module = new Module();
     $module->name = 'Menu Images';
     $module->route = "any admin/gambar";
     $module->save();
     $module = new Module();
     $module->name = 'admin/users';
     $module->route = "[Menu^=admin/users]";
     $module->save();
     $module = new Module();
     $module->name = 'admin/roles';
     $module->route = "[Menu^=admin/roles]";
     $module->save();
     $module = new Module();
     $module->name = 'admin/menu:child';
     $module->route = "admin/menu:child";
     $module->save();
     $module = new Module();
     $module->name = 'admin/preference:image';
     $module->route = "admin/preference:image";
     $module->save();
     $module = new Module();
     $module->name = 'admin/preference:background';
     $module->route = "admin/preference:background";
     $module->save();
     $module = new Module();
     $module->name = 'admin/preference:logo';
     $module->route = "admin/preference:logo";
     $module->save();
     $module = new Module();
     $module->name = 'admin/preference:footer';
     $module->route = "admin/preference:footer";
     $module->save();
     $modules = Module::all();
     $admin = Role::where('name', 'admin')->get()->first();
     $tech = Role::where('name', 'tech')->get()->first();
     foreach ($modules as $key => $m) {
         $permission = new Permission();
         $permission->name = $m->name;
         $permission->display_name = 'Dapat mengakses module ' . $m->name;
         $permission->access = true;
         $permission->action = 'access';
         $permission->type = 'module';
         $permission->save();
         $result = DB::table('permission_role')->insert(['role_id' => $admin->id, 'permission_id' => $permission->id, 'action' => 1, 'access' => 'module']);
         $result = DB::table('permission_role')->insert(['role_id' => $tech->id, 'permission_id' => $permission->id, 'action' => 1, 'access' => 'module']);
     }
 }