skip to Main Content

How can i delete old images in Laravel?

I want to remove old images in my public folder when he want to change him profile photo. ProfileController: if($request->hasFile('image')){ $request->validate([ 'image' => 'image|mimes:jpeg,png,jpg,svg|max:2048' ]); $imageName = $request->user()->id.'-'.time().'.'.$request->image->extension(); $request->image->move(public_path('users'), $imageName); $path = "users/".$imageName; $request->user()->image = $path; $request->user()->save(); } i tried…

VIEW QUESTION

Laravel SQLSTATE[42883]: Undefined function: 7 ERROR: operator does not exist: integer

I have like this migration file: Schema::create('posts', function($table) { $table->engine = 'InnoDB'; $table->increments('id')->unsigned(); $table->string('title'); $table->text('description')->nullable(); $table->integer('sort_order')->default(0); $table->boolean('status')->default(0); }); And I have also seeder: class SeedPostsTable extends Seeder { public function run() { $posts = $this->getPosts(); foreach ($posts as $title =>…

VIEW QUESTION

Get Only children from hasmany relation laravel 8

I have two mysql table with HasMany/belongsTo relation like this : public function Products() { return $this->hasMany(Prices::class, 'product_id'); } public function Prices() { return $this->belongsTo(Products::class); } If i do the following function, i can get the latest price for every…

VIEW QUESTION
Back To Top
Search