I'm new to laravel .
I want to work with php artisan tinker in cygwin but I am getting some errors in making an object. I watched some videos and the guy did this:
$article = new app\articles;
but when I do this it says:
PHP Fatal error: Class 'app\articles' not found in eval()'d code on line 1
I tried this too:
$article = new c://xampp/htdocs/laravel/app/articles;
but it says this:
PHP Parse error: Syntax error, unexpected ':' on line 1
Laravel Tinker allows you to interact with a database without creating the routes. Laravel tinker is used with a php artisan to create the objects or modify the data. The php artisan is a command-line interface that is available with a Laravel. Tinker is a command tool that works with a php artisan.
Tinker is very convenient if you want to create test data in development – simply create two new test users with their factory. This command uses the model factory for users and creates two new users. Your output of this command should look similar to this – with different usernames and emails.
To dispatch new jobs and test if the job is working, I run this code in Tinkerwell within the local application: $order = Order::latest()->first(); dispatch(new UploadOrderDataToMailchimp($order));
Tinker is case sensitive so if you are trying to create the object the way you are doing it it will fail so instead try placing the whole namespace in the exact way it is on your project
$article = new App\Article;
Use terminal to go to your project, and type :
php artisan tinker
Then type the following command for example to create a new Article
:
$article = new Article;
After that you can manipulate the article like any Article
object :
$article->title = "foo";
Maybe you should take a look at Laravel Fundamentals at laracasts.com, it's a greate serie for Laravel beginners.
Regards.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With