How to build a quaternary relationship in laravel 6?

I have to create a relationship between this tables: As you can see, I need to relate 4 tables creating a quaternary relationship, asuming that the database model is ok, how i can do the relationship with eloquent? In model Subject public function curs_academic(){ // as academic year return $this->belongsToMany(‘App\Curs_academic’, ‘assignatura_alumne_curs_professor’, ‘id_assignatura’, ‘id_curs_academic’); } public…

Laravel download file from php output buffer VS. private storage folder | security

A user can download query results in CSV format. The file is small (a few KB), but the contents are important. The first approach is to use php output buffer php://: $callback = function() use ($result, $columns) { $file = fopen(‘php://output’, ‘w’); fputcsv($file, $columns); foreach($result as $res) { fputcsv($file, array($res->from_user, $res->to_user, $res->message, $res->date_added)); } fclose($file);…

Do Unique validation on multiple fields in Laravel 5.8

I want to do “unique” validation on multiple fields. I have written below validation rule but not sure how to include brand_id and company_id in it $request->validate([ ‘name’ => ‘required|string|unique:products’, ‘company_id’ => ‘required’, ‘brand_id’ => ‘required’, ]); So what I am trying to do is, ADD PRODUCT but check if the name is unique for…