Category : database

SQLSTATE[42S21]: Column already exists: 1060 Duplicate column name ‘image’ (SQL: create table products (id bigint unsigned not null auto_increment primary key, name varchar(255) not null, slug varchar(255) not null, short_description varchar(255) null, description text not null, regular_price decimal(8, 2) not null, sale_price decimal(8, 2) null, SKU varchar(255) not null, stock_status enum(‘instock’, ‘outofstock’) not null, feature ..

Read more

Is there any to in laravel? I want to check if current_time<2PM , i want to update the datatabase time with : current_date and 8PM, If current_time>2PM: update the db with tomorrows date , 2pm, if TODAYS DAY is saturday and I want to update to MONDAY 2PM $check_time = Carbon::createFromFormat(‘H:i a’, ’01:00 PM’); $date ..

Read more

This is my code $data = DB::table(‘constructor_standings’) ->join(‘constructors’, ‘constructors.constructorId’, ‘=’, ‘constructor_standings.constructorId’) ->select(‘constructor_standings.*’, ‘constructors.*’) ->where([‘constructor_standings.raceId’ => $res2]) ->orderBy(‘position’, ‘asc’) ->get(); return $data; In constructor_standings there is a column "points". The column’s type is float. Although only few values are demical so i want the rest of them to be returned as integer and not as a ..

Read more

I have this line in a migration table Schema::create(‘xyzTableName’, function (Blueprint $table) { $table->id(); $table->unsignedBigInteger(‘userId’); $table->foreign(‘userId’)->references(‘id’)->on(‘userId’); $table->timestamps(); }); where I did write on(‘userId’) by mistake what I want is on(‘users’) now I did this, (in a new migration, as I can’t run migrate:fresh) Schema::create(‘xyzTableName’, function (Blueprint $table) { $table->foreign(‘userId’)->references(‘id’)->on(‘users’)->->change(); }); but I don’t why it ..

Read more

I have this line in a migration table Schema::create(‘xyzTableName’, function (Blueprint $table) { $table->id(); $table->unsignedBigInteger(‘userId’); $table->foreign(‘userId’)->references(‘id’)->on(‘userId’); $table->timestamps(); }); where I did write on(‘userId’) by mistake what I want is on(‘users’) now I did this, (in a new migration, as I can’t run migrate:fresh) Schema::create(‘xyzTableName’, function (Blueprint $table) { $table->foreign(‘userId’)->references(‘id’)->on(‘users’)->change(); }); but I don’t why it ..

Read more

i make code to when user click on button make count how much count do downloaded look here : https://i.ibb.co/1GMfrvr/3s.png $downloads = new Download(); $downloads = Download::where(‘trx’,$downloads->trx)->whereHas(‘user’, function ($query) { $query->where(‘download_count’,0); })->latest()->with([‘product_id’])->first(); $downloads->increment(‘download_count’); I need to read it differently for each transaction id and id – one by one Sourc..

Read more

Hi I am trying to get the current count of my statement below , but Iam get another product count: i adding New Count System Like When User Click Button get +=1 in DB public function productDownload($id) { $counts_download = Download::where(‘download_count’,0,’product_id’,$product->id->paginate(getPaginate())); $counts_download->increment(‘download_count’); } This Working Adding Count but on another Product so how to edit ..

Read more

Here is my products table schema Schema::create(‘products’, function (Blueprint $table) { $table->id(); $table->string(‘product_name’); $table->string(‘product_slug’); $table->text(‘product_description’); $table->unsignedBigInteger(‘quantity’); $table->foreignId(‘category_id’)->constrained()->onDelete(‘cascade’); $table->timestamps(); }); Here is my categories table schema Schema::create(‘categories’, function (Blueprint $table) { $table->id(); $table->string(‘name’); $table->timestamps(); }); After that when i try to migrate the database it show this kind of errors.please tell me why it’s causing this ..

Read more

public function scopeSearch($query, $value) { $searchValues = explode(‘ ‘, $value); if (!$value) return $query; return $query->where(function ($q) use ($searchValues) { foreach ($searchValues as $token) { $q->orWhere(‘name’, ‘like’, "%{$token}%"); $q->orWhere(‘street’, ‘like’, "%{$token}%"); } }); } I want to search the data. This model also has public function brands() { return $this->belongsToMany(Brand::class, ‘dealer_brands’); } public function province() ..

Read more