Hello
I've started studying the Laravel framework on @JeffreyWay's Laracasts for a few hours and I noticed this:
When using tinker
, I receive the mass-assignment error even if the columns are whitelisted with $fillable
. The error is: Illuminate\Database\Eloquent\MassAssignmentException with message 'title'
)
Try to add a new row and notice the error eg.
>>> App\Article::create(['title'=>'1st Article']);
Is there a way to avoid restarting tinker?
I think you mean tinker
cause tinkster is _way_ something else :D
@Anahkiasen Yep, thanks.
This is not a bug. It is how tinker
works.
@JosephSilber I see, thanks.
@kadimi you might want to check out this repo: https://github.com/ajthinking/tinx
We've love contributions back to the original repo. We were discussing the possibility of restarts only recently.
you can use tinx and call re() to refresh session
@kadimi Here a simple bash command:
while true; do php artisan tinker; done
CTRL+D = reload
CTRL+C = exit
or
.profile file:
alias pat="php artisan tinker"
alias patt="while true; do php artisan tinker; done"
after type "pat" to normal tinker, and "patt" to continous tinker.
@GrahamCampbell Any more recent thoughts about how not to be required to restart Tinker after editing code?
I see "Laravel Tinx was archived on 12th December 2019 and is no longer maintained." but also that it seems to be just a suggestion like https://github.com/laravel/framework/issues/8504#issuecomment-478248339
@szekeresa It seems to work for me so far (+1), but would you mind explaining what that is doing and what the downsides are of running Tinker that way?
Thanks!
@szekeresa It seems to work for me so far (+1), but would you mind explaining what that is doing and what the downsides are of running Tinker that way?
Thanks!
This command while true; do php artisan tinker; done
runs a loop with tinker, and every time you close it by Cmd+D or exit it the loop starts over again, so it reloads the classes and all the lot. Cmd+C closes it.
Most helpful comment
@kadimi Here a simple bash command:
while true; do php artisan tinker; done
CTRL+D = reload
CTRL+C = exit
or
.profile file:
alias pat="php artisan tinker"
alias patt="while true; do php artisan tinker; done"
after type "pat" to normal tinker, and "patt" to continous tinker.