text
stringlengths
316
100k
Today, there are reports that the far-right America destroyers, the Koch Brothers, are out to gobble up the Tribune Company-owned newspapers and possibly its TV Stations. You though Rupert Murdoch was bad? Just wait till you meet the Kochtopus. Think Progress Media: The Koch brothers own Koch Industries, the second-...
Strikingly, for a political newsmaker in a year plagued by grim events, most of the 278 comments about his contribution were positive, and almost all of them were about his work to legalise euthanasia. "Putting political considerations aside, this profound moral question has been discussed and guided through the legisl...
28 Condivisioni Facebook Whatsapp Telegram Flipboard Twitter Pinterest Linkedin Come sappiamo, Google è un forte sostenitore delle energie rinnovabili. E, come tale, il suo obiettivo è quello di aiutare le persone a capire l’importanza di adottare pannelli solari sui tetti delle loro case. E in particolare attraverso ...
Melbourne petrol stations restock after running out of fuel when delivery trucks were taken off the road Updated Petrol stations are monitoring their fuel supplies after dozens of delivery trucks were taken off the road by safety inspectors. More than 60 Cootes Transport trucks were suspended from service yesterday ...
THOSE looking for a quick bite while they are casting their vote in the federal election now have an online friend to tell them where to go. The www.electionsausagesizzle.com.au website has created an online map for those who want to grab a snack and contribute to local causes before or after they vote. While about 7...
It's not just the Dallas Mavericks who've nudged their way into the race for Greg Oden along with NBA Finals combatants Miami and San Antonio. There are growing indications that the New Orleans Pelicans are going to be a factor in the Oden chase as well. Sources close to the situation told ESPN.com that the Pelicans ...
Out in the desert, a young would-be monk labors. He is on a mission for his monastery, a week of fasting and privation that all initiates must go through. As he works to create a shelter for the coming night, he sees a traveler approaching. No one travels the desert so he is filled with fear. The man approaches. He is ...
Russian energy major Rosneft has agreed to take control of the main oil pipeline in Iraq’s Kurdistan, further boosting its role as the main international investor in the semi-autonomous region. The move is an apparent part of a broader strategy by President Vladimir Putin to ratchet up Moscow’s political and economic ...
Archaeologists and historians have begun to convert social theories to computer programs, intending to simulate social processes and historical trajectories of known societies. We can mention two kinds of approaches: implementing a social theory of human action in the past to test the internal coherence of such a theor...
Protesters shouted over Virginia Republican gubernatorial candidate Corey Stewart as he gave interviews about his opposition to removing a Robert E. Lee statue from a Charlottesville park in February. (Fenit Nirappil/The Washington Post) RICHMOND — For a minute there, it looked like Corey Stewart’s bid for Virginia go...
After watching Frozen hundreds of times, it has started to rub off on most things in our life. We want every snowman to talk, we appreciate clothes with rosemaling, and we want to be awake when the sky is awake. We’ve also noticed that some of our favorite Disney males are what the trolls would call, “fixer uppers.” Wi...
Back in 1996 the Web was starting to gain some serious momentum, but it was still just a few years old. Now in 2008, looking 12 years back into the past of the Web can be a both nostalgic and entertaining experience. To give you some perspective, in 1996… Google.com didn’t exist yet. In January 1996 there were only ...
GORAV GUPTA has spent his life helping the mentally ill. But when suicidal patients seek help at his psychiatric hospital in Delhi, he turns them away. Mr Gupta says he cannot handle the “legal hassle” that might ensue if they try to end their lives while in his care. Get our daily newsletter Upgrade your inbox and ge...
Donny Ray Williams Jr., a former Democratic congressional aide, pleaded guilty to sexually assaulting two women. His face was disfigured by an unrelated acid attack a year after his arrest. The protrusion on Williams’ head is the result of a rod surgically implanted to stretch the skin and promote healing. (Ricky Cario...
The D.C. region’s transportation planners often say they want to give travelers more choices. In transit, those options include rapid bus service in dedicated lanes, light-rail lines and streetcars. All the major jurisdictions have such transit projects in various stages of development, but the one likely to appear fir...
An Australian bearded dragon (Stephan Junek/Max Planck Institute for Brain Research via Reuters) The dragon's eyes twitch under its lids. An electronic monitor hooked up to its brain shows activity spiking across it. Somewhere inside its reptilian subconscious, a dream may be playing out — of enjoying a satisfying mea...
In the financial world, some shares have new owners every second. Today, much of the buying and selling is done by computers, but many trades still rely on human intuition—the gut feeling of the experienced trader. “Nobody can predict the market, but traders are expected to,” Richard Taffler, professor of finance at t...
Attorney Damario Solomon-Simmons, left, comforts Tiffany Crutcher, twin sister of Terence Crutcher, who was shot and killed by Tulsa police last week. At right is the Rev. Joey Crutcher, Terence’s father. (Mike Simons/Tulsa World via AP) Some guest posts don’t need much of an introduction. This is from a teacher in Tu...
Adobe has announced today the public availability of an Adobe AIR alpha release for Linux. Although the alpha is not feature-complete, it is already capable of running some mainstream AIR applications and is robust enough to facilitate AIR development on the Linux platform. Adobe has also officially joined the Linux Fo...
Of Mice and Men, the John Steinbeck novella, is one of a number of American classics that have been axed from new English literature GCSEs after the education secretary insisted students must study British works. Michael Gove’s intervention means three-quarters of the books on the government directed GCSEs, which will...
Making your own BBQ sauce is easier than one might think and it tastes far superior to anything purchased in the grocery store. There are plenty of recipes online for BBQ sauces but many of them use ketchup as a base ingredient. I decided that I wanted to develop a bbq sauce recipe that used more original ingredients. ...
ERROR: type should be string, got "https://github.com/mbaljeetsingh/laravel5-jokes-api-with-jwt-and-pagination\n\nLaravel & Angularjs works really well together, if used in a correct way. In this Laravel & Angularjs Series, we will be creating an app where Laravel will be used for creating an API and Angularjs for consuming that API.\n\nThis series is aimed at those, who want to completely separate their frontend and backend. This is the most common use case in hybrid app development using phonegap or ionic framework. So without further due, let’s get started with the Laravel Part.\n\nInstall Laravel & Create New Project\n\nFirst Install Composer By Following this guide. Then, download the Laravel installer using Composer.\n\ncomposer global require \"laravel/installer=~1.1\"\n\nOnce successfully installed, you can type laravel new command to create new Laravel project.\n\nlaravel new project_name\n\nAfter successfully creating the project, make sure your webserver is running (you can use XAMPP, LAMP, MAMP), now go into the project directory and type.\n\nphp artisan serve\n\nNow you can open the following url.\n\nhttp://localhost:8000 And you will see the Laravel front page.\n\nNow we will add a package called Laravel-5-Generators. This Laravel package provides a variety of generators to speed up your development process.\n\nYou can install the generator via composer as:\n\ncomposer require laracasts/generators --dev\n\nNow open the app/Providers/AppServiceProvider.php file and updated the register function as,\n\npublic function register() { if ($this->app->environment() == 'local') { $this->app->register('Laracasts\\Generators\\GeneratorsServiceProvider'); } }\n\nNow run,\n\nphp artisan\n\nYou will see new commands added in the make:* section.\n\nSetup DB, Create Migration & Insert Dummy Data\n\nSetup DB\n\nFirst, rename the .env.example file in the laravel installation root directory to .env\n\nnow open the .env file and change the following:-\n\nDB_HOST=localhost DB_DATABASE= your_database_name DB_USERNAME= your_database_username DB_PASSWORD= your_database_password\n\nCreate Migration\n\nNext step is to create the migration, as the laravel documentation says, Migrations are like version control for your database, allowing a team to easily modify and share the application’s database schema. Open the terminal and type the following command to create the migration.\n\nphp artisan make:migration create_jokes_table\n\nYou can see the created migration in database/migrations folder. Open the migration file and replace it with this code.\n\n<?php use Illuminate\\Database\\Schema\\Blueprint; use Illuminate\\Database\\Migrations\\Migration; class CreateJokesTable extends Migration { /** * Run the migrations. * * @return void */ public function up() { Schema::create('jokes', function (Blueprint $table) { $table->increments('id'); $table->text('joke'); $table->integer('user_id'); $table->timestamps(); }); } /** * Reverse the migrations. * * @return void */ public function down() { Schema::drop('jokes'); } }\n\nHere you can see we have added the id, joke, user_id and timestamps fields. Where id is auto incrementing, joke is the body of the joke and user_id will be used for the user who will submit the joke. Here there are two functions one is up and other is down. The down function is the exact opposite of the up and will be used if we want to revert back the migration.\n\nNow run the following command\n\nphp artisan migrate\n\nNow have a look at the database, you can see the new jokes table there. Along with jokes table, laravel creates three other tables namely users, migrations, password_resets.\n\nNow to demonstrate the down function. Let’s say we want to change the joke field with body. What you can do is, change the field in the migration table.\n\npublic function up() { Schema::create('jokes', function (Blueprint $table) { $table->increments('id'); $table->text('body'); $table->integer('user_id'); $table->timestamps(); }); }\n\nNow run the following commands.\n\nphp artisan migrate:rollback php artisan migrate\n\nNow open the database and check the structure and you can see the jokes table joke field renamed to body.\n\nInsert Dummy Data\n\nThe next step is to insert the dummy data that we can use throughout the development process. For inserting dummy data we will use a package called fzaninotto/faker.\n\nFirst we need to install this package,\n\ncomposer require fzaninotto/faker\n\nNow first create a Joke Model by typing:\n\nphp artisan make:model Joke\n\nNow create the seed file which will be used to insert dummy data.\n\nphp artisan make:seed Jokes\n\nYou can see the created seeder file in database/seed folder. Open JokesTableSeeder.php and add the following.\n\n<?php use Illuminate\\Database\\Seeder; use App\\Joke; class JokesTableSeeder extends Seeder { /** * Run the database seeds. * * @return void */ public function run() { $faker = Faker\\Factory::create(); foreach(range(1,30) as $index) { Joke::create([ 'body' => $faker->paragraph($nbSentences = 3), 'user_id' =>$faker->numberBetween($min = 1, $max = 5) ]); } } }\n\nAt the top you can see, we have added App\\Joke that makes us available the jokes model and we are using to create new jokes as Joke::create. Here you can see we have used $faker object, it is availabe through package. For the list of all the available functions, you can have a look at their documentation.\n\nNow Create the new seed file for users table as.\n\nphp artisan make:seed UsersTableSeeder\n\nNow open UsersTableSeeder.php and add the following.\n\n<?php use Illuminate\\Database\\Seeder; use App\\User; class UsersTableSeeder extends Seeder { /** * Run the database seeds. * * @return void */ public function run() { $faker = Faker\\Factory::create(); foreach(range(1,5) as $index) { User::create([ 'name' => $faker->userName, 'email' =>$faker->email, 'password' =>bcrypt('secret') ]); } } }\n\nHere you can see we have added App\\User at the top, which means we are requiring user model. It is availabe through default laravel install.\n\nThe next step is to open DatabaseSeeder.php and add the created seeder classes.\n\n<?php use Illuminate\\Database\\Seeder; use Illuminate\\Database\\Eloquent\\Model; class DatabaseSeeder extends Seeder { /** * Run the database seeds. * * @return void */ public function run() { Model::unguard(); $this->call(JokesTableSeeder::class); $this->call(UsersTableSeeder::class); Model::reguard(); } }\n\nNow before using the seed command we need to do one more thing. Open the Joke Model file. This will be inside app root folder and add the fillable array inside the class as.\n\nprotected $fillable = ['body', 'user_id'];\n\nBy using this we can mass insert values in the database table.\n\nNow the last step is to run the db seed command as.\n\nphp artisan migrate --seed\n\nAfter that you can see the database table with all the dummy entries.\n\nCreating & Testing Routes\n\nIn the last section we successfully created the database, created migration and prepared seeder classes. In this section we will create our routes or api end points which we can hit to get data.\n\nOpen the routes.php file and add the follwing code:\n\nRoute::resource('jokes', 'JokesController');\n\nNow we need to create the JokesController, for this we will use generators like,\n\nphp artisan make:controller JokesController\n\nThis command will create the jokescontroller with all the required methods.\n\nNow run this command:\n\nphp artisan route:list\n\nYou will see output similar to this:\n\nNow we can add the prefix to all these routes as, in the routes.php updates the code as: Route::group([‘prefix’ => ‘api/v1’], function(){ Route::resource(‘jokes’, ‘JokesController’); }); Now your output will look like:\n\nNow open the JokesController.php, add the following at the top,\n\nuse App\\Joke;\n\nNow update the index method as:\n\npublic function index(){ $jokes = Joke::all(); //Not a good idea return $jokes; }\n\nHere we are using the Eloquent ORM, which makes it easy to work with database. If you don’t know about eloquent, have a look at the Eloquent Documentation.\n\nThe Joke::all() will return all the rows from the jokes table.\n\nNow run the server as:\n\nphp artisan serve\n\nand open:\n\nhttp://localhost:8000/api/v1/jokes\n\nYou will see all the records from the jokes table, also it is worth mentioning, the data is casted to json automatically.\n\nNow using the browser is good if you want to test GET request, but if you want to test POST, PUT, PATCH, DELETE request we probably will not use browser for this. So, for that scenario we can use Curl, which is perfectly fine or we can use a utility called POSTMAN which is a chrome extension. That makes it really easy to test all the requests. Let’s see how we can test our api with postman. Install the postman extension and open postman:\n\nHere select the request (GET, POST etc.), enter url and press send, the output is similar to the one we saw in browser but this will prove more useful once we get to other requests.\n\nNow, yes it is a working api but there are some problems with it:\n\nIt is not a good idea to return all the results at once.\n\nWe are showing the exact structure of the table.\n\nWe are sending any error message and response codes.\n\nNow in the following sections, we will work on improving that api.\n\nResponses & Codes\n\nNow let’s add the status codes to the data, the available status codes are:\n\nUpdated the index method in the JokesController.php as follows:\n\npublic function index(){ $jokes = Joke::all(); return Response::json([ 'message' => $jokes ], 400); }\n\nNow open the /api/v1/jokes url in the postman, you can see status returned as 400.\n\nThe 400 is mainly for the bad request, so the status that we probably want to return is 200, so change the code as follows:\n\npublic function index(){ $jokes = Joke::all(); return Response::json([ 'data' => $jokes ], 200); }\n\nNow again hit the endpoint/url in the postman, you can see status returned as 200.\n\nNow let’s implement the route for getting single joke, we can see from php artisan route:list, when we get to api/v1/jokes/{jokes} we are calling the show method and will get single joke.\n\nSo update the show method as follows:\n\npublic function show($id){ $joke = Joke::find($id); if(!$joke){ return Response::json([ 'error' => [ 'message' => 'Joke does not exist' ] ], 404); } return Response::json([ 'data' => $joke ], 200); }\n\nNow try accessing this route, if the joke with specific id not exists we will get the error response and if it exists we will get the 200 response.\n\nIf the joke exists:\n\nIf the joke doesn’t exists:\n\nTransforming Data\n\nAt that point, we can see that, we are returning the exact db table structure, and it is not a good idea, it may be possible we only want to show specific fields and don’t want to show the fields name as in the table. So for this we can transform the data before displaying.\n\nAdd the following two methods at the bottom of the JokesController Class in the JokesController.php,\n\nprivate function transformCollection($jokes){ return array_map([$this, 'transform'], $jokes->toArray()); } private function transform($joke){ return [ 'joke_id' => $joke['id'], 'joke' => $joke['body'] ]; }\n\nNow update the index and show methods as:\n\npublic function index(){ $jokes = Joke::all(); return Response::json([ 'data' => $this->transformCollection($jokes) ], 200); } public function show($id){ $joke = Joke::find($id); if(!$joke){ return Response::json([ 'error' => [ 'message' => 'Joke does not exist' ] ], 404); } return Response::json([ 'data' => $this->transform($joke) ], 200); }\n\nNow again hit the routes and you will see the transformed data.\n\nEloquent Relationships\n\nUsing Eloquent Relationships we can relate two tables.\n\nFirst we need to define the relationship between the two tables users and jokes and then we can join the tables data.\n\nLet’s start by adding a relationship:\n\nopen the User.php model file and add the following method:\n\npublic function jokes(){ return $this->hasMany('App\\Joke'); }\n\nand open the Joke.php model file and ad the following method:\n\npublic function user(){ return $this->belongsTo('App\\User'); }\n\nNow open the JokesController.php and update the show method as follows, before that add the following code at the top:\n\nuse App\\User;\n\nNow update the show method as:\n\npublic function show($id) { $joke = Joke::with( array('User'=>function($query){ $query->select('id','name'); }) )->find($id); if(!$joke){ return Response::json([ 'error' => [ 'message' => 'Joke does not exist' ] ], 404); } // get previous joke id $previous = Joke::where('id', '<', $joke->id)->max('id'); // get next joke id $next = Joke::where('id', '>', $joke->id)->min('id'); return Response::json([ 'previous_joke_id'=> $previous, 'next_joke_id'=> $next, 'data' => $this->transform($joke) ], 200); }\n\nand our updated transform method with look like this:\n\nprivate function transform($joke){ return [ 'joke_id' => $joke['id'], 'joke' => $joke['body'], 'submitted_by' => $joke['user']['name'] ]; }\n\nSo, our updated show method code will look like this, here first we are joining User table data with the jokes tables, also we are finding the previous and next joke and then we are adding them to the response. So our response will now look like this:\n\nWhere submitted_by data is coming from users table after joining.\n\nImplement POST, PUT, DELETE requests\n\nOpen JokesController.php and update the store, update and destroy methods as follows:\n\nFirst add the following code at the top of the file,\n\nuse Illuminate\\Http\\Request;\n\nNow update the following methods:\n\npublic function store(Request $request) { if(! $request->body or ! $request->user_id){ return Response::json([ 'error' => [ 'message' => 'Please Provide Both body and user_id' ] ], 422); } $joke = Joke::create($request->all()); return Response::json([ 'message' => 'Joke Created Succesfully', 'data' => $this->transform($joke) ]); }\n\npublic function update(Request $request, $id) { if(! $request->body or ! $request->user_id){ return Response::json([ 'error' => [ 'message' => 'Please Provide Both body and user_id' ] ], 422); } $joke = Joke::find($id); $joke->body = $request->body; $joke->user_id = $request->user_id; $joke->save(); return Response::json([ 'message' => 'Joke Updated Succesfully' ]); }\n\npublic function destroy($id) { Joke::destroy($id); }\n\nTo test POST request, open postman and send post request as follows:\n\nSimilarly, you can test Update and Delete requests.\n\nPagination\n\nFor pagination, Laravel provides a very simple method called paginate(), let’s see how we can implement pagination. Open JokesController.php and update the index method as follows:\n\npublic function index(){ $jokes = Joke::with( array('User'=>function($query){ $query->select('id','name'); }) )->select('id', 'body', 'user_id')->paginate(5); return Response::json($this->transformCollection($jokes), 200); }\n\nNow access the route, you will see error something like this,\n\nThe problem is now we need to update the transformcollection method in the JokesController.php as:\n\nprivate function transformCollection($jokes){ $jokesArray = $jokes->toArray(); return [ 'total' => $jokesArray['total'], 'per_page' => intval($jokesArray['per_page']), 'current_page' => $jokesArray['current_page'], 'last_page' => $jokesArray['last_page'], 'next_page_url' => $jokesArray['next_page_url'], 'prev_page_url' => $jokesArray['prev_page_url'], 'from' => $jokesArray['from'], 'to' =>$jokesArray['to'], 'data' => array_map([$this, 'transform'], $jokesArray['data']) ]; }\n\nNow go to the route you will see the paginated result, like this.\n\nCurrently, we are hard coding the pagination to 5 elements but we can use query string to specify the no. of elements. The updated index method will look like this:\n\npublic function index(Request $request) { $limit = $request->input('limit')?$request->input('limit'):5; $jokes = Joke::with( array('User'=>function($query){ $query->select('id','name'); }) )->select('id', 'body', 'user_id')->paginate($limit); $jokes->appends(array( 'limit' => $limit )); return Response::json($this->transformCollection($jokes), 200); }\n\nHere we are checking to see, if the limit is present as query string, if yes use that value otherwise the no. of elements are default to 5.\n\nImplementing Search\n\nNow let’s implement the search functionality, update the index method as follows:\n\npublic function index(Request $request) { $search_term = $request->input('search'); $limit = $request->input('limit')?$request->input('limit'):5; if ($search_term) { $jokes = Joke::orderBy('id', 'DESC')->where('body', 'LIKE', \"%$search_term%\")->with( array('User'=>function($query){ $query->select('id','name'); }) )->select('id', 'body', 'user_id')->paginate($limit); $jokes->appends(array( 'search' => $search_term, 'limit' => $limit )); } else { $jokes = Joke::orderBy('id', 'DESC')->with( array('User'=>function($query){ $query->select('id','name'); }) )->select('id', 'body', 'user_id')->paginate($limit); $jokes->appends(array( 'limit' => $limit )); } return Response::json($this->transformCollection($jokes), 200); }\n\nNow you can test the search as follows:\n\nAdding JWT Auth\n\nNow we will add the security to the routes, such that only the authenticated users can request the data, otherwise they will get error.\n\nLet’s start with basic auth, that laravel provides by default, open the JokesController.php and add the contructor function as:\n\npublic function __construct(){ //$this->middleware('auth.basic', ['only' => 'store']); $this->middleware('auth.basic'); }\n\nThis means we are using basic auth on all routes. When we now try to view the route in the browser, we will first need to signin and then we see the data like.\n\nNow, if we type the correct credentials, only then we can see the data.\n\nBut we won’t be using this for our api, for api’s it is better to use token based authentication, which means whenever the user authenticates he will be provided with the token, and the user will then send this token with each request and if the token is valid, only then the data will be displayed.\n\nFor Token Based Auth, we will use a laravel package called jwt-auth ,\n\nFirst open the composer.json and add the following item to the required array,\n\n\"tymon/jwt-auth\": \"0.5.*\"\n\nNow run the following command:\n\ncomposer update\n\nIt will download the jwt-auth package.\n\nNow Open config/app.php file and add the following item to the providers array:\n\nTymon\\JWTAuth\\Providers\\JWTAuthServiceProvider::class\n\nAlso in the config/app.php, add the following items to the aliases array:\n\n'JWTAuth' => Tymon\\JWTAuth\\Facades\\JWTAuth::class, 'JWTFactory' => Tymon\\JWTAuth\\Facades\\JWTFactory::class\n\nNow publish this package from command line as:\n\nphp artisan vendor:publish --provider=\"Tymon\\JWTAuth\\Providers\\JWTAuthServiceProvider\"\n\nNow you will see a new file in the config folder called jwt.php, Now we need to generate jwt specific key from command line as:\n\nphp artisan jwt:generate\n\nNow you can see the key in the secret field changed to new key.\n\nNow open the routes.php and add the following routes:\n\nRoute::group(['prefix' => 'api/v1'], function() { Route::resource('authenticate', 'AuthenticateController', ['only' => ['index']]); Route::post('authenticate', 'AuthenticateController@authenticate'); Route::get('authenticate/user', 'AuthenticateController@getAuthenticatedUser'); });\n\nAdd the following middleware to the construct method in the JokesController.php:\n\npublic function __construct(){ $this->middleware('jwt.auth'); }\n\nNow we need to make the AuthenticateController from the command line as:\n\nphp artisan make:controller AuthenticateController\n\nNow open the AuthenticateController.php and update the file as follows:\n\n<?php namespace App\\Http\\Controllers; use Illuminate\\Http\\Request; use App\\Http\\Requests; use App\\Http\\Controllers\\Controller; use App\\User; use JWTAuth; use Tymon\\JWTAuth\\Exceptions\\JWTException; class AuthenticateController extends Controller { public function __construct() { $this->middleware('jwt.auth', ['except' => ['authenticate']]); } /** * Display a listing of the resource. * * @return \\Illuminate\\Http\\Response */ public function index() { return \"Auth index\"; } public function authenticate(Request $request) { $credentials = $request->only('email', 'password'); try { // verify the credentials and create a token for the user if (! $token = JWTAuth::attempt($credentials)) { return response()->json(['error' => 'invalid_credentials'], 401); } } catch (JWTException $e) { // something went wrong return response()->json(['error' => 'could_not_create_token'], 500); } // if no errors are encountered we can return a JWT return response()->json(compact('token')); } public function getAuthenticatedUser() { try { if (! $user = JWTAuth::parseToken()->authenticate()) { return response()->json(['user_not_found'], 404); } } catch (Tymon\\JWTAuth\\Exceptions\\TokenExpiredException $e) { return response()->json(['token_expired'], $e->getStatusCode()); } catch (Tymon\\JWTAuth\\Exceptions\\TokenInvalidException $e) { return response()->json(['token_invalid'], $e->getStatusCode()); } catch (Tymon\\JWTAuth\\Exceptions\\JWTException $e) { return response()->json(['token_absent'], $e->getStatusCode()); } // the token is valid and we have found the user via the sub claim return response()->json(compact('user')); } }\n\nNow try to hit the route, /api/v1/jokes, you will get an error token not provided like this:\n\nWhich means, we first need to generate token that we can generate by sending post request to api/v1/authenticate with email and password as following:\n\nNow you can send the requests with this token and then you will get the result as expected.\n\nTackling CORS\n\nNow our api is working fine, but there is last thing to take care of, now let’s say if we put this api online, no one will be able to access the api due to cross domain restrictions. So to overcome this we can install a Laravel package called laravel-cors.\n\nFirst install the package using composer:\n\ncomposer require barryvdh/laravel-cors 0.7.x\n\nNow add this package to config/app.php file’s providers array as:\n\nBarryvdh\\Cors\\ServiceProvider::class\n\nNow to use this package, open the routes file and update the routes as follows:\n\nRoute::group(['middleware' => 'cors', 'prefix' => 'api/v1'], function() { Route::resource('authenticate', 'AuthenticateController', ['only' => ['index']]); Route::post('authenticate', 'AuthenticateController@authenticate'); Route::get('authenticate/user', 'AuthenticateController@getAuthenticatedUser'); }); Route::group(['middleware' => 'cors', 'prefix' => 'api/v1'], function(){ Route::resource('jokes', 'JokesController'); });\n\nWrapping Up Part 1\n\nHopefully this tutorial was helpful and you have created your first API by the end of it.\n\nFeel free to leave any feedback or questions in the comments below and let me know if there’s anything you need help with or if I can clarify anything.\n\nThanks @jeffrey_way (laracasts) for his awesome screencasts, learned lot from him & jwt-auth inspiration by @ryanchenkie.\n\nSee Part 2 of this series, where we will create an app with AngularJS using this API.\n\nThanks."
Release Date: July 24, 2015 Rated: R Synopsis: Billy “The Great” Hope is the reigning Junior Middleweight Champion whose unorthodox stance, the so-called “Southpaw,” consists of an ineloquent, though brutal, display of offensive fighting…one fueled by his own feelings of inadequacy and a desperate need for love, m...
The time has come for us to officially announce the Immutant project. Immutant is going to be for Clojure what TorqueBox is for Ruby: a true, enterprise-grade application server, encapsulating the robust services provided by JBoss AS7 within intuitive Clojure API's. Further, Immutant has inspired us to attempt to achi...
Train with Diesel locomotive No 32042 from Transnet The Outeniqua Choo Tjoe was the last remaining continually-operated passenger steam train in Africa, ending operation in June 2009. The railway was completed in 1928, and links the towns of George and Knysna in the Western Cape, South Africa. The scenic 67-kilometre ...
By By Karen Graham Jan 16, 2015 in Crime Charleston - Call it what you will, but a chemical company has succeeded in pulling a fast one on West Virginians. After Freedom Industries poisoned 300,000 peoples drinking water last year, the company changed names and is still up to its old tricks. Many people assumed this wa...
Undercover video shot by Al Jazeera reveals the lengths to which some leaders of the UK’s influential pro-Israel networks will go to discredit their critics. Part three of The Lobby, broadcast on Friday night, shows the chairperson of Labour Friends of Israel falsely claiming a Palestine Solidarity Campaign supporter ...
A report by the Association for Democratic Reforms shows that more than 23 percent of each one’s declared income remained unspent An analysis of the income and expenditure of the BJP and Congress in 2015-16 has been prepared by the Association for Democratic Reforms (ADR). report: Following are the key points from th...
Women from Britain, Australia and Malaysia have reportedly travelled to Iraq and Syria to serve as 'comfort women' for Isis militants, a phenomenon which has become known as "sexual jihad." Intelligence authorities in Kuala Lumpur have confirmed that at least three Malaysian females have travelled to the Islamic State...
My name is Darth Fare Evader and I’m a scofflaw. Yup, I frequently use the TTC and hardly ever pay. How? Well that’ll stay my secret for the time being. Do I feel guilty about it? Not really. Here’s the thing. My income does not meet the minimum poverty level. So without regular, full-time employment I just can’t aff...
A man is being treated in isolation in Hawaii for what health officials say is a potential Ebola case, local ABC affiliate KITV reported Thursday, though he could be sick with some other ailment. Authorities stress that they are being especially cautious amid concerns over the deadly virus, two days after the first co...
How YouTrack Personal Agile Board Helped Me to Be Better Organized Andrey Cheptsov Blocked Unblock Follow Following Sep 21, 2016 Disclaimer: I work for JetBrains as a Product Marketing Manager for IntelliJ IDEA, but this article isn’t about selling you YouTrack. Granted, at JetBrains, we’re all using it for our daily...
Establishing the BRICS Bank is a momentous event The July 2014 BRICS (Brazil, Russia, India, China, South Africa) Summit was a momentous event, more important than the World Cup that also took place in Brazil. The BRICS sealed the deal towards the creation of the BRICS development bank and a US$ 100 billion reserve fu...
LinkedIn reported Q2 2014 financial results, beating analysts’ expectations for EPS and revenues, sending the stock price to an 11.7% increase a day after the earnings release. LinkedIn presented weak progress in its international revenues with 60% of revenues originating in the US. LinkedIn made a few steps into Chi...
Erin Andrews is trying to sell me probiotics.1 She is walking through a bustling gym wearing a sharp blazer and a fresh blow out. Male patrons gawk. She bubbles that the euphoric powers of probiotics can improve digestion and immunity. She takes probiotics, and she has grown tall, healthy, and has a sweet gig interview...
CAPTAIN AMERICA: CIVIL WAR New TV spot for CAPTAIN AMERICA – CIVIL WAR: The VFX are made by: Industrial Light & Magic (VFX Supervisor : Russell Earl) Method Studios Rise FX Trixter Double Negative Luma Pictures Lola VFX Cantina Creative Animal Logic The Third Floor The Production VFX Supervisor is Dan DeLeeuw Directors...
The Avalanches’ second album Wildflower has been a long time coming. Since its announcement earlier this year, we’ve heard “Colours” featuring Mercury Rev’s Jonathan Donahue and “Frankie Sinatra” featuring Danny Brown and MF DOOM. Before all that, they teased their new song “Subways” and recently released the full vers...
Ritual Magic, Mind Control and the UFO Phenomenon Part 1 It was not long after my own encounter with strange aerial phenomenon that I began to see a link between UFOs to such seemingly disparate topics as psychedelics, psychotronics, and ritual magick. As the years pass, the Extraterrestrial Hypothesis (ETH) makes fa...
Damian Prince, a 5-star offensive tackle in the class of 2014, is a big guy at 6'6" and 300 pounds, but that doesn't make him immune to death threats. As is too often the case in recruiting, Prince revealed that he has received death threats, according to a feature by Brandon Parker of the Washington Post. Prince disc...
By Chris Wright They said it may happen, then they said it probably wouldn’t happen, and now it’s bloody well happening – as of next season, Cardiff City (The Bluebirds) will be playing in a more dragon-y shade of red on the whim of their Malaysian owners, with their away strip reverting to blue and yellow… Said Card...
CLIFTON, N.J. (CBSNewYork) – A massive police presence at a group of stores in Clifton, New Jersey, Saturday night was sparked by a hoax call, authorities confirmed to CBS2. The Passaic County Sheriff’s Office said the call of a hostage scare they received around 8 p.m. was a case of “swatting.” As CBS2’s Valerie Cas...
Former House Majority Leader Tom Delay called Sen. Jim Bunning (R-Ky.) "brave" on Sunday for launching a one-man filibuster of unemployment benefits, arguing that they dissuaded people from going out and finding work. Appearing on CNN's "State of the Union," the Texas Republican said that Bunning's fiscal responsibili...
BY: Follow @DavidRutz House Minority Leader Nancy Pelosi (D., Calif.) said Thursday at her weekly briefing that she has "confidence" in President Obama's belief that the Islamic State terrorist group was "contained." Obama remarked that the terror group was contained in an interview last week with ABC, but those rema...
DENVER -- Only one Cincinnati brewery will be taking home hardware from the Great American Beer Festival this year. However, breweries from Ohio and Indiana made a strong showing at the big event in the Mile High City this year. Over-the-Rhine-based Rhinegeist Brewing won silver in the Wood- and Barrel-Aged Strong St...
Multisystem Trojan Janicab attacks Windows and MacOSX via scripts On Friday, July 12th a warning from an AVAST fan about a new polymorphic multisystem threat came to an inbox of AVAST. Moreover, an archive of malicious files discussed here were attached. Some of them have been uploaded to Virustotal and therefore they...
My dear son, I am appalled, even horrified, that you have adopted Classics as a major. As a matter of fact, I almost puked on the way home today. I suppose that I am old-fashioned enough to believe that the purpose of an education is to enable one to develop a community of interest with his fellow men, to learn to kno...
Spain's Ministry of Culture has just reported on the first month's activities following the introduction of the country's 'Sinde' anti-piracy law. The controversial legislation, described by some as a Spanish version of SOPA, took effect March 1st and since that time rightsholders have been busy filing notices. Almost ...
Andrew McCabe, James Comey, Rod Rosenstein—again and again, Trump and his aides have misrepresented and abused, if not fabricated, statements from trusted officials. Photo illustration by Slate. Photos by Alex Wong/Getty Images, Aaron P. Bernstein/Reuters, James Lawler Duggan/Reuters, and Kevin Lamarque/File Photo/Reut...
Check out MaximMart Textile Products Best Selling Items Page ! Here you will find all of the products being most commonly used in the microfiber industry. These items are sure to satisfy the needs of your home or business. All of MaximMart’s products are of the highest quality and have excellent reviews ! MaximMart Mi...
The Minor League season begins today, with 59 games scheduled to be played across the four full-season levels. Of course there's talent spread throughout the Minor Leagues, but certain teams stand out more than others. With that in mind, MLBPipeline.com has compiled a ranking of the Top 10 Minor League teams for fans ...
A Founders Brewing Co. dark beer on the taproom bar. Photo taken Wednesday, October 3, 2012. (Chris Clark | MLive.com) (Chris Clark | MLive) KALAMAZOO, MI – Bell's Brewery Inc. and Founders Brewing Co. continue to mash out competitors in national ranking lists. Both breweries were named among The Daily Meal's Top 15...
EU ambassadors on Wednesday (7 September) decided to extend the life of a blacklist that designates top Russian officials on grounds of “actions against Ukraine's territorial integrity”. The list, which expires on 15 September, is to stay in place until 15 March next year, with EU capitals to ratify the decision by wr...
Fundamentalist Church of Jesus Christ of Latter-Day Saints President Warren Jeffs, along with other officials in the church and its former land trust, is accused of carrying out a “calculated plan” to sexually abuse underage girls as part of a religious ritual, according to a lawsuit filed Wednesday. The lawsuit also ...
Years ago, I brought a new boyfriend to Christmas dinner. “Is this the same boy as last time?” My uncle asked. That was bad enough, but when I told him no, he followed up with, “Every year, different boy.” Merry Christmas! If your family is anything like mine, they like to ask painfully awkward questions, and this can ...
Like the iPhone 5 before it, the unannounced iPad Mini has—through leaks and logic—made itself essentially a known quantity. Let's assume for a second that we know what it looks like, how big it is, and what guts will power it. It's a safe assumption. Advertisement With just a few weeks until a rumored launch, we hav...
When will the gunhuggers and ammosexuals get that guns give you the foolish illusion of safety -- and invincibility? Personally, I'll take my chances with an aluminum baseball bat! (H/t Brendan Squire.) [Philadelphia] police are asking for the public's help tracking down the second suspect responsible for robbing gun ...
Queens Park Rangers have sent the Football League their accounts for 2013-14, the period covered by new financial fair play rules expected to result in the club being hit with a multimillion-pound fine. QPR and the league confirmed that the accounts were sent on time on 1 December but neither would discuss the financia...
The manager of a Domino’s Pizza in Lake City, Fla., torched a Papa John’s Pizza down the street because he hoped his boss would give him a bonus if business increased, police said. The heated rivalry burst into flames on Oct. 20, when an arson attack caused about $500,000 in damages to Papa John’s, said Capt. John Bla...
September 2010 The Obama Administration has further weakened already inadequate immigration enforcement in the interior of the country. This may be seen in four developments undertaken by agencies of the Department of Homeland Security (DHS). First, DHS announced that it was revising 287(g) agreements with state and ...
Malka Leifer: Former Melbourne Jewish school principal wins further delay in fight against extradition from Israel on abuse allegations Updated A former principal accused of molesting students at an ultra-Orthodox Jewish school in Melbourne has had her extradition hearing to Australia delayed. Malka Leifer fled to I...
"We... just discovered some tapes from the previous Freddy Fazbear's Pizza location." Scott nervously tells me. What a way to begin my final day. People could have found me out. Found out what I did. "The... police are doing an investigation. This place'll close really soon." "Really? Why's that? ...What was in thes...
My boyfriend told me that I should watch an anime called Girl’s Monthly Nozaki-Kun. It’s a comedy and it made me cry these ugly wracking sobs and he had to call me so I could stop and go to sleep. In the end Nozaki-kun is a young woman’s story about unrequited love, about a man who hurts her not because he wants to but...
Like Alice down the rabbit hole, the heroes of Disney's double bill take tumbles down long, strange tunnels and emerge in fantastic worlds. "Runaway Brain," a new seven-minute Mickey Mouse cartoon, begins with the familiar, brightly colored Mickey in up-to-the-minute surroundings. As Pluto looks on, he plays a "Snow Wh...
Share Roadside breathalyzers, used for estimating blood alcohol content, have been used by law enforcement as far back as the 1930s. However, to date there is still no equally fast-acting, accurate roadside equivalent that cops can use if they suspect someone of driving under the influence of marijuana. That could be...
The main idea is to keep the board clear with the arms dealer and mizzium mortars, while building up goblins (and maybe a krenko) and knock down the opponents life total with the instants and sorceries in combination with guttersnipe. If the board is clear then trumpet blast but if not, searing spear (perhaps even reve...
Cramer on WFC: What you want to know as an investor 4:10 PM ET Wed, 14 Sept 2016 | 04:47 Federal prosecutors are investigating Wells Fargo, after the bank was fined for opening unauthorized accounts, The Wall Street Journal reported, citing sources. The Journal said that the investigation is in its early stages and t...
Looks like the US Air Force will have the F-16 Falcon in its arsenal for decades to come. Today it was announced that the Air Force has commissioned Lockheed Martin to extend the overall flight hours of the F-16 from 8,000 to 12,000. This decision will ensure the the aircraft will remain active for many more years. In...
ROGERS PARK — Come Tuesday, North Side Beer-lovers will have another place to imbibe on locally-made pints with the opening of Empirical Brewery's new Rogers Park brewpub. The Ravenswood-based beer company replaces the former Act One Pub inside the Mayne Stage at 1330 W. Morse Ave. and after a soft opening this week w...
When Tanvir Sarao arrived at school the morning of Feb. 14, the 10-year-old boy saw smoke coming from a house opposite the school’s yard. That morning, a Brampton house fire left three dead: Iftekhar Niazi and his wife Jyoti Kapadia and their 19-year-old daughter Amina Kapadia. Iqvinder Lally, Yasmeen Bajwa, Gurleen J...
Early on the afternoon of April 1, Adam Wilson posted a message to Twitter. But instead of using his hands to type, the University of Wisconsin biomedical engineer used his brain. "USING EEG TO SEND TWEET," he thought. That message may be a modern equivalent of Alexander Graham Bell's "Mr. Watson, come here. I want to...
The staff of the Ghost in the Shell Arise anime announced the details of its project on Tuesday. The project will consist of four 50-minute parts. The first part, "Ghost Pain," will run in Japanese theaters for two weeks starting on Saturday, June 22. There will be advance Blu-ray Disc copies with a bundled scenario b...
Evelyn could recall the day she had first seen those bright green eyes. They had been frustrated, desperate, scared even in that moment, as the man they belonged to struggled against the two hefty persons dragging him away from an angry crowd, accusations of thievery ringing through the air. There was little he could d...
by Delhi. On Wednesday, April 24, a day after Bangladeshi authorities asked the owners to evacuate their garment factory that employed almost three thousand workers, the building collapsed. The building, Rana Plaza, located in the Dhaka suburb of Savar, produced garments for the commodity chain that stretches from th...
KMO and Olga continue the conversation with Jay Smith and . This week the topic moves from race in the Peak Oil narrative to the prospects for atheistic rational materialism in a post-petroleum milieu. The same fossil fuel windfall that has allowed industry to replace the work of human and animal muscles with machines ...
The rest of us don't get to see much .750 baseball, unless some team starts the season 3-1. In the modern era, only one club has finished the season with a winning percentage higher than .750. Irony alert: That was the 1906 Chicago Cubs. ST. LOUIS -- After one month of the season, the St. Louis Cardinals are playing ....
Playing in Gus Malzahn’s spread offense at Auburn, Uzomah was not a conventional tight end. But at 6’5”, 264 pounds with 4.6 speed in the 40-yard dash, the 22-year-old from Georgia has the prototypical size and speed to play the position in the NFL. “We think his strength is his versatility,” said tight ends coach Jon...
At a whopping 2.13m Dean Williams may just be the world's tallest rugby player. At an impressive 2.13 metres (7 foot in the old money), Dean Williams could be the largest man in rugby – anywhere. And the ex-pat Brit is putting his considerable size to good use as a premiere-grade lock with the west Auckland-based Sub...
Canada’s highest court has given developers the green light to build a 6,250-bed ski resort on land considered sacred by an indigenous community in British Columbia, in a landmark court case that pitted religious rights against the controversial project. The case centred around a proposal for a year-round ski resort o...
Being a part of video game culture can be a frustrating exercise. That culture is defined primarily by the magazines, websites, television programs and social events aimed at “gamers,” but even the term "gamer" can be exclusionary; many members of the video game audience reject the notion that people who only play vide...
NEW YORK — A film created with help from a former Lynyrd Skynyrd drummer violates a "blood oath" surviving band members made not to exploit the band’s name and history, a judge concluded as he blocked its distribution, siding with a surviving member of the 1970s pioneering southern rock group and the widow of its lead ...
The other day, a customer eating lunch from the Halal Guys offered his opinion on the news. Anthony Greco, 26, who works in finance, was sitting on a sun-baked granite bench near the Museum of Modern Art devouring a platter. He said he had “no doubt” the franchise would be successful. “I think it is a staple of New Yor...
, who is now just 152 days away from (as he declares so ), will be doing an impromptu show in Nashville tomorrow night, at a record store owned by Detroit rocker . The comedian and late night talk show host will perform at White's store on June 10 at 8 p.m. This afternoon : Jack White & I are doing something co...
Linux-powered IoT gateways offer LTE and Wirepas Mesh SolidRun has launched a Linux-driven line of i.MX6-based “SolidSense N6 Edge Gateways” available in indoor, outdoor, and industrial models with WiFi, BT, BLE, LTE, GPS, and Wirepas Mesh support. SolidRun has introduced the first in a line of SolidSense Edge Gateways...
Commenter Burninator discovered that you don't even need the .desktop ending in the attachment. The Gnome and KDE desktops actually read the file, and don't base their decision to special-case the file on the file-name extension! So, the critical meta data here (make this something that can be executed) is NOT encoded ...
Loading... Better late than never. Now even liberal fruitcake Michael Moore has had enough of Sweden's neglect of rapes and its unwillingness to strike hard on rapists. In an open letter to the Swedish government, published in the liberal news outlet Huffington Post , he addresses the problem:"Dear Swedish Government:...
The typically uneventful walk home from school took a terrifying turn for two brothers in east Scarborough on Thursday after they became the unwitting victims of an armed police take-down. Devonte Miller Blake, 15, and his 10-year-old brother, Kishwayne McCalla, were surrounded by up to seven officers pointing guns as...
MOBILE, Ala. -- Some team is going to select South Alabama's Gerald Everett in the NFL Draft. In all likelihood, it's going to be in the first round. And if the big tight end has his way, he'll be making his way to East Rutherford. "I'm going to be happy with any team that takes me," Everett told NJ Advance Media at ...
News NYSE Owner Admits ‘We May Be Stupid’ for Not Being First on Bitcoin Futures Jeff Sprecher, CEO of Intercontinental Exchange Inc. and owner of the NYSE seems to be having second thoughts about letting his competitors launch Bitcoin futures trading first. It is by now very well known that Bitcoin futures trading i...
Image copyright Ariel Gonzalez Image caption A Galaxy Note 7 reportedly caught fire shortly after its charger was unplugged Samsung has urged owners of its Galaxy Note 7 phones to stop using or exchange the devices as they risk exploding. Samsung recalled 2.5 million phones last week after reports emerged of the devi...
Democratic Senate nominee Doug Jones talked to supporters Jennifer L. Greer (right) and Janet Crosby (left) as he campaigns at Niki's West restaurant Wednesday in Birmingham, Ala. BIRMINGHAM, Ala. — Doug Jones already has a place in Alabama’s layered and, at times, traumatic history. His name appears in the Birmingham...
Canon ODF-1 This page is part of the vintage Canon collection I maintain at canonfd.org Serial: 577843 This olive drab (OD) Canon F-1 was made available for a limited run of somewhere between 2000 and 3000 bodies. I contacted Canon Japan and they claimed that these were made available starting January of 1978 for 10...
In this undated photo provided by the Catholic Diocese of Wichita, Father Emil Kapaun holds out a broken pipe. (Photo11: AP/Catholic Diocese of Wichita) Story Highlights Chaplain was well-awarded but never received Medal of Honor A group is pushing to canonize him Chaplain was known for generosity, bravery, and smoki...
Libertarian presidential candidate Gary Johnson has filed a lawsuit against the Commission on Presidential Debates on the grounds that the commission is violating the Sherman Anti-Trust Act. The Commission on Presidential Debates (CPD) has formally invited only Mitt Romney and Barack Obama to the debates while excludi...
Joe Lauzon is as straightforward as they come in the fight game and he has zero issue with that being the case. There's always so much more going on than what Lauzon allows anyone to see, and his ability to change pace and throw a loop is what has made him the undeniable bonus king of the UFC.The Massachusetts native's...
An online rumor circulating since January 2007 alleges that Barack Obama is secretly a Muslim and has lied to the American people about his religious affiliation, including his statement that he's been a devout Christian for most of his adult life. However, the evidence indicates this is false. Analysis of Whether Bar...
The Kataas-taasan, Kagalang-galang, Katipunan ng mga Anak ng Bayan[1] ("Supreme and Venerable Society of the Children of the Nation", Spanish: Suprema y Venerable Asociación de los Hijos del Pueblo), also known as Katipunan or KKK,[5] was a Philippine revolutionary society founded by anti-Spanish colonialism Filipinos ...
I am getting a bad request from the api call i'm making and i have no idea why, been searching around for a long time now. the response i get from the call is : {"error":"invalid_request","error_description":"Missing input parameters"} So i'll list my code below, first my html form: <ion-view view-title="Login" id="...
Tuesday Bassen, a 27-year-old illustrator from Los Angeles, has accused the Spanish clothing and accessories retailer Zara of "stealing" designs that also appear on Bassen's store ShopTuesday Bassen told BuzzFeed News she was initially made aware of the fact Zara's designs were similar to the ones she had created for ...
Exclusive: Conservative group offers to sell endorsement for $2M The American Conservative Union asked FedEx for a check for $2 million to $3 million in return for the group’s endorsement in a bitter legislative dispute, then flipped and sided with UPS after FedEx refused to pay. For the $2 million+, ACU offered a ra...
In the wake of the Dallas sniper attack that killed five police officers, police departments in the Bay Area and beyond are on heightened alert, pairing up officers as a safety measure and revisiting the stark realities of their duties. The moves come as tensions between law enforcement and communities of color were a...