Category : database

I create new command in laravel: public function handle() { $serversList = [ ‘cubegame.pl’, ‘feerko.pl’, ‘skyup.pl’, ‘mcosada.pl’, ‘dragon-craft.pl’, ‘gc2.pl’, ‘mc.craftplay.pl’, ‘iskyblock.pl:25600’, ‘mc.craftmc.pl’, ‘mc.realcraft.pl’, ‘katomc.pl’, ‘mc.minestar.pl’, ]; foreach ($serversList as $server) { $req = Http::get("https://api.mcsrvstat.us/2/$server"); if ($req->ok()) { $status = $req->json(); // dump($status[‘motd’][‘html’][0]); $serv = Server::updateOrCreate( [ ‘name’ => $server, ‘ip’ => $status[‘ip’] ], [ ‘motd’ ..

Read more

Whenever I try to update the record in laravel in 8.2.1 version this error (POST http://127.0.0.1:8000/add-student 500 (Internal Server Error) ) comes to me and when i see in console it says ( xhr.send( ( options.hasContent && options.data ) || null ); ) two picture are also attached 1. My Code in inside.blade.ph and second ..

Read more

$products = product::select([ DB::raw(‘product_no as number’), DB::raw(‘product_name as name’), DB::raw(‘sum(total) as total’), DB::raw(‘sum(product_qty) as qty’), DB::raw(‘sum(product_price) as price’), ]) ->groupBy(‘number’) ->groupBy(‘name’) ->get(); return view (‘view’,[‘products’=>$products]); i need to insert the result to another table in database by laravel Sourc..

Read more

I’m working on SQL. My database has so many entry that reason query taking too time any solution to improve my query perfoment. I’m use many groupBy And Sum of value. My Query :- select distinct airplay_songs.song_uuid, airplay_songs.song_isrc, sum(airplay_songs.play_count) as play_count from artist_music inner join airplay_songs on artist_music.uuid = airplay_songs.song_uuid and artist_music.isrc = airplay_songs.song_isrc where ..

Read more

I have this Controller called GetChangeInfo public function GetChangeInfo(Request $request){ $customers = Customer::doesntHave(‘bookings’) ->doesntHave(‘product_baskets’) ->whereRaw("CONCAT(customers.id, COALESCE(customers.first_name, ”), ‘ ‘, COALESCE(customers.last_name, ”), ‘ ‘, COALESCE(customers.email, ”), ‘ ‘, COALESCE(customers.phone, ”), ) LIKE ?", ["%{$request->find}%"] ) ->orderBy(‘id’, ‘desc’) ->paginate(10); return response()->json($customers); } I want to insert customers.pending_update_info, 1 this code inside in whereRaw whenever i insert that ..

Read more

$personalSale = DB::select(DB::raw("SELECT * FROM purchases a WHERE a.purchase_status IN (3001,3002,3003,4000,4001,4002,4003) AND a.purchase_date LIKE "%12/2020" AND (a.user_id = 50 OR a.user_id in (SELECT b.user_id FROM user_infos b WHERE b.referrer_id = 1911000140)) ORDER BY a.purchase_amount DESC LIMIT 10; ")); error: syntax error, unexpected ‘" AND ‘ (T_CONSTANT_ENCAPSED_STRING), expecting ‘,’ or ‘)’ Sourc..

Read more

so I have table in sql with 20 columns and I need one column to get the sum of other two columns, the data is showing in modal-fade dialog this is how it look like div id="show" class="modal fade" role="dialog"> <div class="modal-dialog modal-sm"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal">&times;</button> <h4 class="modal-title"></h4> </div> <div ..

Read more

this datasbe tables for example This is my Controller $categoryIds = Category::select(‘id’)->with(‘childrenRecursive’)->where(‘id’, 1)->get(); Ad::whereIn(‘category_id’, $categoryIds)->get(); This is my model public function parent() { return $this->belongsTo(Category::class, ‘parent_id’); } public function childs() { return $this->hasMany(Category::class, ‘parent_id’); } public function Ads() { return $this->hasManyThrough(Ad::class, Category::class, ‘parent_id’, ‘category_id’, ‘id’); } Have you any ida ?!! Sourc..

Read more

I would like to display the name of each entity in my table but it returns me Property [name] does not exist on this collection instance. My Controller $users = User::with(‘pearls’)->latest()->get(); the index.blade.php <thead> <tr> <th scope="col">SL No</th> <th scope="col">Name</th> <th scope="col">Email</th> @foreach($users as $user) <th>{{ $user->pearls->name}}</th> @endforeach <th scope="col">Actions</th> </tr> </thead> Sourc..

Read more

I need to insert array data into the 2 tables. My table structure and form structure are given below. Please check and help me to insert data. Getting an error in the browser My Controller public function prtmulti(Request $req) { $maxPrId = newpr::max(‘prid’); $requestData = $req->all(); if(array_key_exists("vendor_name",$requestData)) { $insertData = []; $uniqueData =array_unique($requestData["vendor_name"]); foreach ($uniqueData ..

Read more

I’m trying to filter a query on a model that has a one to many relationship, but it’s not working. Correct output should remove all stocks that are expired, but it returns all the available stocks. Product: hasMany(Stock::class) Stock: belongsTo(Product::class) code: $keyword = $request->keyword; $data = Product::with(‘stocks’) ->where([ [‘pharmacy_id’, ‘=’, auth()->user()->pharmacy->id], ]) ->where(function($productModel) use($keyword) { ..

Read more

We try to achieve an AdminCMS coupon functionality with multiple, dynamic coupon rule base on products, its categories & sub-categories, users, seller, cart, and related database table columns and data value. We have created an e-commerce website where a user can buy products from the website, but in the cart order process, there’s a process ..

Read more

The following is a MySQL query. I know it is wrong because the EXTRA column cannot be used in the query. SELECT users.id, user_time.*, CONCAT(users.info1, users.info2) AS EXTRA FROM users JOIN user_time ON users.id = user_time.user_id WHERE EXTRA ="ABCDEFG"; But isn’t it possible to use this EXTRA column in Laravel? Something like… $table = User::join(‘user_time’,’user_time.user_id’,’users.id’)->select(‘users.id’,’user_time.*’,DB::raw("CONCAT(users.info1, ..

Read more

I’m using laravel 8 and I try to update data but it won’t save, and it really strange Here’s the controller private function _generatePaymentToken($kode) { $this->initPaymentGateway(); $pnd = new Pendaftar; $pnd = $pnd::where(‘nohp’, $kode)->get(); if($pnd->count()){ $customerDetails = [ ‘first_name’ => $pnd[0]->nama, ‘last_name’ => $pnd[0]->nama, ’email’ => $pnd[0]->email, ‘phone’ => $pnd[0]->nohp, ]; $params = [ ‘transaction_details’ ..

Read more