swimmer

Member Since 1 Year Ago

Experience Points
9,070
Total
Experience

930 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 2
9,070 XP
Feb
25
3 days 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
5 days 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
2 weeks 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
2 weeks 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.

Feb
08
2 weeks ago
Activity icon

Replied to Controller Not Working When In Subfolder

Thank you for your help my namespace was set correctly I just had a get request higher up in my “web” and that what led to the error.

That right way to set it up is


Route::Get('download_report', 'CreateExcel\[email protected]');
Route::Post('download_report', 'CreateExcel\[email protected]');
Activity icon

Started a new Conversation Controller Not Working When In Subfolder

I put my controller inside a subfolder.

When I call it from the route it stopped working and I’m getting the following error:

Target class [App\Http\Controllers\CreateReportController] does not exist.

This is my route

Route::Post('download_report', 'CreateExcel\[email protected]');

This is my controller

<?php

namespace App\Http\Controllers\CreateExcel;

use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Requests\DownloadReportExcelRequest;
use App\Http\Controllers\Controller;

// Relevant to export Excel sheets

use App\Exports\ExcelSites;
use App\Exports\CreateReportInExcel;
use Maatwebsite\Excel\Facades\Excel;

class CreateReportController extends Controller
{
    
    
    public function DownloadReportExcel(DownloadReportExcelRequest $request) 
    // public function DownloadReportExcel(Request $request) 
    {
          // Converts reports to Excel for immediate download
         
        
          $request = $request->toArray();        
          $report_id = $request['report_id'];   
          $report_id =  trim($report_id);

          return Excel::download(new CreateReportInExcel($report_id), 'report '.$report_id.'.xlsx');
    }

    

 }


Why I’m getting this error? What am I doing wrong?

Feb
07
3 weeks ago
Activity icon

Replied to Same Laravel Project Different Results On Different Computers

@tray2

That is exactly what I am doing I am running php artisan dusk:chrome-driver

Every time before running the algorithm on both machines to make sure that it has the latest version of Chrome.

The must be some kind of other reason. Any ideas?

Feb
04
3 weeks ago
Activity icon

Replied to Same Laravel Project Different Results On Different Computers

@tray2

Yes I am using it

If you look at my second comment to this post.

I mentioned that in order to have a clean set up I install on both computers the newest version of Chrome

With the help of “php artisan dusk:chrome-driver”

Activity icon

Replied to Same Laravel Project Different Results On Different Computers

1)I am not sure what you mean by the real world 2) I am simulating clicks on external websites.

Activity icon

Replied to Same Laravel Project Different Results On Different Computers

@tray2 There is no error message.

In one machine the Chrome browser shows up each time and the other you do not see the Chrome browser in action it works behind the scenes.

I wanted it to be a live browser which I can see what it does

Activity icon

Replied to Same Laravel Project Different Results On Different Computers

@tray2

1)It is not a poor test as it dose very complicated things and works on one computer great. 2)On both computers I installed the latest version of chrome that Dusk uses with the help of “php artisan dusk:chrome-driver”

Activity icon

Replied to Json_encode V ToJson

Thank you for your answer. You mentioned that “may be a slight customisation of in the toJson implementation depending on the class, which determines what/how the object is represented as JSON”

Can you please explain a little bit more because I don’t understand what will be the difference in the way the “JSON is determines”?

Activity icon

Started a new Conversation Same Laravel Project Different Results On Different Computers

I am running a project on 2 local computers in our office. The project is based Laravel Dusk And in the project there is an instance of Google Chrome running.

The issue we have is that on one computer the instance of Google Chrome runs perfectly. The second computer sometimes it runs sometimes it doesn’t.

Both computers are windwos 10 and have the same PHP version and the same XAMPP installed. What can be causing this issue? Why would there be a difference between the computers if it’s the same exact code?

How do I troubleshoot this issue?

Feb
02
3 weeks ago
Activity icon

Started a new Conversation Json_encode V ToJson

What are the differences with Laravel using

json_encode V toJson

I tested both I’m not sure why would I use the Laravel built in toJson When I have a PHP json_encode

That is the only advantage I found is when working with collections.

However I can convert the collection to on array therefore I do not see a big advantage for it.

Activity icon

Replied to Try Catch Not Working Properly

@talinon

Thank you for your explanation

Feb
01
3 weeks ago
Activity icon

Replied to Try Catch Not Working Properly

@jlrdw @talinon

I am using PHP error handling not the Laravel one.

Do I still need to load the exception class?

Jan
31
4 weeks ago
Activity icon

Replied to Try Catch Not Working Properly

@jlrdw

Is it possible that I didn’t understand the documentation correctly

However that still does not explain why my “try catch” block is not working correctly.

This is the part of documentation that I was using for the enter key:

“Another valuable use case for the keys method is sending a "keyboard shortcut" combination to the primary CSS selector for your application:”

$browser->keys('.app', ['{command}', 'j']);

Jan
30
4 weeks ago
Activity icon

Started a new Conversation Try Catch Not Working Properly

I have a try catch block inside my Laravel dusk test

However my application is always crashing when it can not find the CSS property '[data-default="Add a Tag"] What is wrong with the following code flow?

<?php

try {  
  $browser->type('[data-default="Add a Tag"]','a');  
  $browser->pause(1000);
  $browser->keys('[data-default="Add a Tag"]', ['{ENTER}']);
  $browser->pause(500);
 
 
  }

  catch (Exception $e) {
    
    // do somthing
 
  }
Jan
02
1 month ago
Activity icon

Started a new Conversation Forge V CPane

I deployed my first Laravel project on a hosting service with cPanel.

It has a connection to GitHub mySQL database and can run different projects with different PHP versions.

It is easy to use.

I was reading about Laravel Forge. 1)What advantages over cPanel I can get from Forge? 2) Are there any disadvantages for using Forge?

Dec
28
2 months ago
Activity icon

Replied to 403 In FormRequest

@imrodrigoalves

Thank you. Fixed it.

Activity icon

Started a new Conversation 403 In FormRequest

I have the following controller

 
    public function DownloadReportExcel(DownloadReportExcelRequest $request) 
    // public function DownloadReportExcel(Request $request) 
    {
          // Converts reports to Excel for immediate download
         
        
          $request = $request->toArray();        
          $report_id = $request['report_id'];   
          $report_id =  trim($report_id);

          return Excel::download(new CreateReportInExcel($report_id), 'report '.$report_id.'.xlsx');
    }

Which leads to the following form request


class DownloadReportExcelRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return false;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
      
        return [
         
                   
            'report_id'    => 'required|unique:upload_report,id',
        ];
    }
}

However each time I get to the form I get 403 this action is unauthorized

I don’t even know where to start in order to troubleshoot this issue. Any advice?

Dec
27
2 months ago
Activity icon

Replied to 0 Passed And Exactly 1 Expected

Thank you it works

Activity icon

Started a new Conversation 0 Passed And Exactly 1 Expected

I have the following form

<form class="form-inline" action="{{url('download_report')}}" method="POST" novalidate="novalidate" autocomplete="off" enctype="multipart/form-data">>
  @csrf  

  <div class="form-group mx-sm-3 mb-2">
    <label for="generate_report_in_excel" class="sr-only"></label>
    <input type="text" class="form-control" id="generate_report_in_excel" value="0" name="generate_report_in_excel" placeholder="Enter report ID to process">
  </div>
  <button type="submit" name="submit" class="btn btn-primary mb-2">Download Excel</button>
</form>

When I enter info in to the form and click submit I get the following error

0 passed and exactly 1 expected

My controller is

public function DownloadReportExcel($request) 
    {
          // Converts reports to Excel for immediate download
          $request = $request->toArray();
          $report_id = $request('report_id');

          return Excel::download(new reateReportInExcel($report_id), 'report.xlsx');
    }

What am I doing wrong?

Dec
25
2 months ago
Activity icon

Replied to Bold Headers In Laravel Excel

@nakov It works thank you

Activity icon

Replied to Imagick Method Working From Power Shall Not Controller

@wulfheart I am using PHP 7.4

I found the following post https://stackoverflow.com/.../imagemagick-errors-reading-pdf

That I need to research maybe the solution is there

Activity icon

Started a new Conversation Bold Headers In Laravel Excel

I am using the Laravel Excel Package https://docs.laravel-excel.com/3.0/exports/

I use the package to convert a collection to an Excel sheet I would like to bold my headers.

How can this be done?

This is my code"


class ExcelSites implements FromCollection, WithHeadings
{
    /**
    * @return \Illuminate\Support\Collection 
    */
    public function collection()
    {
   
     $report =  upload_report::where('id','=','526')->first();
     

     $items_info =  collect(json_decode($report->json));     
     return $items_info;

    }

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

}
Dec
21
2 months ago
Activity icon

Started a new Conversation Imagick Method Working From Power Shall Not Controller

If I call particular method directly from the controller I get at the following line of code

$pdf = new Pdf(storage_path()."/app/".$PDF_path);

The following error

PDFDelegateFailed `The system cannot find the file specified. ' @ error/pdf.c/ReadPDFImage/794 However if I call the same method from the CMD it works great with no errors the code making the issue is relevant to the extension Imagick which converts a file from PDF to JPG

Why do I have this weird behavior?

I am using Laravel 7.12

Dec
19
2 months ago
Activity icon

Replied to If Statement To Make A Request Validation

@slev1n I tried the following

    public function rules()
    {

      $value = "no";
        return [
            
        
            
            'json' => 'required_if:value,yes|max:300|mimes:json',
          
        ];

    }

    }

And still makes the form request I do not wanted to process the request if

value = "no";

What am I doing wrong?

Activity icon

Replied to If Statement To Make A Request Validation

@michaloravec

When I try the following it works


  $value = 1;
        if($value == 1) {
        return [
            
              'json' => 'required|max:300|mimes:json',
        ];

    }
    }

However if I want to ignore the validation and have the following code public function rules() {

        $value = 4;
        if($value == 1) {
        return [
            
              'json' => 'required|max:300|mimes:json',
        ];

    }
    }

I get the following error Argument 2 passed to Illuminate\Validation\Factory::make() must be of the type array, null given.

What am I doing wrong?

Activity icon

Replied to If Statement To Make A Request Validation

Value is information I get from the user import on the from if it is “yes” I want to perform the request otherwise I’m not interested in the request

Activity icon

Started a new Conversation If Statement To Make A Request Validation

I have the following form request validation

<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class JsonUploadRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {

        
        return [
            
              'json' => 'required|max:300|mimes:json',
        ];
    }

    
public function messages()
{
    return [
        'json.mimes' => 'The file you uploaded is not a JSON
        or The file is not a valid JSON check it against https://jsonlint.com',
        
    ];
}
}

I will like preform the request validation only if $value == ‘yes’

How can this be done?

The request is being called the following way

  public function store(JsonUploadRequest $request)
    {
     
   
      $json = $request->file('json')->get();
}
Dec
17
2 months ago
Activity icon

Replied to Invalid Route Action

@nakov I just had syntax issue

I was able to get it to work

This is the code


<?php

use Illuminate\Support\Facades\Route;

include_once "web/bots.php";

Route::prefix('bots')->group(function(){
  
  
        Route::get('download','[email protected]');
         Route::Resource('','BotsController');
       
      });
Activity icon

Started a new Conversation Invalid Route Action

I have the following setting for my routes


use Illuminate\Support\Facades\Route;

include_once "web/bots.php";

Then in the bots.php I have

Route::prefix(bots')->group(function(){
  
  
        Route::get('download,'BotsController');
         Route::Resource('BotsController');
       
      });


This setting gives me the following error

Invalid route action: [App\Http\Controllers\BotsController]

What am I doing wrong?

Dec
14
2 months ago
Activity icon

Replied to Update A Row In The Database

@tykus Works Thank you.

Activity icon

Replied to Update A Row In The Database

@tykus I am trying to update a row in my database table named “json” I tried the code and got

And I got the following error: “add [json] to fillable property to allow mass assignment

Activity icon

Replied to Update A Row In The Database

@tykus

I just tried your suggesting with

$cars = ["Volvo", "BMW", "Toyota"];
        $json = json::where('name', 'certs')->firstOrFail();
        $json->update('json', $cars);

And I got the following error: “update() must be of the type array”

At the following link you can see my MYSQL table structure

https://drive.google.com/file/d/1NcyDHysC7nK7jsNuhLLQpmz-nMZeIe_F/view?usp=sharing

Activity icon

Replied to Session Not Passed When Using Bat

@ftiersch @tray2 Thank you for your help but I need to use a bat file for this task can’t get into all the reasoning on this form.

Any way to pass a session, this way?

Activity icon

Started a new Conversation Update A Row In The Database

I am trying to update a row in the database with has the name certs under the column name I tried the following $Json_db->name->certs = 'elo'; $Json_db->where('name','certs') = json_encode($certs);

however both of them don’t work.

Activity icon

Started a new Conversation Session Not Passed When Using Bat

I am saving information to a session

session(['report_id' => self::$report_id]); Then I call a function using a BAT file

The function that is called Has session("report_id") when I check it there it is equal to null even though

The class in the original class session has a value.

I tried to add the following session()->save();

and use

Illuminate\Support\Facades\Session; 

to each of the classes.

however still not working. What am I doing wrong?

Activity icon

Replied to Uppercase Collection

@snapey I just tried their code and it’s not working

I did make a small modification

Do you have an answer to the question?

Activity icon

Replied to Uppercase Collection

@tykus Thank You for your solution

Is there any way to do this check with “where” without using filter?

Dec
12
2 months ago
Activity icon

Replied to Uppercase Collection

@tykus So I rephrase it To $only = collect($items_info)->where(strtoupper('sku'),'FOO');

How would I make an uppercase check?