Talinon

Talinon

Member Since 3 Years Ago

Toronto

Experience Points
177,520
Total
Experience

2,480 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
905
Lessons
Completed
Best Reply Awards
137
Best Reply
Awards
  • start-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-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-token Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer-token Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • lara-evanghelist 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 36
177,520 XP
Nov
16
2 days ago
Activity icon

Replied to The GET Method Is Not Supported For This Route. Supported Methods: POST.

@chenchen11

First of all, your original post was a problem with posting to the /add endpoint. Now you're posting information on a /store endpoint. If you want help, please stop changing the code mid-way thru the discussion.

Secondly, the thread's topic is that you are getting the following error:

The GET method is not supported for this route. Supported methods: POST.

But, then you go to say that you're getting a 500 error. The above message should have resulted in a 405 error, not a 500. So, which one is it? There is a big difference if your app is returning a 405, which would suggest routing, or a 500, which indicates a problem with the actual code. I really have no idea what the issue is, because all you've been saying for the past few replies is that "it didn't work". In order to get quick and reliable help, you need to be clear.

@jlrdw How is adding a form method going to impact an axios post? Please explain.

Nov
15
3 days ago
Activity icon

Replied to Too Few Arguments To Function

@ain remove the $id parameter from the store method signature.

public function store(Request $request)

You're including the id within the post data, so you can retrieve it like so:

$upload_to_restock = Restock::findOrFail(request('id'));
Activity icon

Awarded Best Reply on Functions Works With Direct Route But Not When Referenced By Another Function

@fbc you just need to return from the function

return $this->devicedash($propertyid);
Nov
14
4 days ago
Activity icon

Replied to NotFoundHttpException In RouteCollection.php Line 179

@jlrdw That is not the problem - it's not even getting that far.

@rykhrdho falta um s no cliente

 <a href="clientes/{{ $cliente->id}}/editar" class="btn btn-default btn-sm">Editar</button>
Activity icon

Replied to Functions Works With Direct Route But Not When Referenced By Another Function

@cronix He provided an ellipsis indicating there is more to the method. According to the docblock it returns a response. He just needs to add a return statement in the calling method.

Activity icon

Replied to Functions Works With Direct Route But Not When Referenced By Another Function

@fbc you just need to return from the function

return $this->devicedash($propertyid);
Activity icon

Replied to Custom Broadcast Connection\driver?

@al.mootasem

I think it would be just a matter of creating a new class that extends Illuminate\Broadcasting\Broadcasters\Broadcaster.php

That implements a contract where you will need to provide the logic behind the methods auth(), validAuthenticationResponse() and broadcast()

You can take a look at Illuminate\Broadcasting\Broadcasters\PusherBroadcaster.php for an example on how Pusher is handled.

Once you create your class, you're going to need to register it with the framework. A good place for this would be within a Service Provider. You could either create your own, or you can probably just use the app/Providers/BroadcastServiceProvider.php already provided.

To register it, you would need to add something like this:

public function boot(BroadcastManager $broadcastManager)
{
    $broadcastManager->extend('mybroadcaster', function (Application $app, array $config) {
        return new MyCustomBroadcaster();  // you can optionally pass $config information into the constructor for your class
    });
}

Then just add it to your config/broadcasting.php file:

'connections' => [

        'mybroadcaster' => [
            'driver' => 'mybroadcaster',  // same as first parameter in extend()
            'options' => [
                //
            ],
        ],
Nov
13
5 days ago
Activity icon

Replied to How To Filter The Relationship Attributes In Laravel

@jlrdw I don't think this is what he is asking for. I think he is looking for a query to only return rooms AND attributes that meet the criteria.

@farshadf There are several options.

You can combine with() and whereHas(). Unfortunately, this would generate two queries, but it would work.

$constraint = function(Builder $q) use ($start_price,$end_price) {
            $q->where('price', '>=',$start_price);
            $q->where('price', '<=',$end_price);
};


return $query->with(['attributes' => $constraint])->whereHas('attibutes', $constraint)->get();

You could query all rooms with the constrained attributes, then filter out the rooms without the relationships. This would be a single query, but at the cost of performance in iterating over the entire collection to filter.


return $query->with([
            'attributes' => function (Builder $q) use ($start_price,$end_price) {
            $q->where('price', '>=',$start_price);
            $q->where('price', '<=',$end_price);
            }
        ])->reject(function ($room) {

        // remove room if it doesn't have the required attributes
        return !$rooms->attributes->count();

    });


If performance is vital, another option would be to use joins with Query Builder.

Activity icon

Replied to Syntax In If-statement Condition

got down to the bottom, not realizing it was resolved.

what is it you think is unresolved?

Why would you say the opposite of what I said

I found this amusing on a thread based on double and triple negation

Activity icon

Awarded Best Reply on Class 'Maatwebsite\Excel\ExcelServiceProvider' Not Found

Did you remove it with the composer remove command?

Have you ran composer dump-autoload?

You might need to clear your cache with php artisan cache:clear or manually deleting the bootstrap/cache/config.php file

Activity icon

Replied to Undefined Class Constant 'users'

@icelander There is nothing within that code that would trigger that error. The last line of the stack trace should tell you where to look.

Activity icon

Replied to Class 'Maatwebsite\Excel\ExcelServiceProvider' Not Found

Did you remove it with the composer remove command?

Have you ran composer dump-autoload?

You might need to clear your cache with php artisan cache:clear or manually deleting the bootstrap/cache/config.php file

Nov
12
6 days ago
Activity icon

Replied to Mocking In Feature Test

I have to head out.. if that doesn't work I'll check back in a couple hours.

Activity icon

Replied to Mocking In Feature Test

You're using it in a queue.. yeah, that won't work because of the closure.

Try this instead:

app()->offsetSet(MyClass::class, $this->mock(MyClass::class, function ($mock) {
    $mock->shouldReceive('someMethod')->once()->andReturn(new ResponseClass);
}));        

Activity icon

Replied to Mocking In Feature Test

Where do you get that error? in the test or the app code?

Could you paste the stack?

Activity icon

Awarded Best Reply on GroupBy Specific Key And Return The Collection

@untymage

$collection['catalogue2'] = collect($collection['catalogue2'])->groupBy('account_id');
Activity icon

Replied to GroupBy Specific Key And Return The Collection

@untymage

$collection['catalogue2'] = collect($collection['catalogue2'])->groupBy('account_id');
Activity icon

Replied to Mocking In Feature Test

@tobz.nz

It is expected behaviour to return a new instance when parameters are provided.

Check this reference for more details:

https://github.com/laravel/framework/issues/25041

To get around that, you should be able to make this work with rewriting your test:


$mock = \Mockery::mock(MyClass::class)->makePartial();

$mock->shouldReceive('someMethod')->once()->andReturn(new ResponseClass);

app()->bind(MyClass::class, function() use ($mock) {

    return $mock;

});

Activity icon

Replied to Mocking In Feature Test

@tobz.nz

How are you resolving MyClass from within your app code? If you are directly instantiating it with new then mocking will have no impact. You need to resolve it out of the container from within your app.

If you need further assistance, post your resource.store endpoint code and I'll try to help.

Activity icon

Replied to [***important Update***] Why Tinker Result Is Different Than Controller Result ?

I don't think the error is coming from your main apache2.conf, but the virtual host config:

AH00526: Syntax error on line 48 of /etc/apache2/sites-enabled/irp.******.com.conf:

Once you get the errors fixed, you should then be able to export the module list

Activity icon

Awarded Best Reply on Check If Endpoint Exists

@tobyreed

If I understand correctly, just modify the stopOnFailure configuration within your phpunit.xml file.

<?xml version="1.0" encoding="UTF-8"?>
<phpunit
    ...
         stopOnFailure="false"
    ...
>
    ...

This will wait until all the tests have ran before exporting all the errors.

Nov
11
1 week ago
Activity icon

Replied to Check If Endpoint Exists

@tobyreed

If I understand correctly, just modify the stopOnFailure configuration within your phpunit.xml file.

<?xml version="1.0" encoding="UTF-8"?>
<phpunit
    ...
         stopOnFailure="false"
    ...
>
    ...

This will wait until all the tests have ran before exporting all the errors.

Nov
10
1 week ago
Activity icon

Replied to Vue

@davy_yg

Open wide, here comes the spoon.

https://flaviocopes.com/vue-devtools/

Activity icon

Replied to [***important Update***] Why Tinker Result Is Different Than Controller Result ?

It might not be the root cause, but configuration errors certainly don't help. You should get them cleared up, or ask your network administrator.

Activity icon

Replied to Validation Is Filtering Out Fields Not Listed In Rules

@bigweld86 Maybe a silly question, but have you added the fields to the $fillable array within the Category model?

Activity icon

Replied to [***important Update***] Why Tinker Result Is Different Than Controller Result ?

Check to see what modules are installed on your web server.

For Apache: apache2ctl -M

For Nginx: nginx -V

Activity icon

Replied to Testing Rocks !

It is life altering :)

If you made descriptive function names, you have the added benefit of having all the features of your app documented.

Activity icon

Replied to [***important Update***] Why Tinker Result Is Different Than Controller Result ?

I bet if you ran that thru the PHP CLI it would also work properly, just like Tinker.

$ php -r "echo 'http://test https://';"

Maybe time to try reinstalling your webserver (apache/nginx)

Nov
09
1 week ago
Activity icon

Awarded Best Reply on How Tpo Get Convert Number To Word

You can use the NumberFormatter class with the Spellout rule-based format:

https://www.php.net/manual/en/class.numberformatter.php

Activity icon

Replied to How Tpo Get Convert Number To Word

If it's just a one time call, you could just wrap it in curly braces. Otherwise you have the option to make a helper function.

{{  (new \NumberFormatter("en", \NumberFormatter::SPELLOUT))->format(245000) }}

BTW - you may need to install the intl extension in PHP.

You could also give this package a try.. it supports 3 languages:

https://github.com/riskihajar/terbilang

Or this one:

https://github.com/kwn/number-to-words

You can likely find other solutions if you search around.

Activity icon

Replied to How Tpo Get Convert Number To Word

You can use the NumberFormatter class with the Spellout rule-based format:

https://www.php.net/manual/en/class.numberformatter.php

Activity icon

Replied to Laravel Concurrente Users

Ironically, about 200 :)

However, it hosts a suite of complex applications such as CRM, Project Management, Purchase Order System, etc.

It gets utilized by admins, operations, sales personnel, managers, foreman, etc. The load average is always quite low, and if it isn't, it's most likely something that I've done somewhere and no fault of the framework.

This is part of engineering - knowing what your app needs. Whether it's hardware, database optimization, caching, load-balancing, etc.

An unoptimized database (no indices) with a bad N+1 query would kill any app and is not specific to any one framework or language.

Activity icon

Replied to Laravel Concurrente Users

Well, there are smatterings of truth in that article. It's basically a blog on how to optimize your applications to ensure that you can handle higher traffic.

It's just like anything - if you have poor code, you'll have poor performance.

It's ridiculous to give a specific number of concurrent connections because each application has different uses and functions. There is no doubt in my mind a simple app built with Laravel can handle much more than 200 concurrent users.

Let's compare it to a silly analogy. A man buys two tomato plants and gives one to his neighbour. The neighbour knows a lot about gardening and knows that tomato plants love lots of sunlight, water and fertilizer. The other man just sticks the plant in a shady corner and neglects it. Over the growing season, the neighbour has a high yield of beautiful tomatoes, but the man who neglected his plant had very little. Does this mean the variety of tomato plant that he bought is susceptible to problems? Or did the man just lack the skills and knowledge to do the job properly?

Activity icon

Replied to Laravel Concurrente Users

@chievo sounds like conjecture. Where did you hear this? Any source you can link?

Nov
08
1 week ago
Activity icon

Replied to [***important Update***] Why Tinker Result Is Different Than Controller Result ?

And you're certain that your production code is up-to-date with your local code?

Go into your app/ directory on your production server and do a string search thru all your code for "test" and "http" and see if there is anything that could be causing it.

grep -rn "http"

grep -rn "test"

If that doesn't shed any light, then my professional analysis is that your server is borked.

Activity icon

Replied to [***important Update***] Why Tinker Result Is Different Than Controller Result ?

@mostafalaravel

Looking thru the framework code, it looks like mutators get cached. Try clearing your cache.

php artisan cache:clear

Would also explain the difference between local/production

Activity icon

Replied to [***important Update***] Why Tinker Result Is Different Than Controller Result ?

Alright, hold up a minute. I've reviewed the very start of this thread and something isn't adding up.

You originally said, here are your results:

Tinker:

 title: "training https: test after adding the permission: https",

Controller:

"title": "training  test after adding the permission: https",

phpPgAdmin:

training https: test after adding the permission: https

So Tinker and phpPgAdmin are correct.

I then asked you to dd($training); from your controller, in which you replied:

Here the result : it exists!

"title" => "training https: test after adding the permission: https"

Which is correct. So what is the problem here?

Am I correct in saying that this is only happening when the model is cast?

So what happens if you try this in Tinker?

App\training::find(7)->toArray();

Activity icon

Replied to [***important Update***] Why Tinker Result Is Different Than Controller Result ?

I'm running out of ideas... and I can't explain why there is a difference between local and production.

I don't think it's driver related because it works in Tinker.

You could try intercepting all queries to see if there is a clue there...

public function show($id)

\DB::connection()->enableQueryLog();

    {
        $training = Training::with([
            'trainers', 'categories', 'participants'
        ])->findOrFail($id);

dd(\DB::getQueryLog());

    }


Activity icon

Replied to [***important Update***] Why Tinker Result Is Different Than Controller Result ?

@mostafalaravel

I still don't understand where external_urls is coming from. You must have global scopes registered or something..

Try this:

public function show($id)
    {
        $training = Training::withoutGlobalScopes()->with([
            'trainers', 'categories', 'participants'
        ])->findOrFail($id);


        return $training;
    }
Activity icon

Replied to [***important Update***] Why Tinker Result Is Different Than Controller Result ?

@mostafalaravel

I've asked a few times what your models extend and whether it includes traits.

Paste your entire Training model here.

Here is another test to rule out model events.

Within your controller, add this:

public function show($id)

    \Event::fake();  // <-- add this line

    {
        $training = Training::with([
            'trainers', 'categories', 'participants'
        ])->findOrFail($id);


        return $training;
    }

Then see what it spits out.

Activity icon

Replied to [***important Update***] Why Tinker Result Is Different Than Controller Result ?

@jaytee

3.. @mostafalaravel is a troll and has gone afk, leaving us to debate this for days

Activity icon

Replied to [***important Update***] Why Tinker Result Is Different Than Controller Result ?

@jaytee I see your point. This just strengthens my suspicion that something is going on in a model event or something.

"training ftp: test aftehttps:r adding the permission:"

This result also is strange. Why did the "https" get inserted there? Seems like a garbage memory reference or something.

Activity icon

Replied to [***important Update***] Why Tinker Result Is Different Than Controller Result ?

@jaytee He put ellipses in the original post. I think he was just truncating the results for brevity?

Activity icon

Replied to [***important Update***] Why Tinker Result Is Different Than Controller Result ?

@mostafalaravel You shouldn't need to use git at all. vendor/ shouldn't be under version control. Just delete it and run composer install. Composer will restore your vendor directory according to your composer.lock file.

Activity icon

Replied to [***important Update***] Why Tinker Result Is Different Than Controller Result ?

@mostafalaravel

Are you 100% certain that nothing within the vendor directory has been edited? Maybe it's time to wipe out vendor/* and do a composer install.

This might explain why it's different between local and production.

Activity icon

Replied to [***important Update***] Why Tinker Result Is Different Than Controller Result ?

@mostafalaravel

I find it hard to believe that this is a bug in the Laravel core. Even if it were, I highly doubt it would result in a string replacement of "test". This screams developer influence from somewhere.

You have mentioned it happens on all models. You never answered whether or not the models extend Illuminate\Database\Eloquent\Model or something else?

Do you have bootable traits that could be affecting the attributes?

Do you have any registered model events or observers that could be firing? Such as on the retrieved event?

Activity icon

Replied to Autocomplete = "off" Not Working

Maybe try using something other than a label element?

You'll just need to try different things. It's annoying behaviour from Chrome that I don't think is documented anywhere, unfortunately.

Activity icon

Replied to Autocomplete = "off" Not Working

Try removing the for attribute and see if that bypasses it.

Activity icon

Replied to Is It A Bug ? "http:" And "https:" Strings Are Removed From Controller Results Event If They Exists In DB

@mostafalaravel

You were getting active help from the other thread. You never replied to the latest round of questions. Starting a new thread for the same problem is counter-intuitive. This thread is now missing the context of all the information and trial & error that was provided in another discussion. This just wastes everyone's time.

Activity icon

Replied to Autocomplete = "off" Not Working

@mostafalaravel

I once had this problem on a text field. No matter what I did, Chrome insisted on auto filling/completing. I eventually discovered changing the id/name of the element solved the problem. It's like Chrome has some hard-coded keywords it looks for and is bent on autofilling them. If the problem persists with the proposed hacks, try changing the id/name to something that doesn't contain "title" or "address", etc.