Laravel always gets empty from JSON post

I’m working on Laravel version 5.2. I’ve been trying to get json data from post. I always get empty data. I also have tried to use solutions found on the internet but there’s nothing works. for example, $request->json()->all(); Input::get(‘data’); $request->get(‘data’); $request->data; Input::all(); json_decode(request()->getContent(), true); json_decode($request->getContent(), true); json_decode(request()->get(‘payload’)); json_decode($request->get(‘payload’)); $request->input(‘data’); Here is my javascript code, $.ajax({…

Can’t retrieve the data from database in laravel

I have the controller with function public function caritiket(Request $request){ $tgl=($request->tgl); $kota1 = ($request->kota1); $kota2 = ($request->kota2); $jumlah = (int)$request->jml_p; // $cek = DB::table(‘tb_bis_wp’)->where(‘tanggal’,$request->tgl)->where(‘kota1’,$request->kota1)->where(‘kota2’,$request->kota2)->count(); // if ($cek > 0) { $cek1 = DB::table(‘tb_bis_wp’)->where(‘tanggal’,$request->tgl)->where(‘kota1’,$request->kota1)->where(‘kota2’,$request->kota2)->get(); foreach ($cek1 as $cek1) { $a=$cek1->tanggal; $b=$cek1->kota1; $c=$cek1->kota2; } return redirect(‘/tampil/daftartiket////’);} the input from view is already have the same name as…

Laravel 6: db:seed multiple seeding in user

I have following factories and seeders. Factories UserFactory.php ThreadFactory.php ReplyFactory.php Seeders UsersTableSeeder.php ThreadTableSeeder.php RepliesTableSeeder.php UserFactory.php $factory->define(App\User::class, function (Faker $faker) { return [ ‘name’ => $faker->name, ’email’ => $faker->unique()->safeEmail, ’email_verified_at’ => now(), ‘password’ => ‘$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi’, // password ‘remember_token’ => Str::random(10), ]; }); ThreadFactory.php $factory->define(App\Thread::class, function (Faker $faker) { return [ ‘user_id’ => function() { return factory(App\User::class)->create()->id;…

can data in variables may leak? Laravel

I’m working on referrals project and my test function looks like this (to check referred users): $referrals = auth::user()->referrals; echo $referrals; The output of the following is like this: [{“id”:2,”name”:”XYZ”,”email”:”abc@def.com”,”is_subscribed”:”0″,”is_referrer”:”0″,”created_at”:”Time here”,”referred_by”:”1″}] and in controller: $referrals = auth::user()->referrals; $host = request()->getHost(); $Link = $host.’?ref=’.\Hashids::encode(auth()->user()->id); foreach ($referrals as $users){ return view(‘dashboard’, compact(‘users’, ‘Link’)); } All is working…

Babel error: Module build fails when I try to compile my front-end assets with Laravel Mix

I’ve been struggling with this error for a while and I went over different solutions on here as well as Git but just can’t seem to get it working. Error: Module build failed: this.setDynamic is not a function These are the Babel dependencies I have in my package.json file: “dependencies”: { “@babel/core”: “^7.6.4”, “babel-core”: “^7.0.0-bridge.0”,…

How to print value in blade from $lookup in laravel

I have two collections in MongoDB I want to aggregation between them, it worked fine but I don’t know how to print the value in the blade(view) of levels that’s come from other collection? $allRanges = Range::raw(( function($collection) { return $collection->aggregate([ [ ‘$lookup’ => [ ‘from’ => ‘Levels’, ‘localField’ => ‘LevelId’, ‘foreignField’=> ‘_id’, ‘as’ =>…

How to use eloquent on the auth command user in laravel

I am facing a weird error right now In my controller, when I import the class user like this use Illuminate\Foundation\Auth\User; It works when I use eloquent like public function index() { $farms = User::where(‘role_id’, 3)->get(); $user = Auth::user(); $animal = Animal::all(); return view(‘clinic.index’, compact(‘user’, ‘animal’, ‘farms’)); } But refuses to work when it comes…