Talinon

Talinon

Member Since 3 Years Ago

Toronto

Experience Points 134,980
Experience Level 27

20 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 716
Lessons
Completed
Best Reply Awards 101
Best Reply
Awards
  • Start Your Engines Achievement

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • First Thousand Achievement

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • One Year Member Achievement

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • Two Year Member Achievement

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • Three Year Member Achievement

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • Four Year Member Achievement

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • Five Year Member Achievement

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • School In Session Achievement

    School In Session

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

  • Welcome To The Community Achievement

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • Full Time Learner Achievement

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • Pay It Forward Achievement

    Pay It Forward

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

  • Subscriber Achievement

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • Lifer Achievement

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • Laracasts Evangelist Achievement

    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 Achievement

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • Laracasts Veteran Achievement

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • Ten Thousand Strong Achievement

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • Laracasts Master Achievement

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • Laracasts Tutor Achievement

    Laracasts Tutor

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

  • Laracasts Sensei Achievement

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • Top 50 Achievement

    Top 50

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

24 Mar
14 hours ago

Talinon left a reply on How To Run A Decent SetUp() In Laravel Dusk

Try adding a void return type:

 public function setUp() : void

Talinon left a reply on Is There A Way To Persist Certain Tables Between Tests?

@alexgodbehere php artisan migrate --database=mytestingdatasename

Talinon left a reply on Is There A Way To Persist Certain Tables Between Tests?

You might want to consider using the DatabaseTransactions trait. You can seed your database once, and DatabaseTransactions will still roll back the test transactions at the end of the tests, but won't run the migrations; meaning your seeded data will persist thru the tests. The only thing you need to be mindful of, is you will need to manually run the migrations on your test database to bring them up-to-date when you make changes to your database structure.

22 Mar
2 days ago

Talinon left a reply on Where To Use Vue In Laravel

@kinsaw88 what you are referencing is a View component, which you would need to register as a component for Vue to mount.

Instead of trying to go into great lengths to explain, I would suggest watching the entire free series on Vue. You'll be taken by the hand and shown every step of the way.

https://laracasts.com/series/learn-vue-2-step-by-step

Talinon left a reply on How To Remove Item From Cart Through Session Laravel 5.6?

@mubeenali Did you write the original Cart code above, or are you editing an existing project?

Talinon left a reply on Using Mockery, But Original Method Still Being Called

There seems to be a problem with return types and previous versions of Mockery. Most likely because the version of Mockery you are using is based upon a PHP version that didn't support return types.

Talinon left a reply on How To Remove Item From Cart Through Session Laravel 5.6?

@mubeenali There is no short-cut to just remove it from the session - because how is your qty and prices supposed to update?

You need to pretty much do the same thing you're doing when you're adding to your cart.

Get the cart from the session, instantiate your Cart class with the session data, call a method that handles the remove logic, and then put it back into the session.

Talinon left a reply on How To Remove Item From Cart Through Session Laravel 5.6?

Unsetting the product from your Request object isn't going to remove it from the session.

It looks like you might want to add a remove() method to your Cart class, and then update the session?

Talinon left a reply on Using Mockery, But Original Method Still Being Called

Try removing the return type:

From:

public function createUser(User $user): void

To:

public function createUser(User $user)

Talinon left a reply on Using Mockery, But Original Method Still Being Called

Do you have final defined on your createUser() method in your IntercomGateway class?

Talinon left a reply on Using Mockery, But Original Method Still Being Called

Yes, you should get 'mocked' as a response. I'm not sure why you would get ``null`

I just tested it using the following, and I get 'mocked`

        $mock = \Mockery::mock('someclass')->makePartial();
        $mock->shouldReceive('createUser')->andReturn('mocked');
        $this->app->instance('someclass', $mock);

        $gw = resolve('someclass');

        dump($gw->createUser(new \App\User));        

Talinon left a reply on Using Mockery, But Original Method Still Being Called

@bwrigley You are still instantiating an instance of IntercomGateway directly in your test:

$gw = new IntercomGateway;

If you resolve it out of the container, it should work:

$gw = resolve(IntercomeGateway::class);

dump($gw->createUser(new \App\User));

Talinon left a reply on Using Mockery, But Original Method Still Being Called

Have you imported IntercomGateway in your test?

Talinon left a reply on Add Additional Login Condition.

I can see valid points on both sides of the argument.

It does seem odd to login in a user, only to turn around and log them out on an additional check. Maybe you (or some other team member) changes something to the related table structure/data which causes the check to break.. then your user stays logged in.

Make no mistake - overriding the login method like you have would work. The question really is, what is the best solution. I don't really see a big issue with what you've done. I've done something similar when I needed to handle a non-standard LDAP authentication login. As @snapey mentioned, just be mindful that you might need to re-evaluate your login logic when you go to upgrade your app.

Talinon left a reply on Mocking Class Doesn't Work

@ Glad that solved the issue. I'm sure we've all had that issue at one point in our career.

Please mark the thread as closed.

Talinon left a reply on Mocking Class Doesn't Work

Make sure you have Foo imported, you use the full namespace in your test. Otherwise it will be mocking Tests\Foo instead.. which I suspect is the issue.

Talinon left a reply on Mocking Class Doesn't Work

@yoeriboven Mocking a class within your test does not magically change your application code.

When you make your get request, your application routes it to your HomeController, which automatically resolves and instantiates a new instance of Foo. Your mocked object has no influence on this.

Instead, if you bound something into the service container which you use to resolve Foo, then you could swap that binding with your mock implementation.

For example:

/** @test */ public function it_mocks_bar() { $this->mock(Bar::class, function ($mock) { $mock->shouldReceive('action')->andReturn('Mocked value'); });

$this->app->instance(Foo::class, $mock);

$this->get('/');

}

Now when your application tries to resolve Foo, it will return your mocked object.

21 Mar
3 days ago

Talinon left a reply on Weird Template Or Render Function Not Defined

@shaqaruden Are you importing or requiring Vue? (in your main.js)

If you are using import, then you are getting the runtime build, which means you can't compile templates.

window.Vue = require('vue');

Talinon left a reply on Coming Soon Page While Admin Can Still Work In Backend

You could easily set up an IP exemption within your App\Http\Middleware\MaintenanceModeExceptions.php file.

Something like:

public function handle($request, Closure $next)
{
    
    
    if (!$this->exemptIps($request))
    {
    
        if ($this->app->isDownForMaintenance()) {
            throw new HttpException(503);
        }
        
    }

    return $next($request);
}


/*
 * Check to see if the HTTP request is from our exempt IPs
 * 
 * @return boolean
 * 
 */
private function ExemptIps($request)
{
    
    return in_array($request->getClientIp(), config('app.exempt_maintenance_ips', []));
    
    
}

Then add an array of IPs to your ``config/app.php`` (or whatever file you want)

Then you just need to code the admin backend to handle the artisan calls.

Talinon left a reply on Report Bug Function To Remote Database

I would suggest taking a look at bugsnag - bugsnag.com

They support laravel. You just apply your API key which they provide you, and your errors automatically get collected on their platform for your convenience.

They provide lots of management tools too, such as marking bugs and assigning them to team members, etc.

Talinon left a reply on Laravel Ajax - Put Request 500 Internal Server Error

@sunnyboy You would get around it by method spoofing, just like HTML forms. That is what the _method field does.

I'm not suggesting this is your problem, just something to test to rule out with trial & error.

Talinon left a reply on Catching 505 Request In App\Exceptions

You could check for the status code within the app/Exceptions/Hander.php

public function render($request, Exception $exception)
{

    if ($exception->getCode() == 505) {

        // caught

    }

    return parent::render($request, $exception);
}

Talinon left a reply on Session Not Persisting

Are your routes included in the web middleware? If not, the session will not start/work.

Try checking php artisan route:list to confirm

Talinon left a reply on Laravel Ajax - Put Request 500 Internal Server Error

If it works locally but not in your shared environment, it's possible your provider has configured the webserver to disallow some HTTP verbs.

If you're getting an HTTP 5xx error, and there is nothing within the Laravel log, then I would conclude it's being blocked at the server level and the request isn't even reaching Laravel.

As @jlrdw mentioned, try changing it to POST just to see if it goes thru.

You could also try sending something via Postman and see what response you get.

18 Mar
6 days ago

Talinon left a reply on Mock Error In PhpUnit Test

You are mocking EmailList, but still end up instantiating an object and passing it to your function. This ends up calling pluck() on an actual instance of EmailList, and not your mock.

Have you tried passing your mock instead?

 $actual = $this->sut->getDoNotEmailers($mock):

Talinon left a reply on Query Relationship Returns Wrong Values

@joshblevins what data type is your performance_rating field?

Talinon left a reply on Clean My Code Of \Log::

This might place you on the right track (at least for models):

https://laravel.com/docs/5.8/eloquent#events

Talinon left a reply on Query Relationship Returns Wrong Values

You are passing a string, change it to be numeric:

$q->where('performance_rating', '<', 80);

Talinon left a reply on Clean My Code Of \Log::

Any editor worth mentioning will have a "find & replace" feature. Just do a global search for "Log::" within your app/ directory, and clear them out.

Talinon left a reply on How To Manage Files In Database

@kisaw88 Yes, that is correct.

You just need to write the application logic to determine what the path will be, and persist the path to the database. That is a better alternative than storing binary pdfs directly into the database.

Talinon left a reply on Lumen Session Not Persisting On Every Request

@xxrockonxx I'm glad you got it figured out!

Talinon left a reply on How To Manage Files In Database

@You technically could store it within the database, with a binary BLOB type.

$table->binary('pdf');

But, I still wouldn't recommend doing it. Storing the PDF on the disk and referencing a file path would be a better practice.

17 Mar
1 week ago

Talinon left a reply on Laravel Broadcasting To Private Channel Fails

@mohamadsleimanhaidar If you have imported it as you say, you should not be receiving that error.

Are you sure you imported it typo free? Are you sure that is the file and line where the error is being thrown?

Try instantiating it with the full namespace:

public function broadcastOn()
{
    return new \Illuminate\Broadcasting\PrivateChannel('invitation.' . $this->message->to);
}

If you still get the same error message, then the problem lies elsewhere.

16 Mar
1 week ago

Talinon left a reply on How To Output Only The Difference In Values In An Array To A Chart?

The reason you're getting the 150 offset error is because of your for loop. You are looping while $i is 150 or less, but since an array starts off with a key of 0, you only want to go to 149. Simple change your comparison operator:

 for ($i = 0; $i < sizeof($realtime_data_array); $i++) {
15 Mar
1 week ago

Talinon left a reply on Auto Model Binding? ? ?

Yes, it is supposed to behave like this.

What are are experiencing is referring to as "lazy loading" - where the data is not queried until it is specifically requested. However, be careful with this technique, because you can easily fall into a trap known as the dreaded N+1. When you don't call with() or load() to query your relationships, EVERY single time you go to reference the relationship, it will hit the database with an extra query. If you had a loop of 1000 tags, you will have 1000 queries to the database. So, even though this works, you need to understand why.

I suggest installing a very well known package: barryvdh/laravel-debugbar It will easily show you how many queries your app is generating, and you can easily isolate the offending lines within your code.

Talinon left a reply on Faker To Generate 2-3 Letters Word

You don't really need faker for this.. you could just do strtoupper(Str::random(3));

Talinon left a reply on Status Code: 405 Method Not Allowed Message: "The PUT Method Is Not Supported For This Route. Supported Methods: GET, HEAD, POST."

That is an entirely different issue than the one you raised, which I provided a solution for. But sure, mark yourself the best answer. That'll be the last time I assist you.

14 Mar
1 week ago

Talinon left a reply on Status Code: 405 Method Not Allowed Message: "The PUT Method Is Not Supported For This Route. Supported Methods: GET, HEAD, POST."

It was a typo. I blame that on trying to reply with a phone. But come on, you should be able to problem solve that...

url: "{{ url('/modules/', [$module->id]) }}", 

Talinon left a reply on Status Code: 405 Method Not Allowed Message: "The PUT Method Is Not Supported For This Route. Supported Methods: GET, HEAD, POST."

Either change your route to remove the {module} parameter and retrieve the resource within the controller via the payload, or add the id to the url

``$.ajax({ method: "POST", url: "{{ url('/modules/', [$module-id]) }}", data: str })

Talinon left a reply on Archive Multiple Tables In A Laravel App

Well, one thing you could is this statement: create table user_archive LIKE users You will instantly have a cloned table with the full schema, without the data. Take note that things like indices and triggers will also be cloned to the new table.

You would need to remember that the archived tables are not part of your app's database migrations, which may be fine. Just something to keep in mind. Or, I guess it would be possible to include the statement in a migration file.

Something like:

public function up()
    {
        \DB::statement('CREATE TABLE user_archive LIKE users; ');
    // whatever other tables
    }

public function down() {

Schema::drop('user_archive');

}

Talinon left a reply on Vue Login Vs Standard Form

I second what @wilk_randall said. I just recently incorporated a Vue login form, and I see no issues with it. I think it improves the UX and is pretty slick. As for that comment, it holds no weight with me because he didn't bother to explain why. I can throw around baseless claims all day long, it doesn't make it true.

Most of the comments are just referring to the fact you might need to take other things into consideration, such handling what happens if sessions expire.

Talinon left a reply on Status Code: 405 Method Not Allowed Message: "The PUT Method Is Not Supported For This Route. Supported Methods: GET, HEAD, POST."

You are preventing the default action within your javascript, so it has nothing to do with the markup.

The problem is here:

$.ajax({
            method: "POST",
            url: "{{ url('/modules') }}",   <--- you only have routes for GET,HEAD,POST for /modules
            data: str
        })

You need to add your id parameter to the url

Talinon left a reply on How Development Process Works After Production?

@abdulaziz I set up a remote repository on the production server where I can push up changes. I then have a on-receive hook which runs a script that applies the codes changes and executes any tasks (artisan command to recache configs, npm, gulp, whatever)

So, in other words, I type 1 command and the magic happens. For example, to push all changes on the master branch to the production repository: git push master production

This tutorial helped me learn the basics to set it up:

http://www.krisjordan.com/blog/2013/11/02/push-to-deploy-with-git

13 Mar
1 week ago

Talinon left a reply on Duplicated Insertions

This is probably just a matter of perfect timing from simultaneous requests. I think this comes down to two choices.

  1. As you have already mentioned - adding a unique index to the table will certainly prevent duplication.

  2. Use database transactions to lock the table while one operation is being carried out. In the event of a deadlock (which would be your 1 in 10,000 recurrence issue) you could handle it by simply catching the exception and ignoring it, if that is appropriate.

https://laravel.com/docs/5.8/database#database-transactions

Talinon left a reply on List Users In Alphabetical Order With Auth User In First Position

If you always want the same item in the first position for each page, you could do:

   public function index()
    {

        $users = User::orderBy('name', 'asc')->where('id', '!=', auth()->id())->paginate(10);

        return $users->prepend(auth()->user());
    }
12 Mar
1 week ago

Talinon left a reply on Vue: Accessing Specific Item Inside Array Of Objects

You don't have an index value for your JSON array.

Try this:

data() {
    return {
        errorInfo: {
                "404": { message: 'Oops, parece que algo salío mal! Intentelo más tarde.' },
                "503": { message: 'Estamos de mantenimiento, disculpe las molestias.' }
        }
    }
},
11 Mar
1 week ago

Talinon left a reply on Vue And Laravel - Ais-configure

You should be able to assign the filters using an expression:

<ais-configure
    :hitsPerPage="8"
    :filters="'category:' + category + ' AND country:' + country"
/>
08 Mar
2 weeks ago

Talinon left a reply on Bind Method Not Being Called In Service Provider

The short answer to your question - no, you don't resolve it at the end of the Service Provider; I just placed that there as an example on why your debug code wasn't firing.

When you bind something into the container, you're essentially making it globally accessible from anywhere in your app, along with the dependencies. Each time you need it, you can resolve it out of the container. If you want the same instance resolved each time, you will want to bind a singleton, otherwise, it will instantiate a new instance of your binding upon each request.