-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dynamic Snippet Form problem #17
Comments
yes, it not support the dynamic Snippet Form. your idea is so cool. I will try to do the auto-update. |
@diaafares do you have any other use case of dynamic Snippet Form? |
Hi @billyct For example: select a user to get how many posts he have and other statistics. I have an idea about how you may implement this feature: Just wanted to give you an idea how you can implement this feature, but maybe you have a better solution for this |
@diaafares I have done a simple auto-update for mac in v0.2.4 😉 thx for your solution, 🤔 I will think about it. |
@billyct oh, great work, thank you very much |
yes, I have not done the dynamic Snippet Form yet. how about writing the dynamic data in the closure for your case above: $field_user = [
'value' => '',
'label' => 'User',
'description' => 'Select a user.',
'type' => 'select',
'options' => function() {
return User::selectRaw('first_name as label, id as value')->get()->toArray();
},
]; with the closure, so I can just run code in the closure only with tinker for getting the dynamic data. |
@billyct oh, great idea, way better than what I suggested! It will be great if we can do it like this: $options = function() {
return User::selectRaw('first_name as label, id as value')->get()->toArray();
};
$field_user = [
'value' => '',
'label' => 'User',
'description' => 'Select a user.',
'type' => 'select',
'options' => $options,
]; Is that possible? |
😉 Already available in v0.2.5 |
@billyct awesome work, thank you very much ^_^ |
@billyct BTW, I tried to get v0.2.5 by using auto update feature, but it seems like it didn't work, I opened Tinkerun and it was downloading the new version in the background, I waited until the network activity stopped (it should mean that the download finished) but nothing happened, I restarted the app and I still have v0.2.4 Also when I tried the latest version v0.2.5, I get this error: I suspect that the cause of the error is that I have many records in the |
@diaafares I will check the auto-updater. And Tinkerun cannot handle 10000 records, because it is only simulating Tinker’s Terminal input. if I do the 10000 records in the terminal, Tinker will just send me something like below: App\Models\User {#5477 …6},
App\Models\User {#5478 …6},
App\Models\User {#5479 …6},
App\Models\User {#5480 …6}, I think you should add some conditions for your query 😂 |
@billyct Before I posted my last comment, I already added Or maybe the problem is different than my thoughts I really don't know |
@diaafares how about just run some code like below in tinker json_encode((function() {
return User::selectRaw('first_name as label, id as value')->limit(3)->get()->toArray();
})()) I get the dynamic data in the background by this code. |
@billyct I think the problem is happen because of the import of the User model when Tinkerun execute the closures, as my App have custom setup and the User model is not placed as normal Laravel apps, I ran the code inside Tinker from terminal and it give me the following error:
The problem is I added the right import inside Tinkerun, but as I said before, it seems like Tinkerun doesn't recognize the imports inside the closures, what you think |
@diaafares yes, Tinkerun can't recognize the things outside the closures. so in your case, you should use App\Models\User::selectRaw('first_name as label, id as value')->limit(3)->get()->toArray(); not good, but I think it will work 😂 Because Tinkerun does not depend on the PHP runtime, so it's quite not easy to do the Dynamic Snippet Form perfectly. |
@billyct yes it worked, but it will be great if Tinkerun returned the error when you hit the Snippet form button, currently if any error happened inside the closure, Tinkerun freezes and you have to Force quit it without knowing whats the problem is. Try this inside Tinkerun to see whats happen:
Notice that I added |
@diaafares yes, I think so. I will do it when I am free |
@billyct great, can't wait |
Hey @billyct I get the same error as here and when I click I will be grateful if you look at the issue and update Tinkerun to not stuck and show the real error message intead |
I have added the error message now, no stuck 😄 |
@billyct Thank you so much!
I tried a different table and a different project and I have the same error always, I don't know why 😞 |
@diaafares I think it may be because Laravel/Tinker has no color by default. checkout the new version, and let me know if you still have problems. |
@billyct |
Hi,
At first, thanks for your efforts doing this great app.
Today I have an idea about to make Snippet Form dynamic, so I did something like this:
But as soon as I click the Snippet Form button, I get this white empty screen:
I was trying to populate the User select from the DB, also I was planning to use the
$field_user
value as an input for a second DB query, so the chosen value for$field_user
will customize the result of the second query!I know maybe the feature was not design to work as I wanted, but when I think about it, supporting dynamic Snippet Form will make the possibilities endless for Tinkerun
Also another request: I will be grateful if you implemented a self-update feature in Tinkerun, so we always have the latest and greatest without checking Tinkerun website every week or so
The text was updated successfully, but these errors were encountered: