Sinnbeck

Sinnbeck

Programmer at Aalund

Member Since 5 Years Ago

Hadsten

Experience Points
793,160
Total
Experience

0 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
179
Lessons
Completed
Best Reply Awards
1225
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.

Level 50
793,160 XP
Nov
24
4 days ago
Activity icon

Replied to Allow HTTP For One Route Only

Can you post your current nginx config for the site?

Activity icon

Replied to Allow HTTP For One Route Only

Just be aware that this will allow static content to be served over http as well then :) Maybe not a problem, but just informing you of it :)

Activity icon

Replied to Laravel Livewire Passwordless Login File_get_contents Error

It happens because the code expects you machine to be running linux (or mac), while you are on windows.

https://github.com/snapey/passphrase/blob/master/PassPhrase.php#L38

Change this like to

$filepath = Str::beforeLast($reflector->getFileName(), DIRECTORY_SEPARATOR);
Activity icon

Replied to Using Tailwindcss 2.0 In A Laravel8 Project

Consider creating a new thread where you explain your problem and what errors you are getting.

Activity icon

Replied to Laravel Guards Vs Gates

Guard: A way to sign in. This could be laravel default auth, or JWT etc. You can then use the guard to make sure that noone can access a route unless signed in.

Gates: Check if a specific user is allowed to go do a certain action.. Here the user is already signed in and we check the users permissions to ensure they are allowed to do a certain action. Perhaps normal users arent allowed to delete other user's accounts, but the admin user is.

Activity icon

Replied to Allow HTTP For One Route Only

Could you start by explaining why this is needed? Perhaps there is a better way :)

Activity icon

Replied to Laravel + Ant Design (Reactjs)

What part are you having trouble with? Perhaps you could use Inertiajs to bridge between react and laravel (I use it for that myself)

Activity icon

Replied to Undefined Index Url Laravel

First check what the actual content of sidebar.items is

{{dd(config('sidebar.items')) }}
Nov
20
1 week ago
Activity icon

Replied to Pluck() Grabbing All Images Instead Of Just One

->pluck() is used to extract a certain field from a collection (or multiple rows) of data

->first() is used to get the first item :)

Activity icon

Replied to How Can I Recall A Created Command?

Sorry not quite understanding what you are saying? Do you mean you reacted the command with php artisan make:command NewCommand ?

If so you can find it in app/Console/Commands

In the file you can change this line to what you want to call it

protected $signature = 'do:stuff';

And call it with php artisan do:stuff

Activity icon

Awarded Best Reply on Npm Error

You might be running off of ubuntus default which is oooold :p Install a ppa and you will get a much newer version: https://www.digitalocean.com/community/tutorials/how-to-install-node-js-on-ubuntu-18-04 Scroll to "Installing Using a PPA"

Activity icon

Replied to Using Inertia With Modules

What error are you getting now? Please show the actual code, path and error. :)

Activity icon

Awarded Best Reply on Class 'App\Http\Controllers\...' Not Found, When Trying To Access From Different Controller

Sounds like you are missing an import at the top of your controller

use App\Models\Team;
Activity icon

Replied to Using Inertia With Modules

And you are passing down the complete path?

return Inertia::render('full/path/to/Index');
Activity icon

Replied to Class 'App\Http\Controllers\...' Not Found, When Trying To Access From Different Controller

Sounds like you are missing an import at the top of your controller

use App\Models\Team;
Activity icon

Replied to How Do You Usually Use Git?

Yeah that is my way of deploying as well :) I just use envoy to do it instead

Activity icon

Replied to Using Inertia With Modules

You could perhaps pass down the full path?

resolveComponent: (name) => require(`${name}`).default,
Activity icon

Replied to Model Constant To Controller

Well why do you need to pass it to the model? All is does is just '$this->amounts[$rank]`

Activity icon

Replied to How Do You Usually Use Git?

I do it directly on the production server. As you can see in the linked script, i do it in a new folder, and then symlink to that once it is complete. I always have 5 folders with the 5 newest releases.

Activity icon

Replied to Using Inertia With Modules

Well require()needs the path to the file it has to load. So you need to specify where it can finde the file

I have no knowledge of your structure but here is an example

resolveComponent: (name) => require(`../../modules/UserModule/js/Pages/${name}`).default,
Activity icon

Replied to Model Constant To Controller

Why not keep it in the model, and make it public?

public const AMOUNTS = [
    'Basic' => 0,
    'Junior' => 100,
    'Premium' => 150,
    'Advanced' => 200,
    'Senior' => 250,
];

in controller

$amount  = Model::AMOUNTS['Basic'];
Activity icon

Replied to Npm Error

You might be running off of ubuntus default which is oooold :p Install a ppa and you will get a much newer version: https://www.digitalocean.com/community/tutorials/how-to-install-node-js-on-ubuntu-18-04 Scroll to "Installing Using a PPA"

Activity icon

Replied to Npm Error

Sounds like you are running quite old versions of node and npm

I have

node -v
v14.15.1

npm -v
6.14.8
Activity icon

Replied to Model Namespaces Shortcut

Why? That sounds like quite bad practice?

You can probably get away with just resolving it from the service container as a string

$myModel = app('MyModel');
Activity icon

Awarded Best Reply on Eloquent , How To Check If The Row Was Updated ?

You need to use whereColumn('column1', 'column2') when comparing columns

Activity icon

Replied to How To Display Data In The Blade View Via API

Well then you need to either

  1. just pass the data directly to the view in the actual controller
  2. learn javascript to request that data
Activity icon

Replied to Npm Error

Nothing that wasnt caused by myself. What errors are you getting? (Ubuntu 20.04 here but should be the same)

Activity icon

Replied to How To Display Data In The Blade View Via API

Are you getting this data using some javascript? Can you show it?

Activity icon

Replied to Using Inertia With Modules

I am unsure how that is related? All it does is check if there is a file ./Pages/Index.vue (or jsx or js). Isnt the app.js file in the same directory as the Pages directory?

Activity icon

Replied to Eloquent , How To Check If The Row Was Updated ?

You need to use whereColumn('column1', 'column2') when comparing columns

Activity icon

Replied to Jetstream | Inertia.js - How To 'return Back()->with()'

I personally use it like this, and it works perfectly

return redirect()->back()->with('success_message', 'Yay it worked');
Activity icon

Replied to Restrict Captcha Route Call Only Through Register View Blade

You could probably make a signed route url, that expires in a few seconds, and use that instead of the direct link.

https://laravel.com/docs/8.x/urls#signed-urls

Activity icon

Replied to How Do You Usually Use Git?

I always use git to handle everything. Of course you will need to be aware to put installed packages (composer or npm) in the correct place (dev and none dev) but in case of composer, your test environment should catch that.

Personally I use laravel envoy (the package), to handle all deployments. I have set up scripts to ssh into the server, do at git reset, git pull and then install everything (composer and npm install), and then recompile assets for production.

If any of this is confusing, feel free to ask a follow up question or two :)

Edit: For reference, my envoy workflow is actually similar to this https://github.com/spatie/freek.dev/blob/master/Envoy.blade.php

But to get you started you can probably get away with something like this (replace ip and path)

@servers(['production' => ['[email protected]']])

@task('deploy', ['on' => 'production'])
{{ logMessage("🏃  Starting deployment...") }}
cd /path/to/project
git reset --hard
git checkout master
git pull origin master
composer install --prefer-dist --no-scripts --no-dev -q -o;
php artisan migrate --force
npm install
npm run prod
@endtask
Activity icon

Replied to Collection Method WhereBetween Acting Weirdly

I see no way that should work, unless $startDate is a string and $endDate is an array with both dates.

This is the actual code being called https://github.com/laravel/framework/blob/5.8/src/Illuminate/Support/Collection.php#L745

Can you show a dd() of both start and end date?

Activity icon

Replied to Laravel ReactJs

I just use Echo from laravel. I set up a lister in a useEffect().

https://laravel.com/docs/8.x/broadcasting#installing-laravel-echo

Example (be aware that this is written from memory, so you might need to tweak it slightly for it to work)

useEffect(() => {
    const channel = window.Echo.channel('orders');
    channel.listen('OrderShipped', (e) => {
        //do something with the data
    });

   return () => {
         channel.stopListening('OrderShipped');
   }
}
Activity icon

Replied to Loop Through Language File To Make A List Of Keys In Blade View?

Here is how I load all language files into dot format (and with translation) for one of my packages. You can probably modify it to your needs :)

https://github.com/sinnbeck/laravel-langcheck/blob/main/src/TranslationLocator.php#L45

Nov
19
1 week ago
Activity icon

Awarded Best Reply on Laravel ReactJs

Either you need to use a timer (it is called polling), or you can use websockets :) Polling is alot easier to implement, but websockets are awesome as you can push anything to the client (i use it for chat myself)

https://laravel.com/docs/8.x/broadcasting#pusher-channels

Activity icon

Awarded Best Reply on How To Substract From The Oldest Row?

  1. Grab like 5 rows from the database.
  2. Loop over them and subtract the stock and update
  3. If hitting number 0, use break to exit
  4. If loop is over and number is over 0, run it all again (eg make it a method)
Activity icon

Awarded Best Reply on Using .php File...where To Put It

Inside the public directory (next to the index.php file)

Activity icon

Replied to I Want Share Data To All Views

Inline version in service provider would be

public function boot()
{
    view()->composer('*', function($view)
    {
        $notice = collect();
        if (Auth::check()) {
            $notice = DB::table('tickets')
                ->where([['user_id', '=', $userId], ['notice', '=', 2]]) 
                ->get();
        
        }

        $view->with('notice', $notice); 
    });
}
Activity icon

Replied to I Want Share Data To All Views

Give Michals answer with a view composer a shot instead then :)

Activity icon

Replied to HTTP Status Codes

Oh yes agreed. I mean when using some external api. If they return a 404 code when the error is something else. By just looking at an error code, I often know the error instantly

Activity icon

Replied to Passing Values From Routes To Controller Functions

Why does the route need to know anything about it? Can't the controller handle it directly?

Activity icon

Replied to I Want Share Data To All Views

Give some more information. "it's not working" helps no one :)

Not at my computer now, but you can try request()->user()->id

Activity icon

Replied to I Want Share Data To All Views

public function boot()
    {
        $userId = Auth::user()->id;

        $notice = DB::table('tickets')
                            ->where([['user_id', '=', $userId], ['notice', '=', 2]])
                            ->get();
        View::share('notice', $notice);
    }
Activity icon

Replied to HTTP Status Codes

Making me able to simply look up a code quickly and see what when wrong (or just recall it from memory) is alot better than being expected to see some homemade error string that might be hard to decode.

An example is 429. I instantly know it its too many requests (instead of guessing the meaning of "you are too eager" or some other random text)

Activity icon

Replied to I Want Share Data To All Views

Don't share it from the controller. Share it from a service provider. Check the link. Move your code there

Activity icon

Awarded Best Reply on RabbitMQ Error GetChannel

Good to hear it's solved.

For the other issue. Sounds like rabbitmq isn't running on you machine?

Activity icon

Replied to RabbitMQ Error GetChannel

Good to hear it's solved.

For the other issue. Sounds like rabbitmq isn't running on you machine?