GodziLaravel

Member Since 4 Years Ago

Experience Points
32,080
Total
Experience

2,920 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
2
Lessons
Completed
Best Reply Awards
1
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 7
32,080 XP
Apr
09
1 week ago
Apr
08
1 week ago
Activity icon

Started a new Conversation Laravel And DDOS Attacks

Hello,

I'm wondering if Laravel can also protect against DDOS attacks or it should be blocked at the transport layer rather than at the application layer?

Thanks

Apr
06
1 week ago
Activity icon

Replied to What's The Correct Http Code To Return The 'queue Job' Is Already Executed!

@michaloravec Thanks ,

I think 406 Not Acceptable is the correct one !

Activity icon

Started a new Conversation What's The Correct Http Code To Return The 'queue Job' Is Already Executed!

Hello ,

I created a controller to execute queues jobs , but before the execution I check if the user has already executed these queues to avoid duplication:

if ($jobCountChecker>0) {
                    $this->output['content'] = "Please wait until the end of process, there are $jobChecker queue(s) left.";
                    $this->output['http_code'] = 200;
                } else {
                   (...)
                    $this->output['content'] = $this->outputMessage(Artisan::output());
                    $this->output['http_code'] = 200;
                }

question: Is there any specific HTTP code to return when $jobCountChecker > 0?

Apr
02
2 weeks ago
Activity icon

Replied to Production Server Seems Not Updated (job Queue)

@frankielee In deed I restarted the queue and it seems working !

Activity icon

Replied to Production Server Seems Not Updated (job Queue)

I found it!

php artisan queue:restart
Activity icon

Started a new Conversation Production Server Seems Not Updated (job Queue)

Hello,

I hade one error on CompanySync.php line 82. (local env & prod env)

I fixed that problem and it works without issues on my local.

But after push/pull in the prod env I keep seeing the same error message !

[2021-04-02 14:32:30] test.ERROR: Trying to access array offset on value of type null {"exception":"[object] (ErrorException(code: 0): Trying to access array offset on value of type null at /data/www/######/app/CustomClass/data/Sync/CompanySync.php:82)
[stacktrace]
(...)

Now to be sure that this error message is not correct I added many return lines in the top of CompanySync.php file, so normally if this error message is true it should now changed to another line instead if 82 !

>>>> Important update : this code is via a job queue

Is there any way to (refresh) my app ?

Mar
31
2 weeks ago
Activity icon

Replied to How To Call Php Artisan From Controller With Parameters ?

@martinbean Thanks.

What I would like to make is:

Create a simple button (javascript & html side) to run some php artisan commands .

do you have any suggestion ?

Activity icon

Started a new Conversation How To Call Php Artisan From Controller With Parameters ?

Hello ,

In my controller I have this code :


Artisan::command('inspire', function () {
    $ask = $this->ask('Are you sure to continue', 'no');
    if ($ask !== 'yes') return null;
    $this->comment(Inspiring::quote());
})->describe('Display an inspiring quote');

As you can see to get the quote I need to answer to the first question. If yes it returns the quote else it returns null

Now, in my controller I call the Artisan command:

    public function commands(){
         Artisan::call('inspire');

        return response()->json([
            'result' => Artisan::output(),
        ]);
    }

My question is : How to add the answer in the this call when it needed?

Mar
26
3 weeks ago
Activity icon

Started a new Conversation Is It Possible To Use `like` With "%" In A Collection ?

Hello ,

I created a collection , and now when I do :

$myCollection= $myCollection->where('comment','test');

It returns results,

But if I do:

$myCollection= $myCollection->where('comment','like','%test%');

It's not working, which is normal because it's not an SQL request,

My question: is it possible in Laravel to use something similar to % when I filter a collection ?

Thanks

Mar
23
3 weeks ago
Activity icon

Replied to Eloquent: How To Get Null Values When Using WhereNotIn

@michaloravec Thanks :) ;

In fact there is other where after this condition so I'm wondering if it's possible to include orWhereNull(...) inside whereNotIn('teamleader_id', [4, 8, 7, 5]) ?

Activity icon

Started a new Conversation Eloquent: How To Get Null Values When Using WhereNotIn

Hello ,

Let me first show this example:

\App\User::whereNotIn('teamleader_id',[4,8,7,5])->get();

The example above returns all the users where the teamleader_id is not in [4,8,7,5] but in fact it ignore the rows where teamleader_id is null!

Is it possible to include also records where not in [4,8,7,5] but also null ?

Thanks

Mar
19
4 weeks ago
Activity icon

Replied to Need For Suggestions And Advices About Voice Streaming .

@bugsysha HHHHH lol no not what I need ... lol

Activity icon

Started a new Conversation Need For Suggestions And Advices About Voice Streaming .

Hello,

Let me explain my idea : I need to record sound (24/24 non stop recording ) and send it to the server of course.

I an another side the user should be capable to play this recording and skip to a specific time (example: 2 hours before)

I'm wondering if there is any specific packages or other solutions to make it possible.

Thanks

Mar
18
4 weeks ago
Activity icon

Replied to What's The Best Way To Create A Search Engine For My App

Thanks @bobbybouwmann ,

does meilisearch free or should I pay ?

Activity icon

Started a new Conversation What's The Best Way To Create A Search Engine For My App

Hello ,

I need to create a search engine for my application , this search engine should search into all tables,

I mean: search in products table and users table and almost everything ...

I'm thinking about Elasticsearch and Redis.

Any suggestions ?

Mar
11
1 month ago
Activity icon

Started a new Conversation JS: How To Search In A String Like (Match ... Against) In Mysql ?

Hello ,

To make my question more simple, let me give an example :

I have this array of object bellow,

let fullNames= [{
  "full_name": "Albertine Tuttiett"
}, {
  "full_name": "Angel Briant"
}, {
  "full_name": "Thorn Darrigoe"
}, {
  "full_name": "Fletch Gornall"
}, {
  "full_name": "Rorke Goadsby"
}, {
  "full_name": "Tadeas Bearham"
}, {
  "full_name": "Brina Asling"
}, {
  "full_name": "Madonna Goding"
}, {
  "full_name": "Aylmar MacGhee"
}, {
  "full_name": "Maighdiln Cotgrave"
}];

Is it possible to get results when I search in fullName even if the full name is not on the same order ?

Example : the origin value is Angel Briant but the user could type Briant Angel or Brian or Angel Briant word

Thanks.

Mar
10
1 month ago
Activity icon

Replied to Is It Possible To Affect Eloquent Condition To A Variable ?

@neilstee Thanks , In fact I want to avoid repeating this condition part , because I will use it in many places

Activity icon

Started a new Conversation Is It Possible To Affect Eloquent Condition To A Variable ?

Hello ,

I have a condition which decides if I will use whereIn or whereNotIn:

i need something like :

if ($x) {
	$var = whereIn('name',[(...)];
} else {
	$var = whereNotIn('name',[(...)];
}

$members = Users::$var->get();

Thanks

Mar
09
1 month ago
Activity icon

Started a new Conversation Is It Possible To Search In Two Fields Without The "key Search" Order ?

Hello ,

Let me first explain my current situation :

  • I have two fields city and country.
  • User can search in city and country at the same time , for example the key search could be : paris france or france paris or paris or france.

Current code :

->orWhereRaw("concat(city, ' ', country) like '%?%' ");

This code is working only if the key search have the same order (city + + country).

Question : Is it possible to search in city and country even if the order is not correct or having many blank spaces ...?

Example : franceparis

Mar
05
1 month ago
Activity icon

Started a new Conversation Javascript , How To Verify If A Property Of An Object Exists Or Not?

Hello ,

to make my question more simple : I will use the console.log();

when I console.log(this.var1); , if this does not exists it will returns undefined so I can use a simple condition like:

if(this.var1 !== undefined) {
// do this  and so that ...
}

But the problem is how to verify the property if it exists or not of an object that also I don't know if it exists or not ?

is there a way to avoid double check like:

if(this.var1 !== undefined && this.var1.proper1 !== undefined) {
// do this  and so that ...
}

Thanks

Mar
03
1 month ago
Activity icon

Started a new Conversation Vue Js : Child Component's CSS Is Overridden By The Parent Tag <h1>

Hello ,

First let me show you the parent component :

(...)
<div class="card-header">
                            <h1>
                                <company-edit :id="companyId" :key="companyId"></company-edit>
                            </h1>
</div>

(...)


<style scoped></style>

As you can see there is no specific styles.

component :

 <div class="form-group row">
        <label class="col-4 col-form-label pr-0" :for="'companyNameI"> Company name in-				 
                 house</label>
     <div class="col">
            <input (...)

<style scoped></style>

The problem is when I put <company-edit> inside <h1></h1> tag all the content of the <company-edit> is overridden by H1 style, and all the form labels are on H1 style!

Is there a way to "scope" the CSS of child component ?

Thanks

Mar
01
1 month ago
Activity icon

Started a new Conversation What's The Best Way To Convert Markdown To Html ?

Hello ,

I use an API that contains a markdown property and I would like to save it in DB as a HTML instead of markdown.

What's the best way to do that ?

Thanks

Feb
25
1 month ago
Activity icon

Started a new Conversation Laravel Validation Problem With Uploaded Image

Hello ,

I upload an image using FormData()(Javascript side) when I try to make a validation it's not working !

        $request->validate([
            'companiesLogos' => 'required|image|size:512',
        ]);

The validation error returns "The companies logos must be an image." even when I upload an image !

When I dd(request()->file('companiesLogos') the result is :

Illuminate\Http\UploadedFile {#1548
  -test: false
  -originalName: "5C51E427-1715-44E6-9B14D9487D7B7F2D_source.jpg"
  -mimeType: "image/jpeg"
  -error: 0
  #hashName: null
  path: "/tmp"
  filename: "phpEwa4h8"
  basename: "phpEwa4h8"
  pathname: "/tmp/phpEwa4h8"
  extension: ""
  realPath: "/tmp/phpEwa4h8"
  aTime: 2021-02-25 14:59:14
  mTime: 2021-02-25 14:59:14
  cTime: 2021-02-25 14:59:14
  inode: 917514
  size: 388750
  perms: 0100600
  owner: 1000
  group: 1000
  type: "file"
  writable: true
  readable: true
  executable: false
  file: true
  dir: false
  link: false
}

Any suggestion?

Activity icon

Started a new Conversation How To Update Specific Filed According To A Condition?

Hello ,

        $company = Company::find($id)
            ->update([
                "company_name" => $request["company_name"],
                "former_company" => $request["former_company"],
                "company_logo" => $imageName,
            ]);

Is it possible to update company_logo only if $imageName is not null ,

how to put this condition inside the ->update() ?

Feb
24
1 month ago
Activity icon

Replied to Is It Possible To Upload A File With Other Data On The Same Request ?

@bugsysha

In fact I thought that formData.append() is just adding to an object . but with the example of @tykus above it's now more clear for me.

thanks

Activity icon

Replied to Is It Possible To Upload A File With Other Data On The Same Request ?

@tykus

With axios.patch it returns an empty result !

but I tried to append the method in formData

            let formData = new FormData();
            formData.append('test', this.companyDetail);
            formData.append('companiesLogos', this.companiesLogos);
            formData.append('_method', 'patch');
            const headers = {
                'Encrypt': 'multipart/form-data',
            }
            axios.post('/api/companies/' + id,
                formData,
                {
                    headers: headers
                }
            );

and the result okay for the file but not for the data:

array:3 [
  "test" => "[object Object]"
  "_method" => "patch"
  "companiesLogos" => Illuminate\Http\UploadedFile {#1548
    -test: false
    -originalName: "cap1.PNG"
    -mimeType: "image/png"
    -error: 0
    #hashName: null
    path: "/tmp"
    filename: "php3QK5RO"
    basename: "php3QK5RO"
    pathname: "/tmp/php3QK5RO"
    extension: ""
    realPath: "/tmp/php3QK5RO"
    aTime: 2021-02-24 17:33:45
    mTime: 2021-02-24 17:33:45
    cTime: 2021-02-24 17:33:45
    inode: 917513
    size: 16735
    perms: 0100600
    owner: 1000
    group: 1000
    type: "file"
    writable: true
    readable: true
    executable: false
    file: true
    dir: false
    link: false
  }
]

As you can see test is just a string ("[object Object]") instead of object with multiple properties !

I verified the header in chrome browser and the encrypt is correct :

Encrypt: multipart/form-data <----------
Host: localhost:3000
Activity icon

Replied to Is It Possible To Upload A File With Other Data On The Same Request ?

@corvs

I try with this but it's not working ! it returns an empty array

let bodyFormData = new FormData();
            bodyFormData.append('userName', 'Fred');
            //bodyFormData.append('image', imageFile);
            axios({
                method: 'patch',
                url: '/api/companies/' + id,
                data: bodyFormData,
                headers: {'Content-Type': 'multipart/form-data' }
            })

Activity icon

Replied to Is It Possible To Upload A File With Other Data On The Same Request ?

@bugsysha

I try to add the header as you can see bellow :

let bodyFormData = new FormData();
            bodyFormData.append('userName', 'Fred');
            //bodyFormData.append('image', imageFile);
            axios({
                method: 'patch',
                url: '/api/companies/' + id,
                data: bodyFormData,
                headers: {'Content-Type': 'multipart/form-data' }
            })

In the update controller : I simply dd($request->all()) but the result is empty array [] instead to see "user_name"=>"Fred"

Activity icon

Started a new Conversation Is It Possible To Upload A File With Other Data On The Same Request ?

I try to upload a file with other fields like name, birth date , ....

the problem is : using Axios I have to use new FormData() and the problem of FormData is it sends data as a string. event with JSON.stringify()

If the sent value is different than String or Blob it will be automatically converted to String

source : https://developer.mozilla.org/en-US/docs/Web/API/FormData/append

My question : How to send a form data (including file) using Axios ?

Activity icon

Started a new Conversation How To Return Null Instead Of Undefined Using .find()

Hello

console.log([4, 6, 8, 12].find(isPrime)); // undefined, not found

In this example if there is no results it will returns undefined But is it possible to return Null instead ?

Thanks

Feb
23
1 month ago
Activity icon

Replied to All Properties Of The $request Are A String Type !

@tykus Is that means it's not possible to send a file and data on the same request ?

Activity icon

Started a new Conversation All Properties Of The $request Are A String Type !

Hello ,

I use Axios to send a form to update method :

            let form = new FormData();
            Object.keys(this.companyData).forEach((key) => {
                form.append(key, this.companyData[key])
            });
            form.append('companiesLogos', this.companiesLogos);
            form.append('_method', 'patch');

**************            
console.log(form.get('bic')); <------ here type is null
**************

            axios.post('/api/companies/' + id, form)
                .then((response) => {
                this.$refs.closeModal.click();
                this.companyUpdatedConfirmation();
            }).catch((error)=> {
                console.log(error.response.data.errors)
            })

in the controller : (update method)

    public function update(Request $request, $id)
    {
        dd($request->all());

The result:

array:38 [
  "id" => "704"
  "created_at" => "2021-02-17T11:58:03.000000Z"
  "updated_at" => "2021-02-23T12:23:58.000000Z"
  "name" => "0001 new company"
  "vat_number" => "null"
  "national_identification_number" => "null"

As you can see id should be integer but here it's a string and vat_number is null but here it's a string with the value "null"

in JS side : I did console.log(form.get('bic')); and the result as expected NULL which is correct

also it's not possible to apply the validation : 'vat_number' => 'required', when it's null (string)

Activity icon

Replied to I Can't Receive File From Axios Patch Method

@tykus thanks :

I modified some stuff and this works :

let form = new FormData();
            Object.keys(this.companyData).forEach((key) => {
                form.append(key, this.companyData[key])
            });
            form.append('companiesLogos', this.companiesLogos);
            form.append('_method', 'patch');
            axios.post('/api/companies/' + id, form)
                .then((response) => {
                this.$refs.closeModal.click();
                this.companyUpdatedConfirmation();
            }).catch((error)=> {
                console.log(error.response.data)
            })
Feb
22
1 month ago
Activity icon

Replied to How To Post Using Axios Without Object Key

@tykus Thanks for your answer ,

when I switch to axios.patch . I get this error : The POST method is not supported for this route. Supported methods: GET, HEAD, PUT, PATCH, DELETE."

my route is a resource type :

Route::resource('api/companies', 'CompanyController', [
        'only' => ['index', 'show', 'store', 'update', 'destroy'],
    ]);
Activity icon

Started a new Conversation I Can't Receive File From Axios Patch Method

Hello , I try to upload a file :

 <input v-on:change="onImageChange" type="file" class="custom-file-input" :id="'customFile'+id">
(...)
        updateCompany(id) {
            axios.post('/api/companies/' + id, {
                _method: 'patch',
                company: this.companyData,
                imageAvatar:this.imageAvatar
            }).then((response) => {
                this.$refs.closeModal.click();
                this.companyUpdatedConfirmation();
            })
        },
        onImageChange(e) {
                console.log(e.target.files[0]);
                this.imageAvatar = e.target.files[0];
                console.log(this.imageAvatar);
        }

But, in update controller the result is always empty and when I :

dd($request->hasFile('imageAvatar')); it returns false !

Any suggestion ?

Activity icon

Started a new Conversation How To Post Using Axios Without Object Key

Hello folks,

axios.post('/api/companies/' + id, {
                _method: 'patch',
                company: this.companyData
            })

Actually the companyData is also an object having all properties I need (id, name, date ...)

In fact, to access company name I need always pass by company because it's the root key so in my controller I have to : $request["company"]["name"],

I would like to remove the root key (company) and send the company detail directly .

Feb
18
1 month ago
Activity icon

Started a new Conversation How To Add A Specific Condition To The Validation Loop?

Hello ,

This is my validation bellow:

        $request->validate([
            'name' => 'required|unique:segments,name,NULL,id,user_id,'. auth()->id(),
            'segments.*.builder' => 'required|integer',
            'segments.*.value' => 'required',
        ]);

How to add an extra condition to this validation like :

if builder == 'abc' then value should be required AND integer

thanks

Feb
17
1 month ago
Activity icon

Replied to How To Use Multiple Arrow When Calling A Class Methods

this one works with me :

class BusinessTypeFetch
{


    private static $params = [];

    public static function setParams($businessTypeCountry, $businessTypeId)
    {
        self::$params = [
            "business_type_id" => $businessTypeId,
            "business_type_country" => $businessTypeCountry
        ];
        return new self;
    }

    public function getBusinessTypeName()
    {
        $param = self::$params["business_type_country"];
        // do something with $param ...
        return (....)

    }
}

Now I can call it like : BusinessTypeFetch::setParams('param1','param2')->getBusinessTypeName();

Feb
16
2 months ago
Activity icon

Started a new Conversation How To Use Multiple Arrow When Calling A Class Methods

Hello ,

class BusinessTypeFetch
{
 
    private static  $businessTypeCountry;
    public  $businessTypeName;
    private static $businessTypeId;

      static public function setParam($businessTypeId, $businessTypeCountry) {
        self::$businessTypeId = $businessTypeId;
        self::$businessTypeCountry = $businessTypeCountry;
    }
    public function fetchBusinessTypeName(){
          return "This is your params: ".self::$businessTypeCountry." ".self::$businessTypeCountry;
    }
}

what I'm looking for is to call fetchBusinessTypeName method after setParam

like : BusinessTypeFetch::setParam('995','8787')->fetchBusinessTypeName();

Is it possible ?