Search
 
SCRIPT & CODE EXAMPLE
 

PHP

laravel copy row

 
//contact_ids is ['10','11',''12], i mean multiple value;contact_ids data type is json so that we will use json_decode()

$sharedContact = SharedContact::all();
$contacts = Contact::whereIn('id',json_decode($sharedContact->contact_ids))->get();

            foreach ($contacts as $contact){
				// copying the old record
                $sharedContact = $contact->replicate();
                
				//change name for image and saving in local storage
                $newName = 'share_'.time().'_'.$contact->photo;
                $newPathWithName = 'public/photo/'.$newName;
                
                if (Storage::copy('public/photo/'.$contact->photo , $newPathWithName)) {
//                    dd("success");
                    $sharedContact->photo = $newName;
                    $sharedContact->user_id = Auth::id();
                    $result = $sharedContact->save();
                }
                dd($result);
                
            }
Comment

PREVIOUS NEXT
Code Example
Php :: laravel multiple copy record 
Php :: laravel copy image with new name 
Php :: carbon if date is today 
Php :: naming the routes in laravel 
Php :: wp plugin create 
Php :: Hide Add to cart button on specific products 
Php :: array to comma separated string php 
Php :: construct php 
Php :: return json in php 
Php :: php switch case greater than 
Php :: php call method from another class 
Php :: not equal in laravel blade 
Php :: laravel rule unique where 
Php :: laravel-enum 
Php :: laravel belongstomany prevent duplicates attach 
Php :: get_the_terms 
Php :: how to create php message 3 
Php :: how do i know if file is empty in php 
Php :: php my admin on linux 
Php :: woocommerce my account php code wordpress 
Php :: download npm package 
Php :: post format wordpress 
Php :: laravel check if environment is production 
Php :: laravel filter array 
Php :: laravel one command for model table and controller 
Php :: naming convention for magento2 custom cms page index xml file 
Php :: yii2 sendemail extension 
Php :: explode (PHP 4, PHP 5, PHP 7, PHP 8) explode — Split a string by a string 
Php :: spatie laravel pdf image 
Php :: install spatie for role and permissions 
ADD CONTENT
Topic
Content
Source link
Name
3+1 =