skip to Main Content

Laravel belongsToMany select all specified ids

Relation public function groups() { return $this->belongsToMany('AppModelsItemGroup','item_to_group','item_id','item_group_id'); } ** How to select all Items that have item_group_id 0 and 9 BOTH?** $zero_and_nine_count = AppModelsItem::with(['groups' => function ($query) { $where[] = ['item_group_id', , 0]; $where[] = ['item_group_id', '=', 9]; $query->where($where); }])->count();…

VIEW QUESTION

How to add LIKE to this Eloquent query – Laravel

I'm working with Laravel 5.8 and I have this method: public function getCourseDefinition() { $course_definition = DB::table('getCourseDefinition'); if (request()->has('cod_title') && request('cod_title')) $course_definition = $course_definition->whereRaw("cod_title = ?", [request('cod_title')]); } So it basically checks if the request contains cod_title, then searches for…

VIEW QUESTION

What is wrong with this form validation – Laravel

I'm working with Laravel 5.8 and I have made this Controller method for creating some records inside the DB. public function doTheUpload(Request $request) { try{ $request->validate([ 'video' => 'nullable|mimes:mp4', 'video_thumb' => 'required|mimes:jpg,png,jpeg', 'video_name' => 'required', 'video_desc' => 'nullable', 'available_download' =>…

VIEW QUESTION
Back To Top
Search