Skip to content

Instantly share code, notes, and snippets.

@vannut
Last active June 19, 2016 20:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vannut/d7629a3860fd64283e76ef4ce9643247 to your computer and use it in GitHub Desktop.
Save vannut/d7629a3860fd64283e76ef4ce9643247 to your computer and use it in GitHub Desktop.
<?php namespace Acme\Plugin\Models;
use Model;
class Activity extends Model
{
public $table = 'acme_activity';
public $hasMany = [
'prices' => 'Acme\Plugin\Models\Price'
];
public $attachOne = [
'image'=>['System\Models\File']
];
}
<?php
// activity
Schema::create('acme_activity', function ($table) {
$table->increments('id');
$table->string('name');
$table->string('slug');
$table->string('tagline');
$table->text('description');
$table->boolean('is_published')->default(true);
$table->timestamps();
});
// price
Schema::create('vannut_price', function ($table) {
$table->increments('id');
$table->integer('activity_id');
$table->string('description');
$table->integer('cents');
$table->boolean('available')->default(true);
$table->timestamps();
});
<?php namespace Acme\Plugin\Models;
use Model;
class Price extends Model
{
public $table = 'acme_price';
public $belongsto = [
'activity' => 'Acme\Plugin\Models\Activity'
];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment