/** * @param $query * @param $hashid * @return bool|int */ public function scopeWhereHashid($query, $hashid) { $id = Hashids::decode($hashid); if (count($id) == 0) { return false; } return $query->where('id', $id[0]); }
/** * Store a new game for the current seed. * * @param StoreSeedGameRequest $request * * @return Response * * @api {post} /v1/seeds/:id/games Store a new game of a seed. * @apiVersion 1.0.0 * @apiName StoreSeedGame * @apiGroup Seeds * @apiPermission User * * @apiParam {String} user_id User unique ID. * @apiParam {String} data Game's data in json format. * @apiParam {Number} score Game's score. * * @apiUse GamesSuccess * * @apiUse ApiLimitError */ public function store($seedId, StoreSeedGameRequest $request) { $user = $this->user->find(Hashids::decode($request->input('user_id')))->first(); $game = new Game($request->only('data', 'score')); $game->user()->associate($user); $game = $this->seed->find($seedId)->first()->games()->save($game); return $this->response->item($game, new GameTransformer()); }
/** * Define your route model bindings, pattern filters, etc. * * @param \Illuminate\Routing\Router $router * @return void */ public function boot(Router $router) { $router->bind('bin', function ($value) { $id = Hashids::decode($value); if (empty($id)) { $id = null; } else { $id = $id[0]; } return Bin::where('id', $id)->first(); }); $router->bind('comment', function ($value) { $id = Hashids::decode($value); if (empty($id)) { $id = null; } else { $id = $id[0]; } return Comment::where('id', $id)->first(); }); parent::boot($router); }
public function Detalles($id) { $record = Hashids::decode($id); $registro = \DB::table('Promociones')->where('Promociones.id', '=', $record[0])->select('Promociones.id', 'Promociones.nombre', 'Promociones.imagen', 'Promociones.descripcion', 'Promociones.inicio', 'Promociones.fin')->first(); return view('Center.promociones.detalles')->with('registro', $registro); }
public function Detalles($id) { $record = Hashids::decode($id); $registro = \DB::table('Servicios')->where('Servicios.id', '=', $record[0])->select('Servicios.id', 'Servicios.nombre', 'Servicios.imagen', 'Servicios.descripcion', 'Servicios.estado')->first(); return view('Center.servicios.detalles')->with('registro', $registro); }
public function editar($id) { $record = Hashids::decode($id); $registro = Preguntas::find($record[0]); return view('Center.preguntas.editar')->with('registro', $registro); }
function decode($value) { $value = Hashids::decode($value); return count($value) === 1 ? $value[0] : 0; }
public function ajax(Request $request) { $type = $request->type; $id = $request->id; $record = Bin::where('user_id', auth()->user()->getAuthIdentifier())->find(Hashids::decode($id)); if (!$record) { return response()->json(['msg' => 'There was an issue with your request!'], 422); } if ($type == 'visibility') { $record->visibility = $request->visibility; $record->save(); return response()->json(['msg' => 'Bin updated successfully!'], 200); } if ($type == 'hash') { // make sure bin is private, if not, then hash isn't needed if ($record->isPrivate()) { // Bin has private hash, request is to delete if ($record->isShared()) { $record->private_hash = null; $record->save(); return response()->json(['msg' => 'Bin sharing has been disabled!', 'status' => 'disabled'], 200); } else { // No private hash exists, create one $record->private_hash = str_random(30); $record->save(); return response()->json(['msg' => 'Bin sharing enabled!', 'status' => 'enabled', 'url' => $record->shareUrl()], 200); } } return response()->json(['msg' => 'Bin is not private! No need for share url!'], 400); } return response()->json([], 200); }
<?php use Vinkla\Hashids\Facades\Hashids; $api = app('Dingo\\Api\\Routing\\Router'); Route::bind('id', function ($value, $route) { return Hashids::decode($value); }); // Authentification routes $api->version('v1', ['namespace' => 'NanokaWeb\\AsyncGame\\Api\\V1\\Controllers', 'middleware' => ['api.throttle', 'cors'], 'limit' => 100, 'expires' => 5], function ($api) { // Auth email / password $api->post('v1/auth/signup', 'AuthController@signup'); $api->post('v1/auth/login', 'AuthController@login'); // Auth Facebook token $api->post('v1/auth/fblogin', 'AuthController@fbLogin'); // Auth Device $api->post('v1/auth/devicelogin', 'AuthController@deviceLogin'); // $api->post('v1/auth/recovery', 'NanokaWeb\AsyncGame\Api\V1\Controllers\AuthController@recovery'); // $api->post('v1/auth/reset', 'NanokaWeb\AsyncGame\Api\V1\Controllers\AuthController@reset'); }); // Need auth $api->version('v1', ['middleware' => ['api.auth', 'api.throttle', 'cors'], 'limit' => 100, 'expires' => 5], function ($api) { $api->group(['namespace' => 'NanokaWeb\\AsyncGame\\Api\\V1\\Controllers', 'middleware' => ['asyncgame.roles'], 'roles' => ['root', 'administrator', 'user']], function ($api) { /* * Endpoint me */ $api->get('v1/me', 'MeController@showMe'); $api->get('v1/me/opponents/{nb}', 'MeController@opponentsMe')->where('nb', '[0-9]'); $api->put('v1/me', 'MeController@updateMe'); $api->post('v1/me/coins', 'MeController@updateCoinsMe'); /* * Endpoint seeds
public function Detalles($id) { $record = Hashids::decode($id); $registro = \DB::table('Opciones')->join('menus', 'menus.id', '=', 'Opciones.menu')->where('Opciones.id', '=', $record[0])->select('Opciones.id', 'Opciones.nombre', 'Opciones.imagen', 'Opciones.extra', 'Opciones.descripcion', 'Opciones.costo', 'menus.nombre AS menu')->first(); return view('Center.menu.detalles')->with('registro', $registro); }
/** * Funcion que retorna la vista de edicion de registro * @param $id - parametro que contiene el id del registro a editar */ public function editar($id) { $record = Hashids::decode($id); $registro = User::find($record[0]); $roles = \DB::table('roles')->get(); return view('Center.empleados.editar')->with('registro', $registro)->with('roles', $roles); }