Signup/Sign In

Answers

All questions must be answered. Here are the Answers given by this user in the Forum.

Please use

***{!! $test !!} ***
Only in case of HTML while if you want to render data, sting etc. use

***{{ $test }}***
This is because when your blade file is compiled

**{{ $test }}** is converted to **** while

**{!! $test !!}** is converted to ****
3 years ago
If the table has an auto-incrementing id, use the insertGetId method to insert a record and then retrieve the ID:

***$id = DB::table('users')->insertGetId([
'email' => 'john@example.com',
'votes' => 0
]);***
3 years ago
If you look in your migrations table, then you’ll see each migration has a batch number. So when you roll back, it rolls back each migration that was part of the last batch.

If you only want to roll back the very last migration, then just increment the batch number by one. Then next time you run the rollback command, it’ll only roll back that one migration as it’s in a “batch” of its own.

Alternatively, from Laravel 5.3 onwards, you can just run:

***php artisan migrate:rollback --step=1***
That will rollback the last migration, no matter what its batch number is.
3 years ago
You can add new columns within the initial Schema::create method like this:

***Schema::create('users', function($table) {
$table->integer("paied");
$table->string("title");
$table->text("description");
$table->timestamps();
});***
If you have already created a table you can add additional columns to that table by creating a new migration and using the Schema::table method:

***Schema::table('users', function($table) {
$table->string("title");
$table->text("description");
$table->timestamps();
});***
The documentation is fairly thorough about this, and hasn't changed too much from version 3 to version 4.
3 years ago
I manged to do this by adding a view bag parameter in asp.net mvc. Here what have i done

Added ViewBag.Current = "Scheduler"; like parameter in each page

In layout page

******
This solved my problem.
3 years ago
You might want to create a web service for your common methods.
Just add a WebMethodAttribute over the functions you want to call, and that's about it.
Having a web service with all your common stuff also makes the system easier to maintain.
3 years ago
If you are only interested to return xml through a request, and you have your xml "chunk", you can just do (as an action in your controller):

***public string Xml()
{
Response.ContentType = "text/xml";
return yourXmlChunk;
}***
3 years ago
I received this error because I used the incredibly broken NuGet Package Manager in Visual Studio 2015 to update my project.json dependencies. It turned this:

***"frameworks": {
"netcoreapp1.0": {
"dependencies": {
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.0.1"
}
}
}
}***
into this:

***"dependencies": {
"Microsoft.NETCore.App": "1.1.0"
},
"frameworks": {
"netcoreapp1.0": {}
}***
Bye bye, platform definition!
3 years ago
With ES2015 support it can be done by:

***foo.sort((a, b) => a.updated_at < b.updated_at ? -1 : 1)***
3 years ago
When I want to tidy up an array like this I use:

***["Kathmandu", "Pokhara", "", "Dharan", "Butwal"] - ["", nil]***
This will remove all blank or nil elements.
3 years ago
You could write an extension method:

***public static T[] Concat(this T[] x, T[] y)
{
if (x == null) throw new ArgumentNullException("x");
if (y == null) throw new ArgumentNullException("y");
int oldLen = x.Length;
Array.Resize(ref x, x.Length + y.Length);
Array.Copy(y, 0, x, oldLen, y.Length);
return x;
}***

Then:
***int[] x = {1,2,3}, y = {4,5};
int[] z = x.Concat(y); // {1,2,3,4,5}***
3 years ago
As of PHP 5.3 the shortest solution seems to be array_walk_recursive() with the new closures syntax:

***function flatten(array $array) {
$return = array();
array_walk_recursive($array, function($a) use (&$return) { $return[] = $a; });
return $return;
}***
3 years ago