skip to Main Content

Laravel Raw Select Returning Repeated Values

I have the following test method in my model, it gets the length of a json column in a row: public function test(){ return $this->select(DB::raw('JSON_LENGTH((SELECT comments FROM lab_evals WHERE id='.$this->id.'))'))->get(); } In tinker it returns this: = IlluminateDatabaseEloquentCollection {#7430 all:…

VIEW QUESTION

Laravel – Would reset hard uninstall a package?

Would reset hard uninstall a package? Say I have commits 789f658a6e55a65cc3f056asf – Commit before installing package 789fdfdsfse55a65cc3f056asf – Commit after installing package If I reset to “Commit before installing package” would that uninstall the package or just remove the line…

VIEW QUESTION

Laravel multi tenant sessions

In my Laravel application, I set the login session settings and set 'expire_on_close' => true in config/session.php file so that if the user closes the browser, his session ends, and I also record when the user logged in for the…

VIEW QUESTION

Laravel – How to prevent unique error if I have 3 fields in a table/model but need more than 1 item? (factory)

I have a unique index on 3 fields: public function up(): void { Schema::create('items', function (Blueprint $table) { $table->id(); $table->foreignId('points_id'); $table->foreignId('user_id'); $table->unsignedTinyInteger('status'); $table->timestamp('created_at')->useCurrent(); $table->foreign('user_id')->references('id')->on('users'); $table->foreign('points_id')->references('id')->on('points'); $table->unique(['points_id', 'user_id', 'status']); }); } I need to make a factory to create a lot…

VIEW QUESTION
Back To Top
Search