like and unlike with javascript and Laravel

I’m trying to implement a functionality where user can like and unlike product using javascript I followed this Laravel – Favourite / Un-Favourite button but it doesn’t work for me, the button can’t be clicked, any idea on how I can fix this? Routes Route::get(‘product/like/{id}’, [‘as’ => ‘product.like’, ‘uses’ => ‘LikeController@likeProduct’]); Route::get(‘product/{product}/unlike’,’LikeController@destroy’)->name(‘product.unlike’); Javascript <script> function…

Laravel api search function with multiple params

I almost read all article in google and posts in stackoverflow, but I couldn’t find the right solution or I don’t get it. anyway, I want to make a search function in Laravel API, so I started with: public function search(Request $request) { $data = $request->get(‘data’); $search = Post::where(‘title’, ‘like’, “%{$data}%”) ->orWhere(‘user_id’, ‘like’, “%{$data}%”) ->get();…

Laravel elequent join query

I have two table rounds and assignments. Its corresponding models are Assignment and Round. Assignment Have relation to round is public function round() { return $this->belongsTo(Round::class, ’round_id’); } assignment have reference key as round_id. I want to get all assignments have the round_id. $assignments = Assignment::find(1)->round()->where(‘start_date’, ‘<=’, $now) ->where(‘end_date’, ‘>=’, $now) ->where(’round_type’, ‘=’, ‘judge’) ->get();

Undefined variable: in laravel 6

I am trying to Display data on Laravel view page from database. but it shows nothing to me this is the code on .blade.php file:- <tbody> @if(isset($Us)) @foreach($Us as $row) <tr> <td></td> <td></td> <td></td> </tr> @endforeach @endif </tbody> </table> Code on AdminController.php: public function index() { $Us = users::all()->toArray(); return view(‘master’)->with([‘Us’=> $Us]); } and on…