Skip to content

Instantly share code, notes, and snippets.

<?php
abstract class TransactionHelper {
protected $closures = [];
public function add(Closure $closure)
{
$this->closures[] = $closure;
}
App.Person = DS.Model.extend({
id: DS.attr('number'),
name: DS.attr('string'),
city: DS.attr('string'),
company: DS.belongsTo('company')
});
window.App = Ember.Application.create();
App.ApplicationAdapter = DS.FixtureAdapter.extend();
App.PersonController = Ember.ObjectController.extend({
isEditing: false,
actions: {
edit: function() {
@dadamssg
dadamssg / gist:7393979
Created November 10, 2013 04:52
MySQL companiesExtended view
CREATE VIEW companiesExtended AS
select *, (select group_concat(id separator ',') from people as peopleTable where companyTable.id = peopleTable.`company_id`) as people_ids from companies as companyTable
<?php
use Illuminate\Database\Migrations\Migration;
class CreateCompaniesTable extends Migration {
public function up()
{
Schema::create('companies', function($table)
{
<?php
class Person extends BaseModel
{
protected $table = 'people';
protected $fillable = [
'firstName',
'lastName',
'email',
{
"posts": [{
"id": "1",
"title": "A blog title",
"links": {
"author": "http://example.com/people/1",
"comments": "http://example.com/comments/5,12,17,20"
}
}]
}
//Why are collections namespaced and single entity responses not? For example:
[
{
"name": "Hulk Hogan",
"id": "100002"
},
{
"name": "Mick Foley",
"id": "100003"
}
@dadamssg
dadamssg / app.js
Last active December 29, 2015 23:28
Select2 is passing an object literal into the handleCompanySelect method on the PeopleNewController.
App.PeopleNewController = Ember.ObjectController.extend({
companySelection: null,
actions: {
doneEditing: function () {
var person = this.get('model');
person.save();
@dadamssg
dadamssg / companies.json
Last active February 6, 2017 19:06
Ember-Data Tutorial
{
"companies": [
{
"id": "1",
"created_at": "2013-12-09 00:57:49",
"updated_at": "2013-12-09 00:57:49",
"name": "Acme Corp",
"links": {
"tasks": "/companies/1/tasks",
"people": "/companies/1/people"