Laravel - Eloquent - query many to many relationship
Example:
Table 1: posts
Table 2: categories
Pivot Table: category_post with foreign keys category_id, post_id
| 'use strict'; | |
| // simple express server | |
| var express = require('express'); | |
| var app = express(); | |
| var router = express.Router(); | |
| app.use(express.static('public')); | |
| app.get('/', function(req, res) { | |
| res.sendfile('./public/index.html'); |
| var defaults = { | |
| number: 1, | |
| bool: true, | |
| magic: 'real', | |
| animal: 'whale', | |
| croutons: 'delicious' | |
| }; | |
| var options = { | |
| number: 2, |
| // It is important to declare your variables. | |
| (function() { | |
| var foo = 'Hello, world!'; | |
| print(foo); //=> Hello, world! | |
| })(); | |
| // Because if you don't, the become global variables. | |
| (function() { |
Laravel - Eloquent - query many to many relationship
Example:
Table 1: posts
Table 2: categories
Pivot Table: category_post with foreign keys category_id, post_id
Install git:
sudo apt-get install git
Configure Git:
touch ~/.gitignore_global
git config --global core.excludesfile ~/.gitignore_global
git config --global user.name "Your Name"
git config --global user.email "Your Email"
#Laravel 5 Simple ACL manager
Protect your routes with user roles. Simply add a 'role_id' to the User model, install the roles table and seed if you need some example roles to get going.
If the user has a 'Root' role, then they can perform any actions.
Simply copy the files across into the appropriate directories, and register the middleware in App\Http\Kernel.php
| /** | |
| * Description: | |
| * removes white space from text. useful for html values that cannot have spaces | |
| * Usage: | |
| * {{some_text | nospace}} | |
| */ | |
| app.filter('nospace', function () { | |
| return function (value) { | |
| return (!value) ? '' : value.replace(/ /g, ''); |
| Function.prototype.compose = function(argFunction) { | |
| var invokingFunction = this; | |
| return function() { | |
| return invokingFunction.call(this, argFunction.apply(this,arguments)); | |
| } | |
| } |
| $(window).on("scroll", function() { | |
| var scrollHeight = $(document).height(); | |
| var scrollPosition = $(window).height() + $(window).scrollTop(); | |
| if ((scrollHeight - scrollPosition) / scrollHeight === 0) { | |
| // when scroll to bottom of the page | |
| } | |
| }); |
| =======[ Media Queries - default media query break points ]======= | |
| @media(max-width:767px) { | |
| } | |
| @media(min-width:768px) { | |
| } | |
| @media(min-width:992px) { | |