Category : tinker

My code is written in PHP using Laravel and Postgresql as the db. I have a model: <?php namespace AppModels; use IlluminateDatabaseEloquentFactoriesHasFactory; use IlluminateDatabaseEloquentModel; class Contact extends Model { use HasFactory; protected $fillable = [ ‘last_name’, ‘first_name’, ‘phone_number’, ‘address’, ]; //protected $table = ‘database.contact’; protected $hidden = [ ‘remember_token’, ]; } and a migration: <?php ..

Read more

Simply prefixes a # to the field name I am using Laravel Breeze, which by default sets the password and remember_token fields to hidden. class User extends Authenticatable { use HasFactory, Notifiable; protected $fillable = [ ‘username’, ’email’, ‘password’, ]; protected $hidden = [ ‘password’, ‘remember_token’, ]; protected $casts = [ ’email_verified_at’ => ‘datetime’, ]; ..

Read more

I am learning laravel 8, I keep getting this error BadMethodCallException Call to undefined method AppModelsQuestion::factory() at C:UsersUSERDesktoplaravelsqnavendorlaravelframeworksrcIlluminateSupportTraitsForwardsCalls.php:50 46▕ * @throws BadMethodCallException 47▕ */ 48▕ protected static function throwBadMethodCallException($method) 49▕ { ➜ 50▕ throw new BadMethodCallException(sprintf( 51▕ ‘Call to undefined method %s::%s()’, static::class, $method 52▕ )); 53▕ } 54▕ } • Bad Method Call: Did ..

Read more

I’m having issues connecting to a docker instance of MySQL through Laravel. I’ve found that by using Tinker, I can connect successfully to the database. e.g, with Tinker, if I run DB::select("select * from users;"); I’m able to get results. However, if I make a route Route::post(‘/sql’, function(Request $request){ return DB::select(‘select * from appointments;’)->get(); }); ..

Read more

I wished create model call the laravel artisan tinker. so I try execute php tinker .. but AppUser command was occurred error. I don’t know. what should I do? My development enviroment vagrant php 8.* laravel 8.* enter image description here enter image description here >>> $user = AppUser::create ([‘name’ => ‘rin’, ’email’ => ‘[email protected]’, ..

Read more

I’m using the laravel-permission package from Spatie, which uses the SpatiePermissionModelsRole and SpatiePermissionModelsPermission classes as models. Whenever I need to work with roles and permissions within php artisan tinker, I need to either write the fully qualified class name for the models or start the session with use SpatiePermissionModelsRole/Permission;, which is a minor annoyance. Role ..

Read more

I’m Inserting some dummy data using the factory model class using this command on tinker: When i run composer dump-autoload, php artisan tinker, Page::factory(10)->create() Then this error shows PHP Error: Class ‘Page’ not found in /var/www/html/laravel/laravel8-blogeval()’d code on line 1 enter image description here My model file location appModelsPage.php <?php namespace AppModels; use IlluminateDatabaseEloquentFactoriesHasFactory; use ..

Read more

I have a RoleUser Model and wanted to run factory. This has 2 columns(role_id, which comes from the Role table), and user_id which comes from the User Table. I wanted to create a loop as such that it will show like this in the RoleUser table id role_id user_id 1 2 1 2 2 2 ..

Read more

In laravel 8, I could generate dummy datas for user using factories but I could not geneate dats for Product. I got the following error: error BadMethodCallException with message ‘Call to undefined method AppModelsProduct::factory()’. User_id in Product is the foreign key. I couldn’t identify what is wrong. Model: Product.php <?php namespace AppModels; use IlluminateDatabaseEloquentFactoriesHasFactory; use ..

Read more

I have a problem with php artisan tinker, can’t find the reason why he wants a ‘businesses’ table but not a ‘business’ table. Help me fix mistakes, I feel I did a lot of them) My Problem : IlluminateDatabaseQueryException with message ‘SQLSTATE[42S02]: Base table or view not found: 1146 Table ‘homestead.businesses’ doesn’t exist (SQL: select ..

Read more

I’m making a second connection of my project in laravel with a view in an MsSql database, I configured my .env and config correctly, however this is an error of memory overflow: $ php artisan tinker Psy Shell v0.10.5 (PHP 7.3.24-3+ubuntu18.04.1+deb.sury.org+1 — cli) by Justin Hileman >>> use AppCondinvestBoletoPropCondominio as BPC >>> BPC::first(); IlluminateDatabaseQueryException with ..

Read more

I have a problem with artisan tinker Problem: IlluminateDatabaseQueryException with message ‘SQLSTATE[42S02]: Base table or view not found: 1146 Table ‘homestead.projects’ doesn’t exist (SQL: insert into projects (title, description, updated_at, created_at) values (My first Project, bla bla, 2020-12-18 14:21:42, 2020-12-18 14:21:42))’ my table file: <?php use IlluminateDatabaseMigrationsMigration; use IlluminateDatabaseSchemaBlueprint; use IlluminateSupportFacadesSchema; class BusinessTable extends Migration ..

Read more

my goal is to convert the following sql query to to laravel tinker syntax, $qstA = " select sum(tmpbutbldata.Personnel_Hours_Spent) as PHS from tmpbutbldata left join tbl_testlocation_links on tmpbutbldata.Test_Request_Number= tbl_testlocation_links.Test_Request_number where tmpbutbldata.Date_Test_Completed between ‘".$dateBack."’ and ‘".$dateCurr."’ and tbl_testlocation_links.".$Location."=’1′ and tmpbutbldata.type = ‘1’ and tmpbutbldata.cancelled = ‘0’ or tmpbutbldata.Date_Test_Completed between ‘".$dateBack."’ and ‘".$dateCurr."’ and tbl_testlocation_links.".$Location."=’1′ and tmpbutbldata.type ..

Read more

I have two models Poll and DuplicatePoll with the respective tables: Schema::create(‘polls’, function (Blueprint $table) { $table->id(); $table->text(‘status’); $table->timestamps(); }); Schema::create(‘duplicate_polls’, function (Blueprint $table) { $table->id(); $table->unsignedBigInteger(‘poll_id’); $table->timestamp(‘created_at’)->useCurrent(); $table->foreign(‘poll_id’) ->references(‘id’) ->on(‘polls’); }); when i go to create a value for DuplicatePolls with tinker i get the following error: AppModelsDuplicatePoll::factory()->create([‘poll_id’=>10]); PHP Fatal error: Class ‘App/Models/DuplicatePoll’ not ..

Read more