/**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $validator = Validator::make($request->all(), ['title' => 'required|min:5|max:60|unique:services', 'route' => 'required|max:60|unique:services']);
     if ($validator->fails()) {
         return redirect()->back()->withErrors($validator)->withInput();
     }
     $service = new Service();
     if ($request->sort_id > 0) {
         $service->sort_id = $request->sort_id;
     } else {
         $service->sort_id = $service->count() + 1;
     }
     $service->slug = !empty($request->slug) ? $request->slug : str_slug($request->title);
     $service->title = $request->title;
     $service->route = $request->route;
     $service->title_description = $request->title_description;
     $service->meta_description = $request->meta_description;
     $service->text = $request->text;
     if ($request->status == 'on') {
         $service->status = 1;
     } else {
         $service->status = 0;
     }
     $service->save();
     return redirect('/admin/services')->with('status', 'Сервис добавлен!');
 }
Esempio n. 2
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Request $request)
 {
     $data = $request->all();
     $langs = get_langs();
     //return $langs;
     DB::beginTransaction();
     try {
         $com = new Service();
         $com->value = $data['value'];
         $com->option = $data['option'];
         $com->choice = $data['choice'];
         $com->save();
         foreach ($langs as $lang) {
             $code = $data[$lang->code];
             $valid = \Validator::make($code, ['name' => 'required']);
             if ($valid->fails()) {
                 DB::rollBack();
                 return redirect()->back()->withErrors($valid)->withInput();
             }
             $name = $code['name'];
             $com_lang = ['name' => $name];
             //return $com_lang;
             $com->langs()->attach($lang->id, $com_lang);
         }
     } catch (Exception $e) {
         DB::rollBack();
         return redirect()->back()->withInput()->with('errorMess', 'Có lỗi xảy ra!');
     }
     DB::commit();
     return redirect()->route('admin.services.index')->with('Mess', 'Thêm thành công');
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  Request $request
  * @return Response
  */
 public function store(Request $request)
 {
     $service = new Service();
     $service->fill($request->all());
     $service->save();
     return redirect()->route('services.show', $service);
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Request $request)
 {
     //
     $newService = new Service($request->all());
     $newService->save();
     Flash::success("El servicio " . $newService->nombre . " ha sido creado correctamente");
     return redirect()->route('admin.services.index');
 }
Esempio n. 5
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request $request
  * @return \Illuminate\Http\Response
  */
 public function store(ServiceRequest $request)
 {
     $service = new Service();
     $service->fill($request->all());
     $service->section = str_replace('services.', '', $request->section);
     $service->save();
     return redirect(route($request->section))->with('message', 'Servicio creado corectamente');
 }
Esempio n. 6
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $name = $request->get('name');
     $country = $request->get('country');
     $min = $request->get('min');
     $max = $request->get('max');
     $service = new Service();
     $service->name = $name;
     $service->country_id = $country;
     $service->min_process = (int) $min;
     $service->max_process = (int) $max;
     $service->save();
     return redirect()->action("ServicesController@adminIndex");
 }
 public function store(CreateServiceRequest $request)
 {
     $id = Auth::user()->id;
     $services = new Service($request->all());
     $services->iduser_create = $id;
     $services->iduser_update = $id;
     $services->save();
     Session::flash('message', 'El servicio: ' . $services->name . ' se creo exitosamente');
     //  if($action=='save_new')
     //  {
     return redirect()->route('admin.servicios.index');
     //  }
     //    else {
     //       return redirect()->back();
     //    }
 }
Esempio n. 8
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $this->validate($request, ['title' => 'required|max:255', 'note' => 'string', 'month' => 'required|integer|min:1|max:12', 'day' => 'required|integer|min:1|max:31', 'cost' => 'required|regex:/([0-9],)+[0-9]{2,}/|min:0', 'currency' => 'required|in:hrk,usd,eur', 'exchange_rate' => 'required|numeric|min:0', 'active' => 'boolean', 'client_id' => 'required|exists:clients,id', 'category_id' => 'required|exists:categories,id']);
     $client = Client::find($request->get('client_id'));
     $category = Category::find($request->get('category_id'));
     $service = new Service();
     $service->title = $request->get('title');
     $service->note = $request->get('note');
     $service->month = $request->get('month');
     $service->day = $request->get('day');
     $service->cost = convert_integer($request->get('cost'));
     $service->currency = $request->get('currency');
     $service->exchange_rate = $request->get('exchange_rate');
     $service->active = $request->get('active', false);
     $service->client()->associate($client);
     $service->category()->associate($category);
     $service->save();
     event(new ServiceWasCreated($service));
     flash()->success('Service created!');
     return redirect()->route('services.index');
 }
Esempio n. 9
0
 public function store(Request $request)
 {
     if (Auth::check()) {
         $staff_id = Auth::user()->id;
         $sfname = Auth::user()->fname;
         $slname = Auth::user()->lname;
     } else {
         return redirect('auth/login');
     }
     // $cat_id = $request->input('cat_id');
     // $fc = Formcategory::find($cat_id);
     // $formcategory = $fc->formcategory;
     $service = new Service();
     $service->service = $request->input('service');
     $service->defunit = $request->input('defunit');
     //per diem or per service
     $service->description = $request->input('description');
     $service->charge = $request->input('charge');
     $service->duration = $request->input('duration');
     $service->isprogram = $request->input('isprogram');
     $service->cptcode = $request->input('cptcode');
     $service->modifier = $request->input('modifier');
     $service->hcspcs = $request->input('hcspcs');
     $service->staff_id = $staff_id;
     //$request->input('staff_id');
     $service->datestart = $request->input('datestart');
     $service->datestop = $request->input('datestop');
     $service->datedoc = $request->input('datedoc');
     $service->sfname = $sfname;
     //$request->input('sfname');
     $service->slname = $slname;
     //$request->input('slname');
     $service->isactive = 1;
     $service->eie = 0;
     $service->save();
     return redirect('service')->with('status', 'Created Service');
     //
 }
Esempio n. 10
0
 public function addExpense(Request $request, Service $services)
 {
     $inputs = $request->all();
     for ($i = 0; $i < count($inputs['txt_total_by_item']); $i++) {
         $service = new Service();
         $service['created_by'] = \Auth::user()->id;
         $service['updated_by'] = \Auth::user()->id;
         $service['is_active'] = 1;
         $service['company_id'] = 1;
         $service['section_id'] = $inputs['section_id'][$i];
         $service['uom_expense_id'] = $inputs['uom_expense_id'][$i];
         $service['qty'] = $inputs['txt_qty'][$i];
         $service['expense_date'] = date("Y-m-d");
         $service['expense_time'] = $inputs['times'][$i] . ":" . $inputs['minutes'][$i];
         $service['exchange_rate_id'] = $inputs['exchange_rate_id'];
         $service['riel_price'] = $inputs['txt_unit_price'][$i];
         $service['dollar_price'] = $inputs['txt_unit_price_us'][$i];
         $service->save();
     }
     return "success";
 }
Esempio n. 11
0
 public function add(Request $request)
 {
     $input = $request->all();
     isset($request->slug) ? $input['slug'] = $request->slug : null;
     if ($input['slug'] == "slack") {
         $validator = Validator::make($input, ['var1' => 'required|max:255|min:1', 'var2' => 'required|max:255|min:30']);
         if ($validator->fails()) {
             return redirect()->back()->with('message', 'Error adding your service')->withErrors($validator)->withInput();
         } else {
             /*$settings = [
                                 'username' => 'Slackreport',
                                 // 'channel' => '#test2',
                                 'link_names' => true
                             ];
             
                             $client = new \Maknz\Slack\Client($input['var2'], $settings);
                             $status = $client->send('Hey, this is a test message from SlackReport !');*/
             $service = new Service(['user_id' => Auth::user()->id, 'slug' => $validator->getData()['slug'], 'status' => 'ADDED', 'var1' => $validator->getData()['var1'], 'var2' => $validator->getData()['var2']]);
             $status = $service->save();
             if ($status == 1) {
                 return redirect('me/dashboard')->with('message', 'Your service was successfully added !');
             } else {
                 return redirect()->back()->with('message', 'Unknown error while adding your service. Please contact an administrator.')->withInput();
             }
         }
     } else {
         if ($input['slug'] == "ga") {
             /*if (Input::file('var3')->isValid()) {
             
                             $keyfileName = Input::file('var3')->getClientOriginalName();
                             $keyfilePath = "/keys/".Auth::user()->id;
                             File::makeDirectory(public_path().$keyfilePath, $mode = 0777, true, true);
                             Input::file('var3')->move(public_path().$keyfilePath, $keyfileName); // uploading file to given path
             
                         }else{
             
                             return redirect()->back()
                                 ->with('message', 'Certificate is not valid.')
                                 ->withInput();
             
                         }
             
                         $service_account_email = $input['var2'];
                         $key = file_get_contents(public_path().$keyfilePath.'/'.$keyfileName);
             
                         $validp12 = openssl_pkcs12_read($key,$certs,'notasecret');
                         if(!$validp12){
                             return redirect()->back()
                                 ->with('message', 'Invalid p12file')
                                 ->withInput();
                         }
             
                         $client = new \Google_Client();
                         $client->setApplicationName("HelloAnalytics");
                         $analytics = new \Google_Service_Analytics($client);
             
                         $cred = new \Google_Auth_AssertionCredentials($service_account_email,array(\Google_Service_Analytics::ANALYTICS_READONLY),$key);
                         $client->setAssertionCredentials($cred);
                         if($client->getAuth()->isAccessTokenExpired()) {
                             try {
                                 $client->getAuth()->refreshTokenWithAssertion($cred);
                             } catch (\Exception $e){
                                 $error = "Error while connecting to your account.";
                                 if(strpos($e->getMessage(), 'invalid_grant') != false){ $error = "Invalid email or certificate file"; }
                                 return redirect()->back()
                                     ->with('message', $error)
                                     ->withInput();
                             }
                         }
                  
                         $accounts = $analytics->management_accounts->listManagementAccounts();
             
                         if(count($accounts->getItems()) > 0){
             
                             $service = new Service([
                                 'user_id' => Auth::user()->id,
                                 'slug' => $input['slug'],
                                 'status' => 'ADDED',
                                 'var1' => $input['var1'],
                                 'var2' => $service_account_email,
                                 'var3' => $keyfileName,
                                 'var4' => $keyfilePath.'/'.$keyfileName
                             ]);
             
                             $status = $service->save();
             
                             if($status == 1){
                                 return redirect('me/dashboard')
                                     ->with('message', 'Your Google service was successfully added !');
                             }else{
                                 return redirect()->back()
                                     ->with('message', 'Unknown error while adding your service. Please contact an administrator.')
                                     ->withInput();
                             }
             
                         }else{
             
                             return redirect()->back()
                                     ->with('message', 'Error, add a website to your analytics account !')
                                     ->withInput();
                         }*/
             /*$code = $request->get('code');
                         $googleService = \OAuth::consumer('Google');
             
                         if ( ! is_null($code))
                         {
             
                             $token = $googleService->requestAccessToken($code);
                             // $result = json_decode($googleService->request('https://www.googleapis.com/analytics/v3/management/accounts'), true);
                             $result = json_decode($googleService->request('https://www.googleapis.com/oauth2/v1/userinfo'), true);
             
                             $service = new Service([
                                 'user_id' => Auth::user()->id,
                                 'slug' => 'ga',
                                 'status' => 'ADDED',
                                 'var1' => $result['email'],
                                 'var2' => $result['name'],
                             ]);
             
                             $status = $service->save();
             
                             if($status == 1){
                                 return redirect('/dashboard')
                                     ->with('message', 'Your service was successfully added !');
                             }else{
                                 return redirect()->back()
                                     ->with('message', 'Unknown error while adding your service. Please contact an administrator.')
                                     ->withInput();
                             }
             
                         }
                         else
                         {
                             $url = $googleService->getAuthorizationUri();
                             return redirect((string)$url);
                         }*/
             $client = new \Google_Client();
             $client->setAuthConfigFile(public_path() . '/private/google_oauth.json');
             $client->setAccessType("offline");
             $client->setRedirectUri('http://' . $_SERVER['HTTP_HOST'] . '/me/service/add/ga');
             $client->addScope(\Google_Service_Analytics::ANALYTICS_READONLY);
             $client->addScope("email");
             $client->addScope("profile");
             if (!isset($_GET['code'])) {
                 $auth_url = $client->createAuthUrl();
                 return redirect(filter_var($auth_url, FILTER_SANITIZE_URL));
             } else {
                 $client->authenticate($_GET['code']);
                 $plus = new \Google_Service_Oauth2($client);
                 $userinfos = $plus->userinfo->get();
                 $tokens = json_decode($client->getAccessToken());
                 $service = new Service(['user_id' => Auth::user()->id, 'slug' => 'ga', 'status' => 'ADDED', 'var1' => $userinfos->email, 'var2' => $tokens->refresh_token, 'var3' => $userinfos->id, 'var4' => $userinfos->locale, 'var5' => $userinfos->picture, 'var6' => $userinfos->name]);
                 $service->save();
                 return redirect('me/dashboard')->with('message', 'Your service was successfully added !');
             }
         }
     }
 }