swimmer

Member Since 1 Year Ago

Experience Points
10,030
Total
Experience

4,970 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
0
Lessons
Completed
Best Reply Awards
0
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.

  • Community Pillar

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

Level 3
10,030 XP
May
03
1 week ago
Activity icon

Replied to Getignore Want To Create Folders

I tried your suggestion. However I was not able to upload to GitHub the folder

What I did was deleted from the main get ignore file The

storage/app/attachments/*

and in the attachment file added the following

*
!.gitignore

what am I doing wrong?

May
02
1 week ago
Activity icon

Replied to Getignore Want To Create Folders

I still do not understand I have photos in that folder which are being deleted all the time and I do not want to upload them to GitHub

For example photo1.png & photo2.png

How would I tell git to make the attachment folder but not what is in it? In my case the photos.

Activity icon

Replied to Getignore Want To Create Folders

The Question and answer you posted from StackOverflow is a different question when what I asked

He asked how you include a subfolder in the main folder that is in git ignore?

I am asking how to allow a main folder but not all folders inside that folder.

How can this be done? Can you please show me an example rather than sending a link to StackOverflow

Apr
29
2 weeks ago
Activity icon

Started a new Conversation Getignore Want To Create Folders

I’m trying to getignore To upload to Git a folder but not what is in the folder for example

storage/app/attachments/*

lest say if there is the file test.php that it will not be uploaded to GitHub

But the folder attachments will.

What am I doing wrong?

Apr
22
3 weeks ago
Activity icon

Replied to Eloquent Query That Returns From The DB Only Rows That ‘sku’ = Array

@tisuchi @tisuchi

I tried to modify it

Here is my code

   $sku = Sku::get();
    
    $sku_arr = $sku->toArray();
   
    $sku_to_update = collect($this->del_update_info_arr);
    $sku_to_update = collect($this->del_update_info_arr)->pluck('sku');
    $sku_to_update_arr = $sku_to_update->toArray();

    
  
    $sku_to_update_db = $sku->whereIn('sku', $sku_to_update_arr)->get();
    

However I got the following error:

get(), 0 passed

Apr
21
3 weeks ago
Activity icon

Replied to Eloquent Query That Returns From The DB Only Rows That ‘sku’ = Array

I am not trying to update but the get from the DB only sku That are in the Array

Activity icon

Replied to Eloquent Query That Returns From The DB Only Rows That ‘sku’ = Array

I tried your suggested it’s still not working

This my array

array:3 [
    0 => 5
    1 => 1
    2 => 20
  ]
Activity icon

Started a new Conversation Eloquent Query That Returns From The DB Only Rows That ‘sku’ = Array

I would like to build a Eloquent query That returns from the DB Only rows that ‘sku’ = array

For example:

 $sku_to_update = ['5','1','20'];
  $sku_to_update = Sku::where('sku', $sku_to_update);

However it’s not working for me what am I doing wrong?

Activity icon

Replied to Must Be Of The Type Array,

When I try your recommendation I get array(0)

Even though the original Array had info Please also explain what is going on behind the scenes

Activity icon

Started a new Conversation Must Be Of The Type Array,

I have an array or object that when I look at my debugger it looks like

  $diff: array(5)

    1: array(3)
    sku: "100"
    city: "New York"

(I tried to replicate in my editor how it looks in the debugger as I do not know how to attach a screenshot to this form)

When I try the following command

 Sku::insert($diff);

I get the following error

insert() must be of the type array, object given, called in C:\xampp\htdocs\bot_manger\vendor\laravel\framework\src\Illuminate\Database\Eloquent\Builder

1)How do I convert my array that Eloquent can read it? 2)What is the definition of this type of array?

Activity icon

Replied to How To Make Calls To DB More Efficient?

Thank you for making things more simpler.

1)How important for speed is 8000 records is mass insert?

Sku::insert($data);

2)Is built in Laravel function diff()

Faster than the way I had it?


   $found_sku_in_db = $db_sku->contains('sku',$dll_sku);
       if($found_sku_in_db == false)

Apr
20
3 weeks ago
Activity icon

Started a new Conversation How To Make Calls To DB More Efficient?

We have a collection with 8000 items in it of SKU And we built a function that checks if the SKU dose not exist in the DB to add to the DB it takes us over then 20 minutes for this to work It should just take a few minutes I am suspecting my code is un fficient attached is my code I would love to learn how I can make it more efficient

<?


$db_sku = Sku::all();
$sku = new sku;

foreach($v_csv_arr as $outer_array)
  {
   $dll_sku = $outer_array[$key_has_sku];
   // We clean the SKU from unwanted characters
   $dll_sku = preg_replace("/\s+/", "", $dll_sku);
 
   if (is_numeric($dll_sku) == true)
      {
       
       $found_sku_in_db = $db_sku->contains('sku',$dll_sku);
       if($found_sku_in_db == false)
       {
         // It can be 
         //confusing $sku and $db_sku
         // $db_sku -represents the DB 
         // $sku - The instance that allows to add more items to DB
        
         $sku->sku = $dll_sku;
         $sku->save();




       }

      }

  

  }
Activity icon

Replied to Laravel Excel Fillable Property To Allow Mass Assignment

Thank you for this solution it works.

Activity icon

Replied to Laravel Excel Fillable Property To Allow Mass Assignment

No, All I want is import the CSV file to a collection not to save to DB.

Activity icon

Replied to Laravel Excel Fillable Property To Allow Mass Assignment

This is my model

namespace App;

use Illuminate\Database\Eloquent\Model;

class Sku extends Model
{
      
    // Set a new default for primary key
    protected $primaryKey = 'sku';
    protected $fillable = ['sku'];
    
}
Activity icon

Replied to Laravel Excel Fillable Property To Allow Mass Assignment

@tykus

Where would I put

$rows = collect($rows);

Activity icon

Replied to Laravel Excel Fillable Property To Allow Mass Assignment

It is not currently a collection I am trying to import from the CSV file in to a collection.

You also wrote that “why is this the method signature” can you explain what you mean?

Activity icon

Replied to Laravel Excel Fillable Property To Allow Mass Assignment

@tykus

I want to skip the steep of connecting to the DB. All I need is to import the CSV file to a collection not relying on the DB

Any ideas?

Activity icon

Replied to Laravel Excel Fillable Property To Allow Mass Assignment

@tykus

I followed your suggestion then I get the following error

'mei' doesn't have a default value

This error is for reference from the SKU model.

Maybe I have it all wrong all I want to do is to import a CSV file contents to a collection Not to DB.

Activity icon

Started a new Conversation Laravel Excel Fillable Property To Allow Mass Assignment

I am working with Laravel Excel “Maatwebsite\Excel”

I am getting the following error while trying to make an import

Add [sku] to fillable property to allow mass assignment on [App\Sku]”

This is my import file
$collection = Excel::import(new SkuExcelImport,storage_path('app\inventory_csv\v.csv'));

This is my file

<?php

namespace App\Imports;

use App\Sku;

use Illuminate\Support\Collection;
use Maatwebsite\Excel\Concerns\ToCollection;



class  SkuExcelImport implements ToCollection
{
    /**
    * @param array $row
    *
    * @return \Illuminate\Database\Eloquent\Model|null
    */
   
// 

    public function collection(Collection $rows)
    {   
        foreach ($rows as $row) 
        {
           
            Sku::create([

                'sku' => $row[0],
              
                
            ]);

           

        }
    }
}

What am I doing wrong?

Apr
14
4 weeks ago
Activity icon

Replied to How Can I Find The Full Namesapces Of A Class ?

There is a class there that I want to use I do not want to rewrite it

Activity icon

Replied to PDF As RGB

@neilstee

I tried it and it works.

Thank you,

Activity icon

Started a new Conversation PDF As RGB

I am using t following package to covert PDF to JPEG

https://packagist.org/packages/spatie/pdf-to-image

Some of the PDF’S that I am converting are converted as CMYK but I want a RGB format

I can’t understand from the documentation how this can be done. I Was thinking that if I cannot use the pdf-to-image package I I can reopen the image with the following package https://packagist.org/packages/intervention/image

And save it as an RGB.

However no success in finding a way to do so in intervention/image.

This the code I have so for


// Convert PDF and save it as JPEG
      
$pdf = new Pdf(storage_path()."/app/".$PDF_path);
$pdf->setCompressionQuality(100);
$pdf->saveImage(storage_path()."/app/public/JPG/".$number.".jpg");

Apr
13
1 month ago
Activity icon

Replied to How Can I Find The Full Namesapces Of A Class ?

@martinbean I have the following namespace in my test ID

namespace Tests\Browser;

and the class name is tes

when In my controller I do

use Tests\Browser\ tes;

I get the following error

“Calss not found”.

Activity icon

Replied to Laravel Excel Collection Not Working

@neilstee

I used your recommendation and converted the collection to a array

This what I got:


array:1 [▼
  0 => array:4 [▼
    0 => array:2 [▼
      0 => "SKU"
      1 => "Quantity"
    ]
    1 => array:2 [▼
      0 => 40000000
      1 => 1
    ]
    2 => array:2 [▼
      0 => 40000002
      1 => 1
    ]
    3 => array:2 [▼
      0 => 40000006
      1 => 0
    ]
  ]
]

The result I would like to have Is an associative array

array:1 [▼
 
    1 => array:2 [▼
    "SKU" => 40000000
    "Quantity" => 1
    ]
    2 => array:2 [▼
    "SKU" => 40000002
    "Quantity" => 1
    ]
    3 => array:2 [▼
    "SKU" => 40000006
    "Quantity" => 0
    ]
  ]
]

What am I doing wrong?

Activity icon

Started a new Conversation How Can I Find The Full Namesapces Of A Class ?

How can I find the full namesapces of a class ?

Apr
12
1 month ago
Activity icon

Started a new Conversation Laravel Excel Collection Not Working

Hi,

I am trying to use the following extension to convert a Excel sheet to a Laravel collection

https://laravel-excel.com/

I have the following

<?php

namespace App\Imports;

use App\Quantitie;
use Maatwebsite\Excel\Concerns\ToModel;
use Illuminate\Support\Collection;


class MImport implements ToModel
{
   

    public function collection(Collection $rows)
    {
        foreach ($rows as $row) 
        {
            Quantitie::create([
                'SKU' => $row[0],
                'Quantity'=> $row[1]
            ]);
        }
    }
}

And I use

 $collection = Excel::toCollection(new MImport, $path); 
         dd($collection);

I get the following error

“contains 1 abstract method and must therefore be declared abstract or implement the remaining methods 1 abstract method and must therefore be declared abstract or implement the remaining methods”

What am I doing wrong?

Activity icon

Replied to File Not Found Google Drive

I was able to view all files in the directory with the help of

$files = Storage::disk('google')->files('dddwSrwrwMDI1ctest');

However it seems that Google drive converts all my files to a file name with a designated string

In my case test.txt = ffffs3434

How would I get the real name of the file? Not the unique identifier that Google drive gives it

Activity icon

Started a new Conversation File Not Found Google Drive

I am using the following package to retrieve files from my Google drive

nao-pon/flysystem-google-drive

While trying to download a file from Google Drive with the following command:

 $a = file_get_contents(Storage::disk('google')->get('dddwSrwrwMDI1ctest/test.txt'));

I get a 404 error “file not found”

What am I doing wrong?

Apr
06
1 month ago
Activity icon

Replied to Can Not Find Magick

@michaloravec @usmanmalik

I found my issue I had the wrong Imagick binaries I need to download the binaries for PHP 7. After downloading the right binaries it works perfectly.

Thank you for your help.

Apr
05
1 month ago
Activity icon

Started a new Conversation Can Not Find Magick

I’m trying to install php_imagick

I added the following line to PHP.ini

extension=php_imagick.dll

I also put the file php_imagick.dll

In to C:\xampp\php\ext

However when I look at my PHPInfo() I do not see my imagick anywhere.

What am I doing wrong?

Activity icon

Replied to Why Is Storage Exists False

Thank you it works

Activity icon

Replied to XDBUG Not Stoping

@neilstee

I reverted to xdbug 2 from 3 and now it’s working fine

Thank you for your help

Activity icon

Started a new Conversation Why Is Storage Exists False

I am trying to check if a particular directory exist with the help of the file system

I have the following code

$temp_path = "C:\xampp\htdocs\test\storage\app\public\PDF"
Storage::exists($temp_path);

Storage::exists($temp_path); is equaled to false

Even though when I put the path name in my file Explorer I can see the directory, I should get true. What am I doing wrong?

Apr
02
1 month ago
Activity icon

Started a new Conversation Xdbug Not Working PHPStrom

Hi, I am using PHPStrom to debug some php code with xdbug. But when trying to debug and setting a breakpoint the code does not stop at the breakpoint. At the following link you can find a video showing the issue and my current settings:

https://drive.google.com/file/d/1BxPHClOkf6P87NEm3nNImgJH1W7Ye5yg/view?usp=sharing

What am I doing wrong?

Mar
19
1 month ago
Activity icon

Replied to XDBUG Not Stoping

@neilstee

I tried recommendation however it’s still not working. This is what I have in my

PHP INI

zend_extension = C:\xampp\php\ext\php_xdebug-3.0.3-7.4-vc15-x86_64.dll
xdebug.remote_port=9003

When I tried to use Xdebug wizard and dose tell me to add xdebug.remote_port=9003 To my PHP INI Or you sure need this line

This is my Launch.json


"version": "0.2.0",
    "configurations": [




        {
            "name": "Listen for XDebug",
            "type": "php",
            "request": "launch",
            "port": 9003
        },
        {
            "name": "Launch currently open script",
            "type": "php",
            "request": "launch",
            "program": "${file}",
            "cwd": "${fileDirname}",
            "port": 9003,
            "runtimeExecutable": "C:\xampp\php\php.exe"
        }
    ]

What am I doing wrong?

Mar
18
1 month ago
Activity icon

Replied to XDBUG Not Stoping

@neilstee

All I have in my PHP.INI is zend_extension = C:\xampp\php\ext\php_xdebug-3.0.3-7.4-vc15-x86_64.dll

How would I set the port inside PHP.INI?

Activity icon

Replied to XDBUG Not Stoping

@neilstee

I tried 9003 and 9000

Both are not working any other ideas?

Activity icon

Started a new Conversation XDBUG Not Stoping

I set up for debugging purposes XDBUG together with VSCODE however when I make a stop point in XDBOUG and run the script the code is not stopping.

What am I doing wrong?

I made a video explaining my issue which can be found at the following link: https://drive.google.com/file/d/1tDi5UVEzUxg2p3ycHCt1kKp5Zq8W3pEC/view?usp=sharing

Feb
25
2 months ago
Activity icon

Replied to Issue With Bat File On Windows

@tray2

That seem to be the problem. Thank you for your help.

Activity icon

Started a new Conversation Issue With Bat File On Windows

Our Laravel project is built in a way that it with the help of Exec it executes a Bat file.

In my local Windows computer it works great. However in my windwos server which is running a virtual machine of windows 10 when I try to initialize the Bat file from Laravel it dose not work and I get the following error

“PHP is not recognized as an internal or external command in command prompt”

However when I click on the bat file from Windows it works great what am I doing wrong

I made the following video to explain the issue better

https://drive.google.com/file/d/1hc38Q3BvDvl8DM9DEV0t3aQV5HNqKw2f/view?fbclid=IwAR0QCYkJBZgvP4S6-cbnQg1sctaM0xr2QHKzZvxoJYfBfBkJIZRAT7gYBG8

Feb
23
2 months ago
Activity icon

Started a new Conversation VM Windows 10 For Laravel

For one of my Laravel projects I need a VM Windows 10. What hosting providers have a VM Windows 10? Any recommendations?

Feb
10
3 months ago
Activity icon

Replied to Error With Abstract Metho

@mvd

Thank you for your explanation

Activity icon

Replied to Error With Abstract Metho

@mvd

Is there a way to debug this that way I can find the tyepo For next time?

Activity icon

Replied to Error With Abstract Metho

@mvd

Thank you for pointing this out

Activity icon

Started a new Conversation Filter A Collection Only Get The Attributes

I am am trying to filter a Collection only get the attributes of 'SKU', link

My elements include also link2,link3 but I do not want the new collection to have them. This my code but it is not working


        $items_info =  collect($this->links_with_sale);   
      
        //    $items_info = $items_info->only(['SKU', 'tradesy_sku']);    

           $subset = $items_info->map(function ($items_info) {
            return $items_info->only(['SKU', 'tradesy_sku']);
        });

What am I doing wrong?

Activity icon

Started a new Conversation Error With Abstract Metho

I am using the following extension to convert a file to Excel https://laravel-excel.com

When trying to implement the Excel export I get the code get stuck in

class ItemsSaleExcel implements FromCollection, WithHeadings, WithStyles

And prints in the terminal The

" PHP Fatal error: Class App\Exports\ ItemsSaleExcel contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (Maatwebsite\Excel\Concerns\FromCollection::collection)

"

This my code

<?php

namespace App\Exports;

use App\Json;
use Maatwebsite\Excel\Concerns\FromCollection;
use Maatwebsite\Excel\Concerns\WithHeadings;
use Maatwebsite\Excel\Concerns\WithStyles;
use Maatwebsite\Excel\Concerns\FromQuery;
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;



class ItemsSaleExcel implements FromCollection, WithHeadings, WithStyles
       
                           
{ 
  /**
    * @return \Illuminate\Support\Collection
    */
   
    protected $links_with_sale;

        public function __construct()
        {
        

            $Json_db = Json::where('name','=','items_to_update_json')->first();       
            $this->links_with_sale = $Json_db->json;
                                    
            $this->links_with_sale = json_decode($this->links_with_sale);
        
    
        }
        public function collectio ()
        {

        $items_info =  collect($this->links_with_sale);                
        //    $items_info = $items_info->only(['SKU', 'tradesy_sku']);
            
                    
            return $items_info;
        }

        Public function headings(): array
        {
            return [
                'SKU',
                'link',            
                
            ];
        }

        public function styles(Worksheet $sheet)
    {
        return [
        // Style the first row as bold text.
        1    => ['font' => ['bold' => true]],
        ];
    }
}

What am I doing wrong?

Activity icon

Replied to Exporting In Excel Only Part Of The Information

@jlrdw

I tried your suggestion however it did not work properly.

I get the following error “contains 2 abstract methods and must therefore mplement the remaining methods”

Is my code set up correctly?

This is my code

<?php


namespace App\Exports;

use Maatwebsite\Excel\Concerns\FromCollection;
use Maatwebsite\Excel\Concerns\WithHeadings;
use Maatwebsite\Excel\Concerns\WithStyles;
use Maatwebsite\Excel\Concerns\FromQuery;
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;

class ItemsSaleExcel implements FromCollection,FromQuery

    // We are using the following extension to convert Laravel collections to Excel sheets
    // https://laravel-excel.com/

    /**
    * @return \Illuminate\Support\Collection
    */
    protected $links_with_sale;

    public function __construct()
    {
       

        $Json_db = Json::where('name','=','items_to_update_json')->first();       
        $this->links_with_sale = $Json_db->json;
                                
        $this->links_with_sale = json_decode($this->links_with_sale);
      
 
    }
    public function collectio ()
    {

        $items_info =  collect($this->links_with_sale);                
        // return $items_info;
        
        return $items_info::query()->only(['SKU', 'url']);;
    }

    Public function headings(): array
    {
        return [
            'SKU',
            'url',            
            
        ];
    }

    public function styles(Worksheet $sheet)
{
    return [
       // Style the first row as bold text.
       1    => ['font' => ['bold' => true]],
    ];
}
}
Feb
09
3 months ago
Activity icon

Started a new Conversation Exporting In Excel Only Part Of The Information

I am using the following extension to create an Excel sheet from my collection laravel-excel.com

My collection has a few associative array’s in it and I only want to create columns in my Excel from part of the information:

However all the information from the collection is being populated in the spreadsheet.

This is what I have so far

return Excel::store(new ItemsSaleExcel,$path);

And the export information is

public function collection()
    {

        $items_info =  collect($this->links_with_sale);                
        return $items_info;
        
    }

    Public function headings(): array
    {
        return [
            'SKU',
            'url',
            
            
        ];
    }

    public function styles(Worksheet $sheet)
{
    return [
       // Style the first row as bold text.
       1    => ['font' => ['bold' => true]],
    ];
}
}

When exporting I only want the following 'SKU', 'url', not all the other info. What am I doing wrong?

Activity icon

Replied to Controller Not Working When In Subfolder

@siangboon Thank you for the tip.