CRUD = Create, Read, Update, Delete
$host = '127.0.0.1';
$dbname = 'test';
$username = 'root';
public function BannersActive() | |
{ | |
return $this->hasMany('App\Ad') | |
->where('user_id', $this->id) | |
->where('status', 1) | |
->get(); | |
} |
//promise in a variable | |
let promise = new Promise(function(resolve, reject) { | |
setTimeout(() => resolve("done!"), 1000); | |
}); | |
// resolve runs the first function in .then | |
promise.then( | |
result => console.log(result), // shows "done!" after 1 second | |
); | |
promise.catch( |
<label for="addressCountry">Country</label> | |
<select name="addressCountry"> | |
<option></option> | |
<optgroup label="North America"> | |
<option value="US">United States</option> | |
<option value="UM">United States Minor Outlying Islands</option> | |
<option value="CA">Canada</option> | |
<option value="MX">Mexico</option> | |
<option value="AI">Anguilla</option> | |
<option value="AG">Antigua and Barbuda</option> |
<div class="alert"> | |
{{ $slot }} | |
</div> |
# Usage: git total [OPTION...] | |
# | |
# Options: | |
# | |
# In theory, the command accepts all command line options supported by | |
# the "git log" command. In reality, however, only few commit-limiting | |
# options are useful. This includes: | |
# | |
# --author=PATTERN, --committer=PATTERN | |
# Displays the number of lines changed by a certain author. |
Table of Contents generated with DocToc
// ๐ฅ Node 7.6 has async/await! Here is a quick run down on how async/await works | |
const axios = require('axios'); // promised based requests - like fetch() | |
function getCoffee() { | |
return new Promise(resolve => { | |
setTimeout(() => resolve('โ'), 2000); // it takes 2 seconds to make coffee | |
}); | |
} |
var groupBy = function(xs, key) { | |
return xs.reduce(function(rv, x) { | |
(rv[x[key]] = rv[x[key]] || []).push(x); | |
return rv; | |
}, {}); | |
}; | |
console.log(groupBy(['one', 'two', 'three'], 'length')); |
let sum = course.lessons | |
.map(l => l.contents) | |
.reduce((acc, val) => acc.concat(val), []) | |
.reduce((acc, val) => { | |
return acc + val.length | |
}, 0) |