Search
 
SCRIPT & CODE EXAMPLE
 

PHP

add data one to many laravel

$employee = employee::find(1);

$salary1 = new Salary;
$salary->amount = '123456789';
$salary->payment_date = '15/07/2020';

$salary2 = new Salary;
$salary->amount = '123456789';
$salary->payment_date = '16/07/2020';

$employee = $employee->salary()->saveMany([$salary1, $salary2]);
Comment

laravel add many to many

You should pass an array of user IDs to the attach() method.

For convenience, attach and detach also accept arrays of IDs as input

Change your code to:

$team = AppTeam::findOrFail($request->team_id);
$team->teamMembers()->attach($request->members_id);
Comment

PREVIOUS NEXT
Code Example
Php :: financial year calculation in php 
Php :: php.validate.executablepath docker 
Php :: Unable to do sum and getting same value by using while loop php 
Php :: How to remove from a multidimensional array all duplicate elements including the original 
Php :: how to enable auto refresh on save 
Php :: Laravel Google Line Chart 
Php :: how get some parameter from request in laravel 
Php :: laravel collection shift 
Php :: drupal form show description 
Php :: PHP Iterables 
Php :: return pdft download and back with msg in laravel 
Php :: get the user detail inside the constructor Laravel 
Php :: while loop laravel 
Php :: wp add_action 
Php :: Update Data Multiple Columns MySql Database Table PHP Function 
Php :: send image in request body laravel 6 
Php :: laravel pluck multiple columns 
Php :: routing with php 
Php :: php += 
Php :: how to create route in laravel 
Php :: how to update a table based on three columns laravel 
Php :: laravel print builder 
Php :: magento check which user has added a product 
Php :: assert symfony 
Php :: spatie/laravel-activitylog display only changed data 
Php :: php loopthrough object 
Php :: how to make a variable in php 
Php :: Code to check Check whether a year is leap year or not 
Php :: php ?? vs ?: 
Php :: with relation laravel 
ADD CONTENT
Topic
Content
Source link
Name
9+8 =