Search
 
SCRIPT & CODE EXAMPLE
 

PHP

laravel copy data

 
//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 :: php apns notification source code 
Php :: position for ip 
Php :: how to create resource controller in laravel 
Php :: PHP MySQL Insert Multiple Records 
Php :: laravel get route path uri 
Php :: laravel 9 route group 
Php :: Method IlluminateDatabaseEloquentCollection::delete does not exist. 
Php :: laravel model factory attribute 
Php :: add custom shortcode in contact form 7 
Php :: wp_query first post 
Php :: wordpress add shortcode with parameters 
Php :: preg_split in php 
Php :: inplode php 
Php :: how to add multiple images in php 
Php :: sort by number of views descending laravel 
Php :: magento 1.9 get all product 
Php :: laravel manually authenticate user 
Php :: how to know if file is empty in php 
::  
Php ::  
Php :: laravel edit form modal example 
Php :: how remove column in migration laravel 
Php :: Parse error: syntax error, unexpected token "{" in C:xampphtdocsloginsystem1welcome.php on line 3 
Php :: php xml parser 
Php :: get all taxonomy name wordpress 
Php :: Add Text After or Before on the Shop Page/Archive Page 
Php :: limit query codeiniter 3 
:: Laravel SPA cors 
Php :: codeigniter 4 radio button isset 
Php :: laravel hash password sample 
ADD CONTENT
Topic
Content
Source link
Name
4+1 =