How to join two tables and get id from first table in Laravel

I’m trying to join posts and tags tables and get id of posts table, but this code giving me id (11) of tags table, but the post id is 15. result $posts = Post::leftJoin(‘tags’, ‘tags.post_id’, ‘=’, ‘posts.id’) ->where(‘tags.slug’, $slug)->get(); dd($posts); Table tags Schema::create(‘tags’, function (Blueprint $table) { $table->bigIncrements(‘id’); $table->unsignedBigInteger(‘post_id’); $table->string(‘tag’); $table->string(‘slug’); $table->integer(‘views’)->nullable(); $table->foreign(‘post_id’)->references(‘id’)->on(‘posts’)->onDelete(‘cascade’); }); Table…

How to join two tables and get id from first table in Laravel

I’m trying to join posts and tags tables and get id of posts table, but this code giving me id (11) of tags table, but the post id is 15. result $posts = Post::leftJoin(‘tags’, ‘tags.post_id’, ‘=’, ‘posts.id’) ->where(‘tags.slug’, $slug)->get(); dd($posts); Table tags Schema::create(‘tags’, function (Blueprint $table) { $table->bigIncrements(‘id’); $table->unsignedBigInteger(‘post_id’); $table->string(‘tag’); $table->string(‘slug’); $table->integer(‘views’)->nullable(); $table->foreign(‘post_id’)->references(‘id’)->on(‘posts’)->onDelete(‘cascade’); }); Table…

How to display laravel eloquent data with jquery “Ajax” tooltip?

I’m a beginner in laravel. I have a index.blade.php file that data is in table form: <table class=”table table-striped”> <thead> <tr> <td>ID</td> <td>Name</td> <td>Available Date</td> <td colspan = 2>Actions</td> </tr> </thead> <tbody id=”myTable”> @foreach($event_detail[‘participants’] as $participant) <tr> <td class=”can_filter”></td> <td class=”can_filter” onmouseover=”tooltip(this);”></td> <td class=”can_filter”></td> <td> <a href=”” class=”btn btn-primary”> Edit</a> </td> <td> <form action=”” method=”post”>…

Laravel routes condition based on which path, how to get the right path

My Routes: routes for different views Route::get(‘/participants’, ‘DatatablesController@getIndex’)->name(‘participants’); Route::get(‘/completed’, ‘DatatablesController@getIndex’)->name(‘completed’); Route::get(‘/failed’, ‘DatatablesController@getIndex’)->name(‘failed’); //route to get data to views Route::get(‘participants_dt’, ‘DatatablesController@getData’)->name(‘get.survey_requests’); Controller: public function getData() { $request = Request::path(); error_log($request); // $request returns participant_dt currently. I want it to return based on which view i’m on. if ($request == ‘participants’) { //return query } elseif ($request…

Laravel live video Streaming over the server

Hello I am new to socket programing in Laravel , I need to create a live streaming video in a project and I have tried “https://packagist.org/packages/php-junior/laravel-video-chat” this package. After configuring the package, The response show that app.js:42617 GET https://video.dev505.io:6001/socket.io/?EIO=3&transport=polling&t=MsbESOE net::ERR_CONNECTION_REFUSED over the time again and again. I searched on google and no proper guidance available…

I have a problem with an Ajax in Laravel?

I have a problem displaying elements of a <option> in the edit view I have a javascript code $(document).ready(function(){ $(‘select[name=”country_id”]’).on(‘change’,function(){ var country_id = $(this).val(); if(country_id) { $.ajax({ url: “edit/getStates/”+country_id, type: ‘GET’, dataType: ‘json’, success: function(data){ console.log(data); $(‘select[name=”state_id”]’).empty(); $.each(data, function(key, value){ $(‘select[name=”state_id”]’) .append(‘<option value=”‘+key+'”>’ + value + ‘</option>’); }); } }); } else { $(‘select[name=”state_id”]’).empty(); }…