Search
 
SCRIPT & CODE EXAMPLE
 

PHP

laravel sharing 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 :: laravel permission 
Php :: wordpress args 
Php :: php flip array 
Php :: php - = 
Php :: laravel 9 route group 
Php :: php exit 
Php :: wordpress options 
Php :: how to save multiple records in database using laravel 
Php :: array_unshift 
Php :: sass download for windows 
Php :: php preg replace 
Php :: php kommentar 
Php :: transforming string to integer in php 
Php :: inverse hyperbolic cosine php 
Php :: in arrray php 
Php :: php get country code from country name 
Php :: epoch conversion php 
Php :: creating default object from empty value laravel 
Php :: how to get stripe processing fees api 
Php :: php get duplicate keys in array without using inbuilt function 
Php :: wp_register_script 
Php :: carbon date time laravel 
Php :: php refresh page without reloading 
Php :: How to Get Radio Button Value in PHP Without Submit 
Php :: SUM with Eloquent 
Php :: php header content type json 
Php :: macrotime phph 
Php :: wordpress highlight text excerpt 
Php :: Toaster switch Statement 
Php :: extract in php 
ADD CONTENT
Topic
Content
Source link
Name
6+6 =