Search
 
SCRIPT & CODE EXAMPLE
 

PHP

laravel sharing record

 
//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 :: wordpress popular posts query 
Php :: laravel copy data 
Php :: laravel permission 
Php :: how to search like in php 
Php :: php flatten array 
Php :: publish spatie 
Php :: laravel carbon date format 
Php :: php extract number from string without comma 
Php :: add phpmyadmin login linux 
Php :: constants in php 
Php :: wc get product category image 
Php :: how to install apache mysql php on ubuntu 18.04 
Php :: how to declare global variable in laravel controller 
Php :: convert collection to array laravel 
Php :: php sort time 
Php :: file upload in laravel 
Php :: laravel datatable render html 
Php :: CHECKING IF FILE IS EMPTY IN PHP 
Php :: add action hook 
Php :: multe data on database laravel 
Php :: resize image using intervention laravel and save 
Php :: asset function in laravel not working 
Php :: PHP temporary files 
Php :: get page templete 
Php :: what is cors in laravel 
Php :: license_verify 
Php :: cf7 remove p tags 
Php :: get dates between two dates using specific interval using carbon 
Php :: multiple ternary operator in php 
Php :: get 1 data from get laravel 
ADD CONTENT
Topic
Content
Source link
Name
2+6 =