Search
 
SCRIPT & CODE EXAMPLE
 

PHP

laravel sharing image

 
//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 copy data 
Php :: php insert to mysql 
Php :: wordpress args 
Php :: php null coalesce 
Php :: php json_encode float 
Php :: wp_customize image 
Php :: laravel function 
Php :: php generate unique id for word 
Php :: Creating (Declaring) PHP Variables 
Php :: array shift php 
Php :: executar comando linux php 
Php :: signup api in laravel 
Php :: php get html tags from string 
Php :: foreach sort orderby php 
Php :: remove last comma php 
Php :: How do i multiple variables in php 
Php :: laravel array search blade 
Php :: ::latest() 
Php :: wordpress login user programmatically 
Php :: check if custom post type exists 
Php :: laravel get from model 
Php :: laravel mailable from 
Php :: in date function + 1 month and - 1 day in php 
Php :: laravel db query log string replacements 
Php :: how check the time of operation in laravel 
Php :: seo_url.php location opencart 
Php :: Regex to remove span tags using php [duplicate] 
Php :: PHP OOP - Destructor 
Php :: laravel event listener 
Php :: laravel custom validation 
ADD CONTENT
Topic
Content
Source link
Name
2+6 =