Skip to content
This repository has been archived by the owner on Oct 28, 2020. It is now read-only.

Commit

Permalink
Added HasOne capability
Browse files Browse the repository at this point in the history
  • Loading branch information
ajthinking committed Jun 8, 2019
1 parent 61ccada commit 2b23a82
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/public/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -208782,7 +208782,13 @@ function (_BasePipe) {
}, {
key: "relationshipMethods",
value: function relationshipMethods(model) {
return [model.relationships.hasMany.map(function (target) {
return [model.relationships.hasOne.map(function (target) {
return _utilities_Template__WEBPACK_IMPORTED_MODULE_0__["default"]["for"]('HasOneRelationship').replace({
___TARGET_CLASS___: target.className(),
___THIS_CLASS___: model.className(),
___METHOD_NAME___: _utilities_Formatter__WEBPACK_IMPORTED_MODULE_2__["default"].camelCase(target.className())
});
}).join(___DOUBLE_LINE_BREAK___), model.relationships.hasMany.map(function (target) {
return _utilities_Template__WEBPACK_IMPORTED_MODULE_0__["default"]["for"]('HasManyRelationship').replace({
___TARGET_CLASS___: target.className(),
___TARGET_CLASS_PLURAL___: _utilities_Formatter__WEBPACK_IMPORTED_MODULE_2__["default"].pluralize(target.className()),
Expand Down
11 changes: 11 additions & 0 deletions src/resources/js/fileFactories/Laravel/pipes/ModelPipe.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,17 @@ export default class ModelPipe extends BasePipe {

relationshipMethods(model) {
return [
model.relationships.hasOne.map(target => {
return Template.for('HasOneRelationship').replace({
___TARGET_CLASS___: target.className(),
___THIS_CLASS___: model.className(),
___METHOD_NAME___: F.camelCase(
target.className()
),

})
}).join(___DOUBLE_LINE_BREAK___),

model.relationships.hasMany.map(target => {
return Template.for('HasManyRelationship').replace({
___TARGET_CLASS___: target.className(),
Expand Down
7 changes: 7 additions & 0 deletions src/templates/HasOneRelationship
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/**
* Get the ___TARGET_CLASS___ for the ___THIS_CLASS___.
*/
public function ___METHOD_NAME___()
{
return $this->hasOne('App\___TARGET_CLASS___');
}

0 comments on commit 2b23a82

Please sign in to comment.