Category : eloquent

Table: vacancies id int unsigned Auto Increment code varchar(191) NULL start_time timestamp NULL end_time timestamp NULL business_unit_id int unsigned job_id int unsigned on_date date break int NULL shift_id int unsigned total_numbers int Table: vacancy_details id int unsigned Auto Increment vacancy_id int unsigned day_id int unsigned shift_id int unsigned rate_type enum(‘flat_rate’,’hourly_rate’) [hourly_rate] start_time timestamp NULL end_time ..

Read more

i’ve an array like below for $response. i wanted to fetch the user field alone & files field lying inside the user from it . i tried like $response[‘user’] & $response[‘user’][‘files’] , it shows the error undefined index. How can i achieve this? [ { "id": 14, "userId": 1, "courseDisplayName": "yuu", "aboutCourse": "kljkl", "user": { ..

Read more

I’m currently making a news system, and I need to get the top 5 posts with the most likes. Below my code and tables: Models: Post: class Post extends Model { use HasFactory; use HasTags; public function user() { return $this->belongsTo(User::class); } public function likes() { return $this->hasMany(PostLike::class); } public function comments() { return $this->hasMany(PostComment::class); ..

Read more

I want to call Model::insert() on this array to insert multiple data at once "person" => array:2 [▼ 0 => array:2 [▼ "name" => "Person 1" "place" => "Place 1" ] 1 => array:2 [▼ "name" => "Person 2" "place" => "Place 2" ] ] but the Model excepts a foreign key constraint department_id before ..

Read more