Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions tests/Feature/Generator/ModelGeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,7 @@ public function modelTreeDataProvider()
['drafts/nested-components.yaml', 'app/Admin/User.php', 'models/nested-components.php'],
['drafts/resource-statements.yaml', 'app/User.php', 'models/resource-statements.php'],
['drafts/all-column-types.yaml', 'app/AllType.php', 'models/all-column-types.php'],
['drafts/alias-relationships.yaml', 'app/Salesman.php', 'models/alias-relationships.php'],
];
}

Expand Down
7 changes: 7 additions & 0 deletions tests/fixtures/drafts/alias-relationships.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
models:
Salesman:
name: string
relationships:
hasOne: User:Lead
hasMany: class_name:method_name
belongsTo: class_name:method_name
42 changes: 42 additions & 0 deletions tests/fixtures/models/alias-relationships.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Salesman extends Model
{
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'name',
];

/**
* The attributes that should be cast to native types.
*
* @var array
*/
protected $casts = [
'id' => 'integer',
];


public function lead()
{
return $this->hasOne(\App\User::class);
}

public function methodNames()
{
return $this->hasMany(\App\ClassName::class);
}

public function methodName()
{
return $this->belongsTo(\App\ClassName::class);
}
}