Ap3twe

Ap3twe

Member Since 1 Year Ago

Canada

Experience Points
20,060
Total
Experience

4,940 experience to go until the next level!

In case you were wondering, you earn Laracasts experience when you:

  • Complete a lesson — 100pts
  • Create a forum thread — 50pts
  • Reply to a thread — 10pts
  • Leave a reply that is liked — 50pts
  • Receive a "Best Reply" award — 500pts
Lessons Completed
126
Lessons
Completed
Best Reply Awards
2
Best Reply
Awards
  • start your engines Created with Sketch.

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • first-thousand Created with Sketch.

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • 1-year Created with Sketch.

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • 2-years Created with Sketch.

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • 3-years Created with Sketch.

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • 4-years Created with Sketch.

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • 5-years Created with Sketch.

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • school-in-session Created with Sketch.

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • welcome-newcomer Created with Sketch.

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • full-time-student Created with Sketch.

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • pay-it-forward Created with Sketch.

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • subscriber Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • evangelist Created with Sketch.

    Laracasts Evangelist

    Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.

  • chatty-cathy Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

Level 5
20,060 XP
Oct
19
1 week ago
Activity icon

Started a new Conversation Help Out With File Upload To S3

Can anyone help me to refactor my code to match the second code? The problem I have is I changed the method to use the AWS S3multipart upload and am not able to put the file in the subfolder of the bucket. All files are uploaded at the root level and I can't create subfolders because of how the AWS multipart code is structured.

What I tried is appending "\subfolder" to the 'bucket' => $_ENV['AWS_BUCKET'], but definitely, it did not work.


           if ($request->hasFile('files_doctor')) {
                    $patientFirstName = $request->patient_firstname;
                    $patientLastName = $request->patient_lastname;

                    //   Users name adding
                    $caseDir = auth()->user()->drname;
                    $caseDir = str_replace(' ', '', $caseDir);
                    $path = public_path('storage/uploads/chromedoctorefiles/'. $caseDir);

                    foreach ($request->file('files_doctor') as $s3file) {
                    $directory  = 'Case/'. $caseDir;
                    $contents = fopen($s3file, 'rb');
                    $s3patientFirstName = $request->patient_firstname;
                    $s3patientLastName = $request->patient_lastname;
                    $s3SavedOrigName = $s3file->getClientOriginalName();
                    $SendFileToS3 = $s3patientFirstName . '_' . $s3patientLastName . '_' . time() . $s3SavedOrigName;
                    // $disk = Storage::disk('s3');
                    $s3 = new S3Client([
                        'version' => 'latest',
                        'region'  => 'us-west-1'
                    ]);
                    $uploader = new MultipartUploader($s3, $contents, [
                        'bucket' => $_ENV['AWS_BUCKET'],
                        'key'    => $SendFileToS3,
                    ]);

                    try {
                        $result = $uploader->upload();
                        
                    } catch (MultipartUploadException $e) {
                        return $e->getMessage();
                    }
                    
                }
                ```

Second Code 

              if ($request->hasFile('files_doctor')) {
                $patientFirstName = $request->patient_firstname;
                $patientLastName = $request->patient_lastname;

                //   Users name adding
                $caseDir = auth()->user()->drname;
                $caseDir = str_replace(' ', '', $caseDir);
                $path = public_path('storage/uploads/chromedoctorefiles/'. $caseDir);

           // Amazon checking folder 
           $directory  = 'Case/'. $caseDir;       

            foreach ($request->file('fileslab') as $s3file) {
            // Getting request names & extension
            $s3patientFirstName = $request->patient_firstname;
            $s3patientLastName = $request->patient_lastname;
            $s3SavedOrigName = $s3file->getClientOriginalName();
            $SendFileToS3 = $s3patientFirstName . '_' . $s3patientLastName . '_' . time() . $s3SavedOrigName;
           $contents = file_get_contents($dbfile->getRealPath());
            $path = Storage::disk('s3')->put($directory. '/' .$SendFileToS3, $contents);

            if (!Storage::disk('s3')->exists($directory)){
                Storage::disk('s3')->makeDirectory($directory);
                $path = Storage::disk('s3')->put( $directory. '/' .  $SendFileToS3, $contents );
            
            }else{
                 $path = Storage::disk('s3')->put( $directory. '/' .$SendFileToS3, $contents);
            }
        }
Oct
02
4 weeks ago
Activity icon

Started a new Conversation IAM User Permissions Problem

Has anyone encountered the situation when I use manage policies on a user, It works but when I use inline policy it gives access denied. I am giving Read access to a bucket for IAM user that is it can only access that bucket.

Manage Policy

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "s3:Get*",
                "s3:List*"
            ],
            "Resource": "*"
        }
    ]
}

Inline Policy

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "s3:Get*",
                "s3:List*"
            ],
            "Resource": "arn:aws:s3:::mybucketname/*"
        }
    ]
}

I also tried this

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "S3Permissions",
      "Action": "s3:*",
      "Effect": "Allow",
      "Resource": [
        "arn:aws:s3:::mybucketname/*",
        "arn:aws:s3:::mybucketname"
      ]
    }
  ]
}
Sep
28
1 month ago
Activity icon

Awarded Best Reply on Refactor S3 File Upload To Multipart Upload

Got it working.

foreach ($request->file('fileslab') as $s3file) {
            
                $contents = fopen($s3file, 'rb');
                $s3patientFirstName = $request->patient_firstname;
                $s3patientLastName = $request->patient_lastname;
                $s3SavedOrigName = $s3file->getClientOriginalName();
                $SendFileToS3 = $s3patientFirstName . '_' . $s3patientLastName . '_' . time() . $s3SavedOrigName;
                $disk = Storage::disk('s3');
                $s3 = new S3Client([
                    'version' => 'latest',
                    'region'  => 'us-west-1'
                ]);
                $uploader = new MultipartUploader($s3, $contents, [
                    'bucket' => $_ENV['AWS_BUCKET'],
                    'key'    => $SendFileToS3,
                ]);
    
                try {
                    $result = $uploader->upload();
                   
                } catch (MultipartUploadException $e) {
                    return $e->getMessage();
                }
                
            }
Activity icon

Replied to Refactor S3 File Upload To Multipart Upload

Got it working.

foreach ($request->file('fileslab') as $s3file) {
            
                $contents = fopen($s3file, 'rb');
                $s3patientFirstName = $request->patient_firstname;
                $s3patientLastName = $request->patient_lastname;
                $s3SavedOrigName = $s3file->getClientOriginalName();
                $SendFileToS3 = $s3patientFirstName . '_' . $s3patientLastName . '_' . time() . $s3SavedOrigName;
                $disk = Storage::disk('s3');
                $s3 = new S3Client([
                    'version' => 'latest',
                    'region'  => 'us-west-1'
                ]);
                $uploader = new MultipartUploader($s3, $contents, [
                    'bucket' => $_ENV['AWS_BUCKET'],
                    'key'    => $SendFileToS3,
                ]);
    
                try {
                    $result = $uploader->upload();
                   
                } catch (MultipartUploadException $e) {
                    return $e->getMessage();
                }
                
            }
Activity icon

Replied to Refactor S3 File Upload To Multipart Upload

I tweak a lil bit and get error getDriver() not found

 foreach ($request->file('fileslab') as $dbfile) {
                $contents = file_get_contents($dbfile->getRealPath());
                $disk = Storage::disk('s3');
                $s3 = new S3Client([
                    'version' => 'latest',
                    'region'  => 'us-west-1'
                ]);
                $uploader = new MultipartUploader($s3->getDriver()->getAdapter()->getClient(), $contents, [
                    'bucket' => $_ENV['AWS_BUCKET'],
                    'key'    => $_ENV['AWS_ACCESS_KEY_ID'],
                ]);
    
                try {
                    $result = $uploader->upload();
                    echo "Upload complete";
                } catch (MultipartUploadException $e) {
                    echo $e->getMessage();
                }
                
            }
Activity icon

Replied to Refactor S3 File Upload To Multipart Upload

This is what I tried, I get error unable to open PK with a bunch of binary codes and the page stuck in loop

 foreach ($request->file('fileslab') as $dbfile) {
                $contents = file_get_contents($dbfile->getRealPath());
                $disk = Storage::disk('s3');
                $uploader = new MultipartUploader($disk->getDriver()->getAdapter()->getClient(), $contents, [
                    'bucket' => $_ENV['AWS_BUCKET'],
                    'key'    => $_ENV['AWS_ACCESS_KEY_ID'],
                ]);
    
                try {
                    $result = $uploader->upload();
                    echo "Upload complete";
                } catch (MultipartUploadException $e) {
                    echo $e->getMessage();
                }
                
            }
            
Activity icon

Replied to Refactor S3 File Upload To Multipart Upload

I have read it just can't seem how to implement it. I have completed the lifecycle. if someone can provide sample code for me, I will appreciate

Activity icon

Started a new Conversation Refactor S3 File Upload To Multipart Upload

Here is my code, how do I integrate the multipart upload of s3? I am uploading to s3 and everything works. just I want to refactor the code to S3 multipart upload because the files are too large on the server


            //    Amazon checking folder 
            $directory  = 'Case/'. $caseDir;           
            foreach ($request->file('fileslab') as $s3file) {
                // Getting request names & extension
                $s3patientFirstName = $request->patient_firstname;
                $s3patientLastName = $request->patient_lastname;
                $s3SavedOrigName = $s3file->getClientOriginalName();
                $SendFileToS3 = $s3patientFirstName . '_' . $s3patientLastName . '_' . time() . $s3SavedOrigName;
            $contents = file_get_contents($dbfile->getRealPath());
            $path = Storage::disk('s3')->put($directory. '/' .$SendFileToS3, $contents);

                if (!Storage::disk('s3')->exists($directory)){
                    Storage::disk('s3')->makeDirectory($directory);
                    $path = Storage::disk('s3')->put( $directory. '/' .  $SendFileToS3, $contents );
                
                }else{
                     $path = Storage::disk('s3')->put( $directory. '/' .$SendFileToS3, $contents);
                }
            }

The example on Amazon sdk is

 require 'vendor/autoload.php';

use Aws\Common\Exception\MultipartUploadException;
use Aws\S3\MultipartUploader;
use Aws\S3\S3Client;

$bucket = '*** Your Bucket Name ***';
$keyname = '*** Your Object Key ***';
                        
$s3 = new S3Client([
    'version' => 'latest',
    'region'  => 'us-east-1'
]);
 
// Prepare the upload parameters.
$uploader = new MultipartUploader($s3, '/path/to/large/file.zip', [
    'bucket' => $bucket,
    'key'    => $keyname
]);

// Perform the upload.
try {
    $result = $uploader->upload();
    echo "Upload complete: {$result['ObjectURL']}" . PHP_EOL;
} catch (MultipartUploadException $e) {
    echo $e->getMessage() . PHP_EOL;
}
Sep
25
1 month ago
Activity icon

Replied to PHP Best Setting For 1gb File Upload..

I am using dropbox. Do you know of any?

Activity icon

Replied to XML Array

Sorry, I didn't find anything relatable. My only concern is send array of the products

Activity icon

Started a new Conversation PHP Best Setting For 1gb File Upload..

We are implementing upload of files upwards of 1gb. What will be the best settings? Our server is dedicated servers no trouble of shared hosting arising. What will you suggest?

memory_limit max_input_time post_max_size upload_max_filesize

Activity icon

Started a new Conversation XML Array

Guys, can anyone show me how I can achieve an array of products based on XML WSDL structure below. It accepts an array of products. It accepst <s:element minOccurs="0" maxOccurs="1" name="Products" type="tns:ArrayOfDLCPMCaseProduct"/>

I tried this and I receive the first array.

Products' => array(
 'DLCPMCaseProduct' => array (
                         'ProductCode' => 'CIBGS',
                         'Description' => 'Money',
                         'Quantity' => '1',
                         'Price' =>  $GLOBALS['sum'],
                         ),
                         
 'DLCPMCaseProduct' => array (
                         'ProductCode' => 'CIBNS',
                         'Description' => 'Food',
                         'Quantity' => '1',
                         'Price' =>  $GLOBALS['sum'],
                         ),
                      ), 
<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/">
    <Body>
        <AddCase xmlns="http://tempuri.org/">
            <!-- Optional -->
            <addCaseReq>
                <!-- Optional -->
                <Auth>
                    <AppName>[string?]</AppName>
                    <DeveloperKey>[string?]</DeveloperKey>
                    <UserName>[string?]</UserName>
                    <Password>[string?]</Password>
                </Auth>
                <!-- Optional -->
                <DlcpmCase>
                    <CaseID>[string?]</CaseID>
                    <CaseNumber>[int]</CaseNumber>
                    <CustomerID>[string?]</CustomerID>
                    <PatientFirst>[string?]</PatientFirst>
                    <PatientLast>[string?]</PatientLast>
                    <LabName>[string?]</LabName>
                    <Shade>[string?]</Shade>
                    <RxNumber>[string?]</RxNumber>
                    <ShipDate>[dateTime]</ShipDate>
                    <DateIn>[dateTime]</DateIn>
                    <DueDate>[dateTime]</DueDate>
                    <DoctorName>[string?]</DoctorName>
                    <PracticeDoctorID>[string?]</PracticeDoctorID>
                    <PanNumber>[string?]</PanNumber>
                    <Carrier>[string?]</Carrier>
                    <CarrierServiceType>[string?]</CarrierServiceType>
                    <WebComments>[string?]</WebComments>
                    <WorkorderNotes>[string?]</WorkorderNotes>
                    <!-- Optional -->
                    <Products>
                        <!-- Optional -->
                        <DLCPMCaseProduct>
                            <CPID>[string?]</CPID>
                            <ProductCode>[string?]</ProductCode>
                            <Description>[string?]</Description>
                            <Quantity>[double]</Quantity>
                            <Price>[double]</Price>
                            <ToothStr>[string?]</ToothStr>
                            <ToothStr2>[string?]</ToothStr2>
                            <Shade>[string?]</Shade>
                        </DLCPMCaseProduct>
                    </Products>
                    <RemakeCaseID>[string?]</RemakeCaseID>
                    <LinkedToCaseID>[string?]</LinkedToCaseID>
                    <RxPreferences>[string?]</RxPreferences>
                    <DocumentsCount>[int]</DocumentsCount>
                    <RemoteCaseNumber>[int]</RemoteCaseNumber>
                    <DeliveryNotes>[string?]</DeliveryNotes>
                    <ShipCustomerID>[string?]</ShipCustomerID>
                    <DigitalScanner>[string?]</DigitalScanner>
                </DlcpmCase>
            </addCaseReq>
        </AddCase>
    </Body>
</Envelope>
Sep
24
1 month ago
Activity icon

Started a new Conversation How To Check Values From Request If They Match A Value?

In an event, I have two radio inputs with the same name case_type. I sent the values to DB like Single Case and Double Case. I would like to check if the user chose single or double then I will do some calculation later. First I can't give it separate names at the view because the logic is to choose one. That is how radio button works.

What I thought of doing is :

if ($request->has('case_type') == " Single Case"){
 // Do something
}
Sep
22
1 month ago
Activity icon

Replied to Laravel On VPS Server

Wow Flawless. thanks It works like charm

Activity icon

Replied to Laravel On VPS Server

Nice, do the files need to be moved out of the httpdocs to another folder after deployment. Do you also symlink the public folder outside the httpdocs?

Activity icon

Replied to Laravel On VPS Server

@geordiejackson Nice. Will give it a try. Do you know how to setup git credentials in the plesk panel. I cant see it. It just ask for the https link and it rejects it because of credentials

Activity icon

Started a new Conversation Laravel On VPS Server

Does anyone have experience deploying laravel app on VPS Server? We have our own sets of VPS Servers and I think it will serve us right to deploy our app there. I think going on AWS or forge is an extra kill. What do you think? Is the operation straightforward like shared hosting?

Activity icon

Replied to Uploading To Drobox

I will visit that tomorrow. I appreciate your help. Thank you. Coding is fun lol

Activity icon

Replied to Uploading To Drobox

BRO I GET Method Illuminate\Http\UploadedFile::copy does not exist. Why though?

What is the difference in laravel docs

The copy method may be used to copy an existing file to a new location on the disk, while the move method may be used to rename or move an existing file to a new location:

Activity icon

Replied to Uploading To Drobox

@laracoft It returns false. /private/var/tmp/ does not exist on dd($dbfile->getRealPath()); It exist when I dump on the request directly though. Is a permission problem I think too.

$filename = $dbfile->getRealPath();
var_dump("Temp filename is: ".$filename);
$filename = $dbfile->getRealPath();
var_dump("Temp filename is: ".$filename);
$contents = file_get_contents($filename); 

I have public_path helpers on my local storage.

This is my complete code if someone can spot it

//Local Storage
 if ($request->hasFile('fileslab')){
         $patientFirstName = $request->patient_firstname;
         $patientLastName = $request->patient_lastname;
         $data = array();
          foreach ($request->file('fileslab') as $file) {
           $FileOriginalExtension = $file->getClientOriginalExtension();
           $fileOriginalName = $file->getClientOriginalName();
         // adding extension and time to the file
             $fileNameToStore =  $fileOriginalName . '_'. $patientFirstName .'_' . $patientLastName . '_' . time().'.'. $FileOriginalExtension;
             $fileNameToSent =  $fileNameToStore;
         //   Users name adding
             $caseDir = auth()->user()->drname;
             $caseDir = str_replace(' ', '', $caseDir);
             $path = public_path('storage/uploads/chromelabfiles/'. $caseDir);
          
        
           if(!file_exists($path)){
             mkdir($path, 0777, true);
         }
           $file->move($path, $fileNameToSent);
           $data[] = $fileNameToSent;

        
        //    Dropbox

        $dbdirectory  = 'Apps/myprotecsenddigitalcase/'. $caseDir;           
        foreach ($request->file('fileslab') as $dbfile) {
           
            // Getting request names & extension
            $dbpatientFirstName = $request->patient_firstname;
            $dbpatientLastName = $request->patient_lastname;
            $dbSavedOrigName = $dbfile->getClientOriginalName();
            $SendFileTodb = $dbpatientFirstName . '_' . $dbpatientLastName . '_' . time() . '_' . $dbSavedOrigName;
            // $contents = \File::get($dbfile->getRealPath());
            $contents = file_get_contents($dbfile->getRealPath());
            $path = Storage::disk('dropbox')->put( $dbdirectory. '/' .$SendFileTodb, $contents);
            
            if (!Storage::disk('dropbox')->exists($dbdirectory)){
                Storage::disk('dropbox')->makeDirectory($dbdirectory);
                $path = Storage::disk('dropbox')->put( $dbdirectory. '/' .  $SendFileTodb, $contents );
              }else{
               $path = Storage::disk('dropbox')->put( $dbdirectory. '/' .$SendFileTodb, $contents);
              }
              
        }

        }
}

         $file = new Labchrome();
            $file->files = ($data);
   }
Sep
21
1 month ago
Activity icon

Replied to Uploading To Drobox

That was dd($request->file('fileslab'));

Activity icon

Replied to Uploading To Drobox

@laracoft Sorry, I realize the output earlier was on dd($request->file('fileslab'); I forgot to remove it before testing it. dd $contents = file_get_contents($dbfile->getRealPath()); is not catching exception. It outputs file_get_contents(): Filename cannot be empty

I tried $contents = ($dbfile->getRealPath()); dd($contents); it returned false

Activity icon

Replied to Uploading To Drobox

@davidjohan hey What is that? Are you serious?

Activity icon

Replied to Uploading To Drobox

Using $contents = file_get_contents($dbfile->getRealPath()); I get error

file_get_contents(): Filename cannot be empty

Then I add $contents = file_get_contents($SendFileTodb, $dbfile->getRealPath()); I get error

file_get_contents(NoCenterImage.jpg): failed to open stream: No such file or directory

If I use $contents = \File::get($dbfile->getRealPath()); I get error

File does not exist at path

then I tried $contents = \File::get($sendFileTodb, $dbfile->getRealPath()); I get error

File does not exist at path NoCenterImage.jpg

Activity icon

Replied to Uploading To Drobox

I imported use League\Flysystem\File , and got error Call to undefined method League\Flysystem\File::get()

isnit it deprecated?

Activity icon

Replied to Uploading To Drobox

Same problem. Every file I upload, the file is not readable. I don't think is getting file contents, do I have to add file_get_contents?

Activity icon

Started a new Conversation Uploading To Drobox

Guys, I am uploading files to dropbox. Files are sent, but are not readable? Am I doing anything wrong? I get the error in dropbox folder .jpg files are supported but something went wrong. Downloading the file can't be read too.

  $dbdirectory  = 'Apps/myprotecsenddigitalcase/'. $caseDir;           
        foreach ($request->file('fileslab') as $dbfile) {
            // Getting request names & extension
            $dbpatientFirstName = $request->patient_firstname;
            $dbpatientLastName = $request->patient_lastname;
            $dbSavedOrigName = $dbfile->getClientOriginalName();
            $SendFileTodb = $dbpatientFirstName . '_' . $dbpatientLastName . '_' . time() . '_' . $dbSavedOrigName;
            
            if (!Storage::disk('dropbox')->exists($dbdirectory)){
                Storage::disk('dropbox')->makeDirectory($dbdirectory);
                $path = Storage::disk('dropbox')->put( $dbdirectory. '/' .  $SendFileTodb, $SendFileTodb );
              
              }else{
               $path = Storage::disk('dropbox')->put( $dbdirectory. '/' .$SendFileTodb, $SendFileTodb);
              }
        }
Sep
19
1 month ago
Activity icon

Replied to Loop Through Array Json

@laracoft 1. It returns all data all the array console.log(jsonData.results);

Activity icon

Replied to Loop Through Array Json

It triggers alert

Sep
18
1 month ago
Activity icon

Replied to Loop Through Array Json

I dont get it, console.log(jsonData) but I get the data from the ajax respone with console.log(results) from ajax

   .done(function(result){
        sendData(result);
        
        let results = result;
        console.log(results);
     // we then pass the result to populate the list                     
    })
Activity icon

Replied to Loop Through Array Json

I don't get anything. But if I use it on the first JSON, I get the value

Activity icon

Replied to Loop Through Array Json

@tray2 The Json is listen bellow. When I hit different endpoint I am able to loop through like the one below. What are the difference?

: 0: {id: "NGHKb2W2KGU", created_at: "2020-09-09T17:35:34-04:00", updated_at: "2020-09-09T19:36:52-04:00", promoted_at: null, width: 4002, …}
1: {id: "F8ZR9BmWD3E", created_at: "2020-09-18T03:53:36-04:00", updated_at: "2020-09-18T22:18:01-04:00", promoted_at: "2020-09-18T22:18:01-04:00", width: 2571, …}
2: {id: "t324188zesk", created_at: "2020-09-18T08:16:40-04:00", updated_at: "2020-09-18T22:15:01-04:00", promoted_at: "2020-09-18T22:15:01-04:00", width: 2787, …}
3: {id: "Gw9vbGiGT_A", created_at: "2020-09-18T14:22:14-04:00", updated_at: "2020-09-18T22:03:02-04:00", promoted_at: "2020-09-18T22:03:02-04:00", width: 4912, …}
4: {id: "UfWaNV1nk9Y", created_at: "2020-09-18T15:09:23-04:00", updated_at: "2020-09-18T21:57:02-04:00", promoted_at: "2020-09-18T21:57:02-04:00", width: 3300, …}
5: {id: "7Ny3ERVCL1A", created_at: "2020-09-18T14:58:30-04:00", updated_at: "2020-09-18T21:54:03-04:00", promoted_at: "2020-09-18T21:54:03-04:00", width: 4232, …}
6: {id: "OOFgEBJCNIs", created_at: "2020-09-18T04:18:47-04:00", updated_at: "2020-09-18T21:51:02-04:00", promoted_at: "2020-09-18T21:51:02-04:00", width: 5257, …}
7: {id: "nws6JU1-ZX0", created_at: "2020-09-18T15:29:30-04:00", updated_at: "2020-09-18T21:48:02-04:00", promoted_at: "2020-09-18T21:48:02-04:00", width: 6000, …}
8: {id: "uKRat_CK080", created_at: "2020-09-17T17:04:56-04:00", updated_at: "2020-09-18T21:45:02-04:00", promoted_at: "2020-09-18T21:45:02-04:00", width: 2921, …}
9: {id: "5xq4wKlqeQs", created_at: "2020-09-18T08:19:44-04:00", updated_at: "20
This one does not work
results: Array(10)
0: {id: 190727, title: "Food", description: null, published_at: "2016-05-06T09:35:56Z", last_collected_at: "2020-08-28T21:39:56-04:00", …}
1: {id: 140489, title: "Food", description: null, published_at: "2016-03-22T15:37:55Z", last_collected_at: "2020-08-30T14:18:47-04:00", …}
2: {id: 179472, title: "Food", description: null, published_at: "2016-04-28T19:48:22Z", last_collected_at: "2020-08-28T18:10:40-04:00", …}
3: {id: 345760, title: "Food", description: null, published_at: "2017-03-20T06:30:00Z", last_collected_at: "2020-09-05T06:36:11-04:00", …}
4: {id: 1016, title: "Food", description: null, published_at: "2016-02-23T20:46:02Z", last_collected_at: "2020-08-29T13:33:33-04:00", …}
5: {id: 197345, title: "Food", description: null, published_at: "2016-05-22T18:12:57Z", last_collected_at: "2020-08-28T22:36:40-04:00", …}
6: {id: 251966, title: "Food", description: null, published_at: "2017-06-20T19:01:57Z", last_collected_at: "2020-08-30T19:36:05-04:00", …}
7: {id: 590343, title: "Food", description: null, published_at: "2017-04-24T10:08:32Z", last_collected_at: "2020-09-05T06:29:56-04:00", …}
8: {id: 474683, title: "STYLED FOOD", description: null, published_at: "2017-09-10T08:29:46Z", last_collected_at: "2020-08-29T00:18:18-04:00", …}
9: {id: 180767, title: "Fresh food", description: null, publishe
window.onload = function (){
    // show spinner
        var spinnerModal = document.querySelector('#spinner-modal');
        spinnerModal.show();    

    var settings = {
        "url": "https://api.unsplash.com/search/collections?page=1&query=food&client_id=****",
        "method": "GET",
        "timeout": 0,
        };
    $.ajax(settings)
    .done(function(result){
        sendData(result);
        
        let results = result;
        console.log(results);
     // we then pass the result to populate the list                     
    })
    .fail(function(xhr, status, error){
        console.log('error:' + xhr.status);
    // NOTE: normally we'd add some error handlers here
    }) 
    .always(function(){
    // done or fail we still hide the spinner
        spinnerModal.hide();
    })   

    function sendData(jsonData){
        
        var itemsList = document.getElementById('list-item');
        for(let i = 0; i < jsonData.length; i++){                
            itemsList.appendChild(
                ons.createElement(
                    '<ons-card class="inside-cards">'+
                    '<ons-list>' +
         
                    '<ons-list-item modifier="tappable>' + 
                        '<div class="left" >' + 
                        '<img src="' + jsonData[i].urls.small +'" class="unsplash-images">' +
                        '</div>' +
                        '<div class="" style="margin-left:20px;" >' 
                            + jsonData[i].likes + "<br>"
                            + jsonData[i].likes + "<br>"
                            + jsonData[i].user.last_name +  "<br>"
                            + jsonData[i].user.first_name + "<br>" +
                        '</div>' + 
                        '<div class="right">' + '<ons-list-item modifier="chevron" tappable onclick="pushJson(\'' + jsonData[i].brand + '\')" ></ons-list-item>' + '</div>'+
                        '<div>' +
                        // '<ons-button onclick="pushJson(\'' + jsonData[i].brand + '\')" icon="md-caret-right"></ons-button>' +
                        '</div>' +
                    '</ons-list-item>' +
                    '</ons-list>' +
                    '</ons-card>'
                )
            );
        }
    }

}

Activity icon

Started a new Conversation Loop Through Array Json

Hey I am having trouble looping through JSON. I am using for loop but can't access response

{total: 10000, total_pages: 1000, results: Array(10)}
results: Array(10)
0:
cover_photo:
alt_description: "pea pods"
categories: []
color: "#37510D"
created_at: "2018-07-17T16:04:26-04:00"
1: 
cover_photo:
alt_description: "pea pods"
categories: []
color: "#37510D"
created_at: "2018-07-17T16:04:26-04:00"

}
for(let i = 0; i < jsonData.length; i++){  
         var j = jsonData[i].color;
cosole.log(j);
}
Sep
17
1 month ago
Activity icon

Awarded Best Reply on Deleting Vapor Project

Hey, You will need to delete the vanity URLs generated by Vapor and all network, domains,cache. Vapor Project:delete

Activity icon

Replied to Deleting Vapor Project

Hey, You will need to delete the vanity URLs generated by Vapor and all network, domains,cache. Vapor Project:delete

Activity icon

Started a new Conversation Deleting Vapor Project

Guys am trying to delete the project, I get an error

    - This project still has active environments. Please delete each environment.

I have deleted the network, database, What else do I have to delete?

Sep
16
1 month ago
Activity icon

Replied to Vapor Cli Installation Error

Valet PHP 7.4

Activity icon

Replied to Vapor Cli Installation Error

Yeah is locally project. I tried composer require laravel/vapor-cli, I get PHP Fatal error: Allowed memory size of 1610612736 bytes exhausted (tried to allocate 4096 bytes) in phar:///usr/local/Cellar/composer/1.9.1/bin/composer/src/Composer/DependencyResolver/Solver.php on line 223 I have to increase memeory size?

Activity icon

Replied to Vapor Cli Installation Error

composer global require laravel/vapor-cli

Activity icon

Replied to Vapor Cli Installation Error

@sinnbeck

{
    "name": "laravel/laravel",
    "type": "project",
    "description": "The Laravel Framework.",
    "keywords": [
        "framework",
        "laravel"
    ],
    "license": "MIT",
    "require": {
        "php": "^7.1.3",
        "fideloper/proxy": "^4.0",
        "intervention/image": "^2.4",
        "laravel/framework": "^6.0",
        "laravel/horizon": "^3.4",
        "laravel/tinker": "^1.0",
        "laravel/vapor-cli": "^1.9",
        "league/flysystem-aws-s3-v3": "^1.0",
        "predis/predis": "^1.1"
    },
    "require-dev": {
        "beyondcode/laravel-dump-server": "^1.0",
        "filp/whoops": "^2.0",
        "fzaninotto/faker": "^1.4",
        "laravel/telescope": "^2.0",
        "mockery/mockery": "^1.0",
        "nunomaduro/collision": "^3.0",
        "phpunit/phpunit": "^7.5",
        "squizlabs/php_codesniffer": "^3.5"
    },
    "config": {
        "optimize-autoloader": true,
        "preferred-install": "dist",
        "sort-packages": true
    },
    "extra": {
        "laravel": {
            "dont-discover": []
        }
    },
    "autoload": {
        "psr-4": {
            "App\": "app/"
        },
        "classmap": [
            "database/seeds",
            "database/factories"
        ]
    },
    "autoload-dev": {
        "psr-4": {
            "Tests\": "tests/"
        }
    },
    "minimum-stability": "dev",
    "prefer-stable": true,
    "scripts": {
        "post-autoload-dump": [
            "Illuminate\Foundation\ComposerScripts::postAutoloadDump",
            "@php artisan package:discover --ansi"
        ],
        "post-root-package-install": [
            "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
        ],
        "post-create-project-cmd": [
            "@php artisan key:generate --ansi"
        ]
    }
}
Sep
15
1 month ago
Activity icon

Started a new Conversation Vapor Cli Installation Error

I get Installation request for laravel/vapor-cli ^1.9 -> satisfiable by laravel/vapor-cli[v1.9.0, v1.9.1, v1.9.2]. - Conclusion: don't install illuminate/container v5.8.36

    - Can only install one of: illuminate/container[v8.0.3, v5.8.36].
    - Can only install one of: illuminate/container[v8.0.4, v5.8.36].
    - Can only install one of: illuminate/container[v8.1.0, v5.8.36].
    - Can only install one of: illuminate/container[v8.2.0, v5.8.36].
    - Can only install one of: illuminate/container[v8.3.0, v5.8.36].

Environment Laravel Version 6 Php 7.4

Sep
11
1 month ago
Activity icon

Awarded Best Reply on Uploading Array Of Images To Amazon S3

I fixed it with this

               $directory  = 'Case/'. $caseDir;           
            foreach ($request->file('fileslab') as $s3file) {
                // Getting request names & extension
                $s3patientFirstName = $request->patient_firstname;
                $s3patientLastName = $request->patient_lastname;
                $s3SavedOrigName = $s3file->getClientOriginalName();
                $SendFileToS3 = $s3patientFirstName . '_' . $s3patientLastName . '_' . time() . $s3SavedOrigName;
                if (!Storage::disk('s3')->exists($directory)){
                    $fileS3directory = Storage::disk('s3')->makeDirectory($directory);
                    $path = Storage::disk('s3')->put( $directory. '/' .  $SendFileToS3, $fileNameToSent );
                  
                  }else{
                   $path = Storage::disk('s3')->put( $directory. '/' .$SendFileToS3, $fileNameToSent);
                  }
            }

@newbie360 I didn't see your solution. I will take a look at it. Thanks though

Activity icon

Replied to Uploading Array Of Images To Amazon S3

I fixed it with this

               $directory  = 'Case/'. $caseDir;           
            foreach ($request->file('fileslab') as $s3file) {
                // Getting request names & extension
                $s3patientFirstName = $request->patient_firstname;
                $s3patientLastName = $request->patient_lastname;
                $s3SavedOrigName = $s3file->getClientOriginalName();
                $SendFileToS3 = $s3patientFirstName . '_' . $s3patientLastName . '_' . time() . $s3SavedOrigName;
                if (!Storage::disk('s3')->exists($directory)){
                    $fileS3directory = Storage::disk('s3')->makeDirectory($directory);
                    $path = Storage::disk('s3')->put( $directory. '/' .  $SendFileToS3, $fileNameToSent );
                  
                  }else{
                   $path = Storage::disk('s3')->put( $directory. '/' .$SendFileToS3, $fileNameToSent);
                  }
            }

@newbie360 I didn't see your solution. I will take a look at it. Thanks though

Activity icon

Replied to Uploading Array Of Images To Amazon S3

I made a mistake initially. I was trying $request->file('fileslab') to see if it will work. The real issue now is the folder is not been created in S3 and there is no file either

Activity icon

Replied to Uploading Array Of Images To Amazon S3

$fileNameToStore is variable storing another variable called filename stored. I know is an array. I store it into local storage.

Activity icon

Replied to Cannot Declare Class Because Name Already In Use

Did you delete a file created before, make sure you check the namespace correctly. Or you can clear cache and config files. php artisan cache:clear and php artisan config:clear after you can use composer autodump

Activity icon

Started a new Conversation Uploading Array Of Images To Amazon S3

I need help with this. The file request is array ```The real issue now is the folder is not been created in S3 and there is no file either.

This is my code


 if ($request->hasFile('fileslab')){
         $patientFirstName = $request->patient_firstname;
         $patientLastName = $request->patient_lastname;
         $data = array();
       foreach ($request->file('fileslab') as $file) {
           $FileOriginalExtension = $file->getClientOriginalExtension();
           $fileOriginalName = $file->getClientOriginalName();
         // adding extension and time to the file
             $fileNameToStore =  $fileOriginalName . '_'. $patientFirstName .'_' . $patientLastName . '_' . time().'.'. $FileOriginalExtension;
             $fileNameToStore =  $fileNameToStore;
         //   Users name adding
             $caseDir = auth()->user()->drname;
             $caseDir = str_replace(' ', '', $caseDir);
             $path = public_path('storage/uploads/chromelabfiles/'. $caseDir);
             
        
           if(!file_exists($path)){
             mkdir($path, 0777, true);
         }
           $file->move($path, $fileNameToStore);
           $data[] = $fileNameToStore;
 
           if (!Storage::exists($fileNameToStore)){
                $file = $request->file('fileslab');
               $fileS3directory = Storage::makeDirectory('case/'. $caseDir);
             $file = Storage::disk('s3')->put( $fileS3directory, $fileNameToStore));
           };
        
       }
Sep
03
1 month ago
Activity icon

Commented on Preparing For Laravel 8

Fun ahead

Aug
19
2 months ago
Activity icon

Replied to Save The Data To Table And Redirect To View With Saved Values

Post the changes you made. It will help someone

Aug
18
2 months ago
Activity icon

Replied to Refactor Foreach In HTML

Thanks once again