skip to Main Content

Laravel 8.x realationship – Use HasMany in HasOne

I'm trying to use a HasMany relation in a HasOne. I have following Models: class Auction extends Model { //... public function bids(): HasMany { return $this->hasMany(Bid::class, 'auction_id'); } public function approvedBids(): HasMany { return $this->bids()->approved(); } public function topBids():…

VIEW QUESTION

update content of stored column in laravel controller

I have a table with 3 columns: firstname lastname fullname in migration: Schema::create('owners', function (Blueprint $table) { $table->id(); $table->string('firstname',20); $table->string('lastname', 20); $table->string('fullname')->storedAs('CONCAT(firstname,lastname)'); $table->timestamps(); }); the problem is that i want to change the concatenation order in the controller i tried…

VIEW QUESTION

Laravel not validate html select box

I have problem with validating html select. I put rules and all other form controls work fine but only select not show validate message. Model class Post extends Model { protected $table = 'post'; static $rules = [ 'title' =>…

VIEW QUESTION

Laravel api bypass auth api for specific ip address

Below is my laravel 8 api route and middleware that I use Route::group(['middleware'=>['auth:api', 'StripScript'],'prefix' => 'v1'], function(){ Route::get('/list', [ListController::class, 'list']); }); I this I want to bypass middleware 'auth:api' if I get request from specific ip address so user doesn't…

VIEW QUESTION

unlink(): Invalid argument this error is occurred while update image in laravel

I am trying to update image to image/brand/ folder but unexpectedly error is occurred. public function update(Request $request,$id){ $validated = $request->validate([ 'brand_name' => 'required|max:4', // 'brand_image' => 'required|mimes:jpg,jpeg,png', ]); $old_image=$request->old_image; $brandimage=$request->file('brand_image'); $image_gen=hexdec(uniqid()); $image_exten=strtolower($brandimage->getClientOriginalExtension()); $image_name=$image_gen.'.'.$image_exten; $image_location='image/brand/'; $image_uplioad= $image_location.$image_name; $brandimage->move($image_location,$image_name); unlink($old_image); Brand::find($id)->update([…

VIEW QUESTION
Back To Top
Search