This will make your Laravel instance available on the web. Make sure your router have port 80 forwarded to your machine. Also make sure no other server applications is blocking the port.
php artisan serve --host 0.0.0.0 --port 80
BashThis will make your Laravel instance available on the web. Make sure your router have port 80 forwarded to your machine. Also make sure no other server applications is blocking the port.
php artisan serve --host 0.0.0.0 --port 80
Bashusort($myArray, function ($a, $b) {
return strcmp($a->myPropery, $b->myPropery);
});
PHPSort by predefined order:
$predefinedOrder = [1, 5, 2, 6];
usort($arrayOfObjects, function ($a, $b) use ($predefinedOrder) {
$flipped = array_flip($predefinedOrder);
$left = $flipped[$a->myPropery];
$right = $flipped[$b->myPropery];
return $left >= $right;
});
PHPCreate migration in console:
php artisan make:migration add_mycolumn_to_mytable
BashUse Schema::table() to access existing table (instead of Schema::create() for creating new tables)
public function up()
{
Schema::table('mytable', function($table) {
$table->text('mycolumn');
});
}
public function down()
{
Schema::table('mytable', function($table) {
$table->dropColumn('mycolumn');
});
}
PHPThen run migrations:
php artisan migrate
BashIf you have problems with Composer not allowing to update to http-connections add this to composer.json (not recommended to keep in production)
config : {
"secure-http" : false
}
JSONI had a custom post type that only used custom fields, so I needed to generate a post title from there.
Here’s one way. You can if course chain as many if else as you want to check other types.
functions.php
[php]
function custom_post_type_title($post_id)
{
global $wpdb;
if (get_post_type($post_id) == ‘staff’) {
$name = get_post_custom_values(‘name’);
$title = $name[0];
$where = array(‘ID’ => $post_id);
$wpdb->update($wpdb->posts, array(‘post_title’ => $title), $where);
}
}
add_action(‘save_post’, ‘custom_post_type_title’);
[/php]
Generate Seed from Database
https://github.com/orangehill/iseed
Generate Migrations from Database:
https://github.com/Xethron/migrations-generator
Replaces newline characters with <br> tags in the same style as the php nl2br function
// newline to br - php style
function nl2br(str, is_xhtml) {
let breakTag = (is_xhtml || typeof is_xhtml === 'undefined') ? '<br />' : '<br>';
return (str + '').replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, '$1' + breakTag + '$2');
}
JavaScriptCreate new Ruby-on-Rails project. By default RoR comes with SQLite support, unless you state otherwise (-d mysql).
[ruby]
// Create project. With mysql support
rails new my_project -d mysql
[/ruby]
[sql]
— Replace a word or string in a column
UPDATE my_table SET my_column = REPLACE(my_column, ‘Old string’, ‘New string’);
—
[/sql]