How to drop table in Laravel?
To drop a table, you may use the Schema::drop method: Schema::drop(‘users’); // Better Schema::dropIfExists(‘users’);
To drop a table, you may use the Schema::drop method: Schema::drop(‘users’); // Better Schema::dropIfExists(‘users’);
Roll back all the migrations (or start with a fresh database); Change the dates that form the first part of the migration filenames so they’re in the order you want (eg. for 2014_06_24_134109_update_database.php, the date & time is 2014-06-24, 13:41:09); Run the migrations again. With respect to your comment about foreign keys… I’m not sure … Read more
These methods both allow you to save data to a database. The save() method performs an INSERT when you create a new model which is currently is not present in your database table: $flight = new Flight; $flight->name = $request->name; $flight->save(); // it will INSERT a new record Also it can act like an UPDATE, … Read more
latest() is a function defined in Illuminate\Database\Query\Builder Class. It’s job is very simple. This is how it is defined. public function latest($column = ‘created_at’) { return $this->orderBy($column, ‘desc’); } So, It will just orderBy with the column you provide in descending order with the default column will be created_at.
I’m assuming you added $this->middleware(‘auth’); inside the constructor of your controller to get the authentication working. In your login/register forms, if you are using {!! Form::someElement !!}, add the following line at the top as well: {!! csrf_field() !!} Or if you are using input tags inside your forms, just add the following line after … Read more
The “tymondesigns/jwt-auth” is a PHP Laravel implementation of the JWT protocol. On the other hand, Passport also uses JWT by default plus a huge extra, a complete Oauth2 implementation. Regarding the functionality, as I said they both use JWT thus you can use whichever you like to authentication via tokens. They both do their job … Read more
You need to change your Ajax call to $.ajax({ type: “POST”, url: “/people”, data: ‘[{ “name”: “John”, “location”: “Boston” }, { “name”: “Dave”, “location”: “Lancaster” }]’, contentType: “json”, processData: false, success:function(data) { $(‘#save_message’).html(data.message); } }); change the dataType to contentType and add the processData option. To retrieve the JSON payload from your controller, use: dd(json_decode($request->getContent(), … Read more
Make use of randomElement method ‘type’ => $faker->randomElement([‘seller’, ‘buyer’]),
You can’t stop the caching of config files since it doesn’t happen automatically. The only thing you need to do, is not call config:cache. The file itself can be found in bootstrap/cache/config.php. Note that the location of the compiled config file has changed recently. Yours might also be in vendor/config.php or storage/framework/config.php. With a fresh … Read more
Okay, I solved it. What I did to solve this: composer update gave me following error: [Seld\JsonLint\ParsingException] “./composer.json” does not contain valid JSON Parse error on line 9: “require-dev ———————^ Expected: ‘STRING’ – It appears you have an extra trailing comma I opened composer.json and there was one extra comma in last line: “require”: { … Read more