コード例 #1
0
ファイル: ContactController.php プロジェクト: gtcrais/gtcms
 public static function handler()
 {
     $data = array('success' => false, 'title' => trans('t.contactErrorTitle'), 'message' => trans('t.contactErrorMessage'));
     $requestAllowed = true;
     if (self::$requestType == 'ajax') {
         $requestAllowed = \Request::ajax() && \Request::get('getIgnore_isAjax');
     }
     if ($requestAllowed) {
         $validator = \Validator::make(\Request::all(), self::$rules);
         if ($validator->fails()) {
             $messages = $validator->getMessageBag()->toArray();
             $finalMessages = array();
             foreach ($messages as $field => $fieldMessages) {
                 foreach ($fieldMessages as $fieldMessage) {
                     $finalMessages[] = $fieldMessage;
                 }
             }
             $message = implode("\n", $finalMessages);
             $data['message'] = $message;
             return self::returnData($data);
         } else {
             try {
                 Mailer::sendMessage(\Request::all());
                 $data['success'] = true;
                 $data['title'] = trans('t.contactSuccessTitle');
                 $data['message'] = trans('t.contactSuccessMessage');
             } catch (\Exception $e) {
                 Dbar::error("Error while sending message: " . $e->getMessage());
             }
         }
         return self::returnData($data);
     }
     \App::abort(404);
 }
コード例 #2
0
 /**
  * [updatePhoto description]
  * @param  Integer Id do usuário
  * @return ??
  */
 public function cropPhotoEntidade($entidade, CropPhotoRequest $request)
 {
     if (!$entidade) {
         App::abort(500, 'Erro durante o processamento do crop');
     }
     $file = Input::file('image_file_upload');
     if ($file && $file->isValid()) {
         $widthCrop = $request->input('w');
         $heightCrop = $request->input('h');
         $xSuperior = $request->input('x');
         $ySuperior = $request->input('y');
         $destinationPath = public_path() . '/uploads/';
         $extension = Input::file('image_file_upload')->getClientOriginalExtension();
         // Pega o formato da imagem
         $fileName = self::formatFileNameWithUserAndTimestamps($file->getClientOriginalName()) . '.' . $extension;
         $file = \Image::make($file->getRealPath())->crop($widthCrop, $heightCrop, $xSuperior, $ySuperior);
         $upload_success = $file->save($destinationPath . $fileName);
         //Salvando imagem no avatar do usuario;
         if ($upload_success) {
             /* Settando tipo da foto atual para null, checando se existe antes */
             if ($entidade->avatar) {
                 $currentAvatar = $entidade->avatar;
                 $currentAvatar->tipo = null;
                 $currentAvatar->save();
             }
             $foto = new Foto(['path' => $fileName, 'tipo' => 'avatar']);
             $entidade->fotos()->save($foto);
             return true;
         } else {
             return false;
         }
     }
 }
コード例 #3
0
 function form($id = null)
 {
     /////////////////////////////
     // Load Data if applicable //
     /////////////////////////////
     if ($id) {
         $query['id'] = $id;
         $api_response = json_decode($this->api->get($this->api_url . '/travel_agents?' . http_build_query(array_merge($query, ['access_token' => Session::get('access_token')])))->getBody());
         if ($api_response->status != 'success') {
             return App::abort(404);
         }
         $data = $this->reformat_images($api_response->data->data)[0];
         foreach ($data->addresses as $address) {
             $address->status = 'data';
         }
         unset($data->addresses);
         $data->addresses = [$address];
     }
     /////////////////
     // Create Form //
     /////////////////
     $this->layout->page_template = view($this->version . '.vendors.template');
     $this->layout->page_template->page = view($this->version . '.vendors.travel_agents.form')->with('id', $id);
     $this->layout->page_template->page->data = $data;
     return $this->layout;
 }
コード例 #4
0
 function __construct()
 {
     $this->errors = new MessageBag();
     $this->page_attributes = new \Stdclass();
     $api_url = '/oauth/client/access_token';
     $api_data = ['grant_type' => 'client_credentials', 'client_id' => env('CLIENT_ID'), 'client_secret' => env('CLIENT_SECRET')];
     $api = new API();
     $result = json_decode($api->post($api_url, $api_data), true);
     // Get success API token
     if ($result['status'] == "success") {
         Session::set('API_token_public', $result['data']['token']['token']);
         Session::set('API_token', $result['data']['token']['token']);
     } else {
         \App::abort(503);
     }
     //generate balin information
     $APIConfig = new APIConfig();
     $config = $APIConfig->getIndex(['search' => ['default' => 'true'], 'sort' => ['name' => 'asc']]);
     $balin = $config['data'];
     unset($balin['info']);
     foreach ($config['data']['info'] as $key => $value) {
         $balin['info'][$value['type']] = $value;
     }
     $this->balin = $balin;
     //nanti kalu butuh template lebih dari satu, switch case aja disini.
     $this->layout = view('web_v2.page_templates.layout');
 }
コード例 #5
0
 /**
  * Display the password reset view for the given token.
  *
  * @param  string  $token
  * @return Response
  */
 public function getReset($token = null)
 {
     if (is_null($token)) {
         App::abort(404);
     }
     return View::make('password.reset')->with('token', $token);
 }
コード例 #6
0
 public function getPoster($id)
 {
     $poster = Poster::find($id);
     if (!$poster) {
         App::abort(404);
     }
     return view('posters/view', array('poster' => $poster));
 }
コード例 #7
0
ファイル: AdminController.php プロジェクト: serovvitaly/kotik
 public function __construct(Request $request)
 {
     $this->user = \Auth::user();
     if (!$this->user->userCan('adminka-access')) {
         \App::abort(403, 'Access denied');
     }
     $this->request = $request;
 }
コード例 #8
0
 /**
  * [showProfile description]
  * @param  [type] $id [description]
  * @return [type]     [description]
  */
 public function showProfile($id)
 {
     $user = User::find($id);
     if (is_null($user)) {
         App::abort(404);
     }
     return View::make('pages.user.profile', array('user' => $user, 'briefingRows' => trans('profile.briefingRows')));
 }
コード例 #9
0
 public function listarPorEstado($estadoId)
 {
     $estado = Estado::find($estadoId);
     if (is_null($estado)) {
         App::abort(404);
     }
     $municipios = Municipio::orderBy('nombre')->where('estado_id', '=', $estadoId)->get();
     return $municipios;
 }
コード例 #10
0
 public function edit($username)
 {
     $user = User::where('username', $username)->get();
     $s_config = Config::get('social.networks');
     if ($user->count()) {
         return view('profile.edit')->with(['user' => $user->first(), 's_config' => $s_config]);
     }
     return App::abort(404);
 }
コード例 #11
0
 public function eliminar($id)
 {
     $participante = Participante::find($id);
     if (is_null($participante)) {
         App::abort(404);
     }
     $participante->delete();
     return response()->json(['success' => true, 'msg' => 'Usuario ' . $participante->nombres . ' ' . $participante->apellidos . ' eliminado.', 'id' => $participante->id]);
 }
コード例 #12
0
 public function user($username)
 {
     $user = User::where('username', '=', $username);
     if ($user->count()) {
         $user = $user->first();
         return view('account.profile')->withUser($user);
     }
     return \App::abort(404);
 }
コード例 #13
0
 /**
  * @param $platform
  * @param $gamertag
  * @return \Destiny\Player
  */
 protected function findPlayer($platform, $gamertag)
 {
     $players = destiny()->player($gamertag);
     $player = $players->get($platform);
     if (!$player instanceof Player) {
         \App::abort(404, "The player '{$gamertag}' on '{$platform}' could not be found.");
     }
     return $player;
 }
コード例 #14
0
ファイル: DocController.php プロジェクト: johnfelipe/madison
 public function getEmbedded($slug = null)
 {
     $doc = Doc::findDocBySlug($slug);
     if (is_null($doc)) {
         App::abort('404');
     }
     $view = View::make('doc.reader.embed', compact('doc'));
     return $view;
 }
コード例 #15
0
 /**
  * @GET("/nottifications/{id}/delete/", as="nottifications.destroy")
  */
 public function destroy($id)
 {
     $model = Nottifications::where('id', $id)->first();
     if ($model->user->id != Auth::user()->id) {
         App::abort(404);
     } else {
         $model->delete();
     }
 }
コード例 #16
0
 public function documentShow($id)
 {
     $document = \App\Models\Document::find($id);
     // Если такого документа нет, то вернем пользователю ошибку 404 - Не найдено
     if (!$document) {
         App::abort(404);
     }
     return View::make('admin.document.show', array('document' => $document));
 }
コード例 #17
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $file = UploadedFile::findOrFail($id);
     if ($file->uploader_id !== Auth::user()->id) {
         App::abort(403);
     }
     $file->delete();
     return response('');
 }
コード例 #18
0
 public function listarPorDia($diaId, Request $request)
 {
     $dia = Dia::find($diaId);
     if (is_null($dia)) {
         App::abort(404);
     }
     //$horariosNoDisponibles = $this->HorariosOcupados($diaId);
     $horarios = $dia->Horarios()->orderBy("nombre")->get();
     return $horarios->toArray();
 }
コード例 #19
0
ファイル: OwnerController.php プロジェクト: bgaeddert/PropMan
 /**
  * @return mixed
  */
 public function store()
 {
     $input = \Request::all();
     $validator = \Validator::make($input, ['org_id' => "in:" . \Auth::user()->org_id, 'owner_name' => 'required|max:255']);
     if ($validator->fails()) {
         \App::abort(400, $validator->messages()->first());
     }
     $owner = Owner::create($input);
     return \Response::json(['success' => true, 'message' => 'Owner Created.', 'data' => $owner]);
 }
コード例 #20
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     $document = \App\Models\Document::find($id);
     $document_type = $document->document_type;
     $document_title = \App\Models\Document::documentTitle($document_type);
     // Если такого документа нет, то вернем пользователю ошибку 404 - Не найдено
     if (!$document) {
         App::abort(404);
     }
     return View::make('document.view', compact('document', 'document_title'));
 }
コード例 #21
0
 public function update($id)
 {
     $candidato = VtCandidato::findOrFail($id);
     try {
         $candidato->fill(['participante_id' => Request::input('participante_id'), 'aspiracion_id' => Request::input('aspiracion_id'), 'locked' => Request::input('locked')]);
         $candidato->save();
     } catch (Exception $e) {
         return App::abort('400', 'Datos incorrectos');
         return $e;
     }
 }
コード例 #22
0
 /**
  * Affiche les participants associés au sport sélectionné par région.
  *
  * @param[in] int $id l'id du sport qu'on sélectionne.
  */
 public function index($id)
 {
     try {
         $sport = Sport::findOrFail($id);
         $regions = Region::all()->sortby('nom');
         $participants = $sport->participants->sortby('nom');
         return View::make('sportParticipant.index', compact('regions', 'participants', 'sport'));
     } catch (ModelNotFoundException $e) {
         App::abort(404);
     }
 }
コード例 #23
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     try {
         $user = Auth::user();
         $role = $user->role;
         $recettes = Recette::all()->sortby('codeModele');
     } catch (ModelNotFoundException $e) {
         App::abort(404);
     }
     return View::make('recettes.index', compact('recettes', 'role'));
 }
コード例 #24
0
 /**
  * @return mixed
  */
 public function store()
 {
     $input = \Request::all();
     $validator = \Validator::make($input, ['unit_id' => 'required', 'tenant_name' => 'required|max:255']);
     if ($validator->fails()) {
         \App::abort(400, $validator->messages()->first());
     }
     $tenant = new Tenant($input);
     $unit = Unit::find($input['unit_id']);
     $tenant = $unit->Tenants()->save($tenant);
     return \Response::json(['success' => true, 'message' => 'Tenant Created.', 'data' => $tenant]);
 }
コード例 #25
0
 /**
  * @return mixed
  */
 public function store()
 {
     $input = \Request::all();
     $validator = \Validator::make($input, ['owner_id' => 'required', 'property_name' => 'required|max:255']);
     if ($validator->fails()) {
         \App::abort(400, $validator->messages()->first());
     }
     $property = new Property($input);
     $owner = Owner::find($input['owner_id']);
     $property = $owner->Properties()->save($property);
     return \Response::json(['success' => true, 'message' => 'Property Created.', 'data' => $property]);
 }
コード例 #26
0
ファイル: UnitController.php プロジェクト: bgaeddert/PropMan
 /**
  * @return mixed
  */
 public function store()
 {
     $input = \Request::all();
     $validator = \Validator::make($input, ['property_id' => 'required', 'unit_name' => 'required|max:255']);
     if ($validator->fails()) {
         \App::abort(400, $validator->messages()->first());
     }
     $unit = new Unit($input);
     $property = Property::find($input['property_id']);
     $unit = $property->Units()->save($unit);
     return \Response::json(['success' => true, 'message' => 'Unit Created.', 'data' => $unit]);
 }
コード例 #27
0
 /**
  * Display a confession based on ID for search engine crawlers
  * @param  int $id confession ID
  * @return void
  */
 public function getConfession($id)
 {
     if ($this->isCrawler()) {
         $confession = Confession::approved()->find($id);
         if (!$confession) {
             \App::abort(404);
         }
         return view('robots.confession', ['confession' => $confession]);
     } else {
         return redirect(url('/confession', $id));
     }
 }
コード例 #28
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($uuid)
 {
     $traces = $this->traces->whereUuid($uuid);
     if (!isset($traces)) {
         if ($uuid != 'city' && $uuid != 'urban' && $uuid != 'rural') {
             \App::abort('404');
         }
     }
     $file_contents = file_get_contents(storage_path() . '/traces/' . $uuid . '.csv');
     $trace_lines = explode("\n", $file_contents);
     //just removing pesky empty strings
     $trace_lines = array_filter($trace_lines);
     return \View::make('traces.show')->withTrace_lines($trace_lines)->withTraces($traces);
 }
コード例 #29
0
 public function store(Request $request)
 {
     $this->validate($request, ['name' => 'required|max:255', 'email' => 'required|email|max:255|unique:users', 'password' => 'required|confirmed|min:6', 'rol' => 'required|in:1,2', 'image' => 'required|mimes:jpeg,png,bmp']);
     if (!$request->file('image')->isValid()) {
         Log::error('Invalid image file for user ' . Carbon::now());
         App::abort(500);
     }
     $image_name = $request->input('email') . Carbon::now()->timestamp . "_" . $request->file('image')->getClientOriginalName();
     $request->file('image')->move(public_path() . '/images/users/', $image_name);
     $data = $request->all();
     $data['image'] = $image_name;
     User::create($data);
     return redirect(action('UserController@index'));
 }
コード例 #30
0
 public function getComment($doc, $commentId)
 {
     try {
         $userId = null;
         if (Auth::check()) {
             $userId = Auth::user()->id;
         }
         $result = Comment::loadComment($doc, $commentId, $userId);
     } catch (Exception $e) {
         throw $e;
         App::abort(500, $e->getMessage());
     }
     return Response::json($result);
 }