0 votes

I'm new to skipper.

How can I set my own abstract base class to all the abstract classes?

Also I have createdby and updatedby fields.

Both these fields have a relationship to Users, but how can I make it so these methods get a special name?

I mean obviously I can do a find and replace on all the abstract models with a script, but wonder if skipper had a method of doing that?

Thanks

in How To & Manuals by (160 points)

1 Answer

0 votes

Hi,

currently, there is no way how to change base class for all abstract classes.

How exactly do you expect to work it? Do you mean to change it for all classes? So at the project level? Or the module level? Or the entity level?

And if so, I'm still not sure where to place such abstract-base class, because the whole directory of abstract-classes is automatically managed via Skipper so there is no way how to edit it.

Can you prepare some example how you're expecting it?

And regarding created/updated by what exactly you want to replace? Can you please show currently export state and expected one?

Thanks

by Skipper developer (141k points)

I think you are keeping everything too tight with inline to a traditional Laravel setup.

Not everyone using Eloquent is using Laravel for example. In my case I use Eloquent with Code Igniter 3 because I have to.

For example setting aside the idea Laravel expects something a certain way, perhapes it is possible to allow rules that don't make sense to you, but in fact when incorporated into some one else's project it works.

So maybe just allowing some one to change the name of the abstract "extends blah" parameter. Or allowing people to not even use abstract classes at all because some people do not want 200 class files.

Also on another topic.
I have errors because class relation methods aren't generated properly. For example.
Say I have two class models User and Activity, in the User model it generates functions like this for an audit scenario.
Why generate two methods with the same name?

public function activities()
{
    return $this->hasMany('\App\Models\Activity', 'updated_by', 'user_id');
}

public function activities()
{
    return $this->hasMany('\App\Models\Activity', 'created_by', 'user_id');
}

This is an automatic PHP error and should never be done. If some one has two fields that reference the same model then shouldn't we take the field name and contact it to the model name.

For example

public function activitiesUpdatedBy()
{
    return $this->hasMany('\App\Models\Activity', 'updated_by', 'user_id');
}

public function activitiesCreatedBy()
{
    return $this->hasMany('\App\Models\Activity', 'created_by', 'user_id');
}

All I am saying here is maybe enable an "Expert" mode and allow people to generate what they want despite the fact you believe it won't work.

I like the software and would consider buying it, but with over 200 tables and many relationships I will have to manually go in and edit ever single file and after I do that I will never use skipper again which kinda sucks because it is sweet.

Hi, thanks for the detailed reply.

Although I understand your point of view, as I wrote you to the email, we're not Laravel experts. Whole Laravel support was created based on documentation and a fantastic Laravel community which helped us with the testing and gave us a lot of advice during implementation.

Regarding base class, this is something we can easily implement as long as it's a common string that will be replaced in exported clas.

Regarding "activities, this is very strange. Skipper should not allow you to create two associations with the same alias exactly because of this error. Can you please send me your project (or at least these entities?). How this model was created? Maybe it's a bug in the database export?

Regarding abstract classes, this is a necessary part of Skipper export. We're not able to export directly to user code for the Laravel framework. For example, in Doctrine2 where @ORM annotations are used, we are able to distinguish between user-code and skipper-generated code. But in the case of Laravel we need to rewrite whole abstract class during every export to keep it in sync with Skipper model. So, unfortunately, we're not able to export it without that.

Regarding "expert" model, feel free to write us an idea for improvement and we will try to implement it. But we're not able to prepare some "expert" mode automatically. Every property from Skipper needs to be manually mapped to Php code in the case of Laravel. What you're suggesting is working for Doctrine, Propel, etc where we're able to map Skipper XML model to Doctrine XML and it's relatively easy for users to add custom attributes, defines new structures, etc.

But in the case of Laravel, every feature has its own way of representations - static arrays, properties, methods with own structure and format. And we're not able to prepare some super-universal export which automatically creates such code.

So, as in the base class case, we would need to know:
- what/where the property should be in Skipper
- how exactly should look export in exported files

based on this we will be able to implement it. We're doing our best to make Skipper as best as possible, so we will do our best to implement any reasonable feature and idea.

Thanks

This wasn't a database created by Skipper. It was imported from mysql.

When it imported it, it the entity alias entries are all the same when they model is the same. It looks like it doesn't take the field into consideration at all.

is it suppose to?

Yes, this is what I though.

Would be possible to share part of DQL where these issue occurs? It's sufficient to send only these three entities and it's relations.

If possible, please send it to [email protected]

Thanks