The simplest way to traverse the hierarchy tree with Baum is by iterating through the children relation.
<?php
$root = Category::roots()->with('children')->first();
echo "<h3>{$root->name}</h3>";
foreach($root->children as $category) {| <?php | |
| require __DIR__ . '/vendor/autoload.php'; | |
| use Illuminate\Database\Capsule\Manager as DB; | |
| use Baum\Node; | |
| // Initialize Capsule | |
| $capsule = new DB; | |
| // Add connection settings |
| <?php | |
| require __DIR__ . '/vendor/autoload.php'; | |
| use Illuminate\Database\Capsule\Manager as DB; | |
| use Baum\Node; | |
| // Initialize Capsule | |
| $capsule = new DB; | |
| // Add connection settings |
| # db/migrate/XXXXXXXXXXXXX_add_authentication_token_to_users.rb | |
| class AddAuthenticationTokenToUsers < ActiveRecord::Migration | |
| def change | |
| add_column :users, :authentication_token, :string | |
| add_index :users, :authentication_token, :unique => true | |
| end | |
| end |
The simplest way to traverse the hierarchy tree with Baum is by iterating through the children relation.
<?php
$root = Category::roots()->with('children')->first();
echo "<h3>{$root->name}</h3>";
foreach($root->children as $category) {| /* | |
| * Inspired by: http://stackoverflow.com/questions/4360060/video-streaming-with-html-5-via-node-js | |
| */ | |
| var http = require('http'), | |
| fs = require('fs'), | |
| util = require('util'); | |
| http.createServer(function (req, res) { | |
| var path = 'video.mp4'; |
| #!/bin/bash | |
| BUNDLED_COMMANDS="${BUNDLED_COMMANDS:- | |
| cap | |
| capify | |
| cucumber | |
| foreman | |
| guard | |
| haml | |
| heroku |
| # Simple, scrappy UDP DNS server in Ruby (with protocol annotations) | |
| # By Peter Cooper | |
| # | |
| # MIT license | |
| # | |
| # * Not advised to use in your production environment! ;-) | |
| # * Requires Ruby 1.9 | |
| # * Supports A and CNAME records | |
| # * See http://www.ietf.org/rfc/rfc1035.txt for protocol guidance | |
| # * All records get the same TTL |
| { | |
| // Sets the colors used within the text area | |
| "color_scheme": "Packages/Color Scheme - Default/Monokai.tmTheme", | |
| // Note that the font_face and font_size are overriden in the platform | |
| // specific settings file, for example, "Base File (Linux).sublime-settings". | |
| // Because of this, setting them here will have no effect: you must set them | |
| // in your User File Preferences. | |
| "font_face": "Monaco", | |
| "font_size": 12, |
| class Person | |
| @name = nil | |
| # class-level reader | |
| # cattr_accessor is rails-specific not ruby, and uses class vbles so ... | |
| # may be done like this too: | |
| # | |
| # class << self | |
| # attr_reader :name | |
| # end |
| # encoding: utf-8 | |
| require 'pp' | |
| class Point | |
| attr_accessor :x, :y | |
| def initialize(x=0.0, y=0.0) | |
| @x = x | |
| @y = y | |
| end |