Category : arrays

im facing an issue to retrive an array from my database and display it on my blade. So to understand my work, im actualy saving "Cart" informations on my "Orders Table" with Serialize the Products public function store(Request $request) { $order = new Order(); $order->user_id = request(‘user_id’); $order->wilaya = request(‘wilaya’); $order->province = request(‘province’); $order->address = ..

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 am attempting to make an array: foreach ($cats as $cat) { $catsList[$cat->id] = [$cat->info => $cat->info]; } What i get is a resulting array that only contains the last $cat info. array:2 [▼ 10 => array:1 [▼ 23 => 23 ] 9 => array:1 [▼ 11 => 11 ] ] What i expect to ..

Read more

I am a newbie in Laravel and I need your help. I trying to use updateOrCreate in the update function but it doesn’t work and no error. I have 3 models they are Sales Team class SalesTeam extends Model { public function salesTeamLeaders(){ return $this->belongsToMany(SalesTeamleader::class); } public function salesTeamMember(){ return $this->belongsToMany(SalesTeamMember::class); } public function users(){ ..

Read more

i have following an array. { "data": [ { "filename": "http: //asd/community/images/25-b5960859c2a24e5a8ab87bc0a7b29918_101.jpg" }, { "filename": "http: //asd/community/images/25-b5960859c2a24e5a8ab87bc0a7b29918_102.jpg" }, { "filename": "http: //asd/community/images/25-b5960859c2a24e5a8ab87bc0a7b29918_103.jpg" } ], "video": [ { "url": "http: //asd/resources/1272681135.mp4" }, { "url": "http: //asd/resources/1272681140.mp4" } ], "data": [ { "filename": "http: //asd/community/images/25-b5960859c2a24e5a8ab87bc0a7b29918_104.jpg" }, { "filename": "http: //asd/community/images/25-b5960859c2a24e5a8ab87bc0a7b29918_105.jpg" }, { "filename": "http: //asd/community/images/25-b5960859c2a24e5a8ab87bc0a7b29918_106.jpg" } ], ..

Read more

iam passing value 228 to a function in $admin_id public function indexAll($admin_id) { $getids = User::where(‘ot_of’, $admin_id)->pluck(‘id’)->toArray(); $ids = array_merge($subadmin_id , $getids); dd($ids); } and in $getids have data like this array:2 [▼ 0 => 565 1 => 823 ] but in $ids my result is null any help would be thankfull. Sourc..

Read more

I’m new in laravel and I’m trying to merge or join to arrays in one array, which have a one-to-many relationship. These are the models: class GroupMenu extends Model { public function optionmenu() { return $this->hasMany(OptionMenu::class, ‘groupmenu_id’); } } class OptionMenu extends Model { public function groupmenu() { return $this->belongsTo(GroupMenu::class, ‘groupmenu_id’); } } Also I ..

Read more

Structure "expenses_column": { "28": { "name": "account.payroll" }, "36": { "name": "account.marketing_and_distribution" }, "29": { "name": "account.general" }, } How could I make it "expenses_column": [ "28": { "name": "account.payroll" }, "36": { "name": "account.marketing_and_distribution" }, "29": { "name": "account.general" }, ] The response structure is a JSON format however my code structure already is ..

Read more

I’m trying to build the following query Model::where(‘id’,$id)->groupBy(‘type’)->get(); I get the following error: SELECT list is not in GROUP BY clause and contains nonaggregated column ‘db.table.id’ which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group This is the result without group by, i’m trying to group by type ..

Read more

I want to get the unique vaule of geography,customer_code and account_manager from the array Array ( [0] => Array ( [AccountManager] => jigar.lohia [AccountManagerStringID] => USER6041 [Age] => 40 [Aging] => 31 to 60 [Amount] => 38403 [CurrencySymbol] => USD [CustomerCode] => UAE_0068 [CustomerName] => Abu Dhabi National Insurance Company (ADNIC) PJSC, [Date] => 3/11/2020 ..

Read more