Skip to content

Instantly share code, notes, and snippets.

@jamesratcliffe
Created December 1, 2017 18:01
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 jamesratcliffe/4d9e68b37b405917dfc1e77e99b188be to your computer and use it in GitHub Desktop.
Save jamesratcliffe/4d9e68b37b405917dfc1e77e99b188be to your computer and use it in GitHub Desktop.
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
use LaravelFillableRelations\Eloquent\Concerns\HasFillableRelations;
class Tool extends Model
{
use HasFillableRelations;
protected $fillable = ['name'];
protected $fillable_relations = ['fields'];
public function fields()
{
return $this->hasMany(static::class . 'Field');
}
}
class ToolField extends Model
{
use HasFillableRelations;
protected $fillable = ['name'];
protected $fillable_relations = ['choices'];
public function choices()
{
return $this->hasMany(static::class . 'Choice');
}
}
class ToolFieldChoice extends Model
{
protected $fillable = ['name'];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment