Laravel change migration order

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

Save vs update in laravel

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

Laravel Eloquent Relations: ->latest()

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.

Laravel Passport VS JWT

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

Laravel 5: Retrieve JSON array from $request

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

How to stop Laravel 5 from caching configurations?

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

Laravel 5 Unable to detect application namespace

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

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)