Talinon

Talinon

Member Since 3 Years Ago

Toronto

Experience Points 130,010
Experience Level 27

4,990 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 706
Lessons
Completed
Best Reply Awards 94
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.

17 Mar
1 day 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
2 days 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
3 days 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
4 days 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
5 days 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
6 days 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
1 week 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.

Talinon left a reply on Why Should I Use 'storage:link"?

@karlm89 Please close out the thread by marking Cronix with the best answer

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

What I'm trying to tell you is that that code you place within the Closure will not execute until you explicitly ask for it (resolve it) out of the Container.

   public function register()
    {
        Log::info('In register 1');
        $this->app->bind(BaseService::class, function ($app) {
            Log::info('In binding');
            return new BaseService(
                new Client(
                    [
                        'base_uri' => config('api.url'),
                    ]
                )
            );
        });

    // will resolve your binding out of the container and execute the code within the closure, including your Log
    dd(resolve(BaseService::class));

    }

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

You won't be able to debug what you've bound into the container until you try to resolve it out of the container. For example, if you try dd(resolve(BaseService::class)); your logging code should execute.

07 Mar
1 week ago

Talinon left a reply on Remove Null From A Collection

You're welcome. As suggested, you can also use the reject method. It's essentially the opposite, but you could drop the negative conditional and just use is_null()

Talinon left a reply on Remove Null From A Collection

You need to assign a variable to the returned collection:

$filteredCollection = $po_items->filter(function ($value) { return !is_null($value); });

         dd($filteredCollection);

Talinon left a reply on Remove Null From A Collection

$collection->filter(function ($value) { return !is_null($value); });

Talinon left a reply on Swap Class When Running Test?

@jorickl Glad you got it worked out :)

06 Mar
1 week ago

Talinon left a reply on If I Wan To Create Custom Login Panel , Custom Registraton Panel , What The Accurate Procedure

I'm certain he has a perfectly rational reason to do such a thing

Talinon left a reply on If I Wan To Create Custom Login Panel , Custom Registraton Panel , What The Accurate Procedure

Not exactly sure that you mean. You want to use another location for your login views? You can override the showLoginForm() method within your app/Http/Controllers/Auth/LoginController.php (from framework's AuthenticatesUsers trait) to return another view/location:

    public function showLoginForm()
    {
        return view('some.other.location.login');
    }

Talinon left a reply on Swap Class When Running Test?

You are still trying to instiantiate (new up) the class directly. Since that is not an interface, it is squawking because you can't instantiate an interface.

You need to place in your service provider:

$this->app->bind(TicketGatewayInterface::class, TicketAPI::class);

Then, instantiate your underlying implementation like so:

$connection = resolve(TicketGatewayInterface::class)->bookings($attributes);

Talinon left a reply on If I Wan To Create Custom Login Panel , Custom Registraton Panel , What The Accurate Procedure

@towhid Check your resources/views/auth folder to customize the out-of-the-box login views.

Talinon left a reply on Swap Class When Running Test?

You are on the right track.

$connection = (new TicketAPI)->bookings($attributes);

The problem with the above statement is that you are still directly "newing up" an instance of TicketAPI. What you want to do, is something like this:

$connection = resolve(TicketAPI::class)->bookings($attributes);

Or, better yet, look into swapping out your underlying service class by coding them to an interface. When you code to an interface, you can swap out the underlying implementation by updating a single binding (usually within a service provider)

04 Mar
2 weeks ago

Talinon left a reply on Public Folder Issue / .env File Related Issue

Hold on.. maybe I can help here.

From Laravel documentation:

After installing Laravel, you should configure your web server's document / web root to be the public directory. The index.php in this directory serves as the front controller for all HTTP requests entering your application.

Thread recap:

Simply set your webservers DocumentRoot to the /public dir of laravel

You have to change settings of root directory to be /var/www/your-app/public

Because you haven't set the DocumentRoot to be /public

DocumentRoot should be /your/path/to/laravel/public. public needs to be the last part.

Your DocumentRoot does not have /public

You still haven't added /public to the end of DocumentRoot

You might need to add public to your DocumentRoot?

02 Mar
2 weeks ago

Talinon left a reply on What Does It Take To Be A Very Good / Master In Laravel

There are a few dedicated series on Laracasts where Jeffrey builds a real-world application from scratch. They are excellent for gauging whether or not you're using best practices for modern web development.

Another thing you could consider is the Laravel Certification. If nothing else, you could skim thru all the things the exam covers here:

https://certification.laravel.com/prepare/

If you can go thru those topics and feel confident you are well-versed in each, then that would be a pretty good indication of your level. If you're very serious, you could consider taking the exam. If you pass that, then that would be reassurance of your competency.

28 Feb
2 weeks ago

Talinon left a reply on Can't Get Storage::delete() Method To Work

To delete a file from your public / folder, you would need to use PHP's unlink(), or use the File facade:

    $file = public_path() . "/{$photo->main_img}";
    \Illuminate\Support\Facades\File::delete($file);

    // or

    unlink($file);


25 Feb
3 weeks ago

Talinon left a reply on Basic Json

THERE ARE FOUR LIGHTS.

Talinon left a reply on Avoid Factories In Testing In Order For My Test Suite To Run Faster.

How much does your test suite slow down because of using a factory to create 4 rows? I find things like this are usually pretty negligible.

Are you using an in-memory database? That can speed up your tests drastically.

Another thing you could consider is using the DatabaseTransactions trait for some of your tests. If you are unfamiliar, it prepares your transactions, and then rolls them back at the end of the test, but it doesn't run migrations. So, what you could do, is create a testing database and seed it with your 4 rows. Then every time you run your test suite, your rows will be available.

Talinon left a reply on Php Artisan Not Working. Tried Almost Everything.

Since this happened since you tried to discover packages, I would think it would be a service provider for one of those packages. You wouldn't happen to have a versioned file of your composer.lock before running the command would you?

If not, you could do some trial error and disable package discovery:

Add this within composer.json:

    "extra": {
        "laravel": {
            "dont-discover": [
        "*"
            ]
        }
    },

and then run composer update and see if artisan works?

Talinon left a reply on Php Artisan Not Working. Tried Almost Everything.

I figured it wasn't the root of the issue. I just didn't want you to keep running the same erroneous command and not get anywhere :)

Try running it in verbose mode and see if it says anything? php artisan list -vvv

Talinon left a reply on Php Artisan Not Working. Tried Almost Everything.

php artisan:list

Could not open input file: artisan:list

This may not be your issue, but you are not running artisan correctly. That is not a framework error, but a PHP error. It is trying to open the file artisan:list, which obviously does not exist. What you want to run instead is: php artisan list

Talinon left a reply on Weird Auth Failure On One Route

Like anything, the more experience you gain, the more natural things will become. You'll learn what influences your application and where to look to resolve the problems. We all go thru these growing pains :)

Talinon left a reply on Weird Auth Failure On One Route

No problem, I'm glad we figured it out!

As I said, "something stupid" :)

You shouldn't need to clear the routes unless you cache them. Even if you haven't set up a specific caching method, a file cache would be set up by default. As long as you don't run php artisan route:cache, you shouldn't need to clear it. You generally only want to use cache your routes within your production environment.

Talinon left a reply on Weird Auth Failure On One Route

Try running php artisan route:clear and see if that helps?

Talinon left a reply on Weird Auth Failure On One Route

and don't get frustrated.. we, or someone else will get to the bottom of this. Laravel is an awesome framework, don't let something stupid like this cause you to miss out on a great experience.

Talinon left a reply on Weird Auth Failure On One Route

I've never used Spark, so I'm not sure if there is something obvious we're overlooking.

Getting the original error:

ErrorException: Trying to get property 'projects' of non-object

Is almost certainly being caused by this line:

$projects = auth()->user()->projects;

Which means that an authenticated user doesn't exist. But, if you're using the auth middleware, it shouldn't get that far. So, you are correct in your thinking.

Try checking your route list and make sure your routes are using the web middleware. If they are, the auth middleware should work. php artisan route:list

Talinon left a reply on Weird Auth Failure On One Route

Do you have your index() method defined on your controller? and does it have anything typehinted?

\Illuminate\Routing\Middleware\SubstituteBindings gets called on the middleware stack before your auth logic. You will often get this message if you try to auto-resolve something that doesn't exist, as the binding error will occur before auth middleware.

This usually would happen when you are using RMB to a specific resource. Getting it on an index method is strange, if you have nothing typehinted.

24 Feb
3 weeks ago

Talinon left a reply on People Think I Can't Code Because I Have Cerebral Palsy

I'm sorry to need to deal with that kind of prejudice.

I deal with construction people all the time.

There is usually a reason why they're in construction, using brawn rather than intellect. When is the last time you've seen a construction job be on budget? There is constant re-budgeting because someone didn't take something into account at the time of planning.

All the intelligent people pursued careers in medicine, law, engineering, (computer science/programming). All the leftovers went into construction.

22 Feb
3 weeks ago

Talinon left a reply on Best Way To Export Data In Xml And Csv Format

Have you sym-linked your storage? php artisan storage:link

Make sure you're using the right disk as well.

    return Storage::disk('local')->download($filePath); // for example

Talinon left a reply on Using Nl2br(e) On Data From Database

@jlrdw - I may be wrong, but I think you took what @lordbedwetter said the wrong way. I think we was referring to himself, saying that instead of making himself sound stupid trying to explain, he will just post a link.

shrug

Talinon left a reply on Moving A Method To A ServiceProvider Vs Model

I remember watching this video a couple years ago and being blown away by it. It changed the way I think about going about many tasks, and it's specifically about filtering:

https://laracasts.com/series/lets-build-a-forum-with-laravel/episodes/15

Talinon left a reply on Moving A Method To A ServiceProvider Vs Model

If it is a relatively simple operation, and you don't require that logic anywhere else other than from within your controllers, you could consider using a trait. Then you could just call something like $this->filterSomeData($data) within the controllers you need that logic.

If you require it elsewhere in your app, and it's not specific to any model, I would likely extract it to its own helper class. Then you would just need to instantiate it from wherever you need it.

Something like:

$filteredData = (new FilterSomeData)->filter($data));

You could place the logic within your model, if you feel its appropriate. I find that things like this can quickly lead to having fat models. I often find myself opting to create a helper class and have it be primarily responsible for that task.

Talinon left a reply on Best Way To Export Data In Xml And Csv Format

Sorry - I just read your previous post again.. you're asking saying there shouldn't be an associative array. You can use ``->values()`