Closed Stiropor closed 6 years ago
Hello.
To display the relations fields, just include them in list of columns
$this->push('client.name')
with name: 'relationname.fieldname', or in
your case 'client.name'.
Remember this assumes you have a relation 'client()' in your User model.
There is no difference between cc version and github one. Cc was just for support, and now its easier to "buy a coffee" instead ;)
On Sat, Jul 21, 2018, 14:57 Stiropor notifications@github.com wrote:
This is an awesome project! But I have one problem - I can't find in any documentation or here anywhere how to display a field from related table. My events table has a client_id field, that points to clients table. In grid right now the data is displayed at 1. How do I make it dispay's client's name (title field)? I know I need to use update() in columns() method, but how? I see that works just fine in your demo app ... but cannot figure what is the correct way of doing it except manually doing search on Client model... is this the only/right way?
2 more questions:
- is that demo site available to download/check anywhere? It'd probably be a great help for users!
- I see this project is also on codecanyon... what's the difference? I'd gladly support this project, would just like to know what the difference between github's version and one from cc is?
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/adminarchitect/core/issues/35, or mute the thread https://github.com/notifications/unsubscribe-auth/ACtA-z3aRWEXi68qp4vaKdqI3lc72fZqks5uIxcygaJpZM4VZml4 .
Oh, so basicaly I don't change the client_id but add client and then hide client_id column. Cool. Thanks!
2 bugs (I think) I just found:
push doesn't have a position parameter, so I have to use move()
. But if I assign ID to client.name
in closure, client.name isn't displayed. If I don't assing it, it works, but I have to assign it in order to change it's position.
if I use insert('client.name', ...)
and current model also has a name (event.name), it will display event.name instead of client.name. Inserting any other client's field that event doesn't have, works as expected.
I see this app is getting currently updated? The UI is way different than the one on demo. Keep up the good work :)
Hello @endihunter,
I would like to ask how to add a form element based on a user role?
Like I have a model User
with roles of admin
, seller
, user
I don't want a user record to have an image uploader on the form. How can I conditionally add the form element based on the role value?
thanks!
@smallcar88 I think something like this should work.
public function form() {
$form = $this->scaffoldForm();
if (auth()->user()->isAdmin()) {
$form->push(FormElement::media('image_uploader'));
}
return $form;
}
@smallcar88 or if you want to disable an element for specific user:
... get form
if (auth()->user()) {
$form->without('image_uploader');
}
return $form;
@endihunter thank you for the answer.
Actually my question is at per-record level, not the current user.
For example, user:1
is a seller, user:2
is a normal user.
When I edit their profiles as an admin, I want the form of the seller to have image
uploader, but not in that of a normal user.
Is it achievable via form() function?
@endihunter thank you for the answer. Actually my question is at per-record level, not the current user. For example,
user:1
is a seller,user:2
is a normal user. When I edit their profiles as an admin, I want the form of the seller to haveimage
uploader, but not in that of a normal user. Is it achievable via form() function?
@smallcar88 so, in your case just use the app('scaffold.model')
instead of auth()->user()
.
that will give you the model you're working on instead of logged in user.
Thank you so much @endihunter, your solution works great for me! Much Appreciated!
This is an awesome project! But I have one problem - I can't find in any documentation or here anywhere how to display a field from related table. My events table has a client_id field, that points to clients table. In grid right now the data is displayed at 1. How do I make it dispay's client's name (title field)? I know I need to use
update()
incolumns()
method, but how? I see that works just fine in your demo app ... but cannot figure what is the correct way of doing it except manually doing search on Client model... is this the only/right way?2 more questions: