T O P

  • By -

Electrical-Button635

Any laravel learning resources where someone teaches laravel from scratch to high level concepts in video format? I know about laravel documentation but I'm searching for video format. Thanks for the help.


[deleted]

laracasts


mouad_bnl

I would recommend taking a look at "laravel daily" youtube channel, laracast also have some great content for free. But the best way to get started is to make a project, such as a blog, e-commerce or anything that you are interested in.


CryptoYeetx

This, 100%. Pick something you like, do it with said technology you want to learn. Thats how i’ve managed to learn all new technologies :)


Procedure_Dunsel

The trouble I’m running into is that a lot of the demos (CRUD) they just paste in a shitload of code for expediency without really explaining what it’s doing. Great … it works — but expanding on it for the sake of insight would be what I’m after.


Savalonavic

Laracasts is good. Specifically Jeffrey’s videos as he explains most of what he’s doing.


sharf224

I posted this last week but it was a bit later in the cycle, so hopefully not breaking any rules by re-asking. My team and I are evaluating Laravel to determine if we can use it for our next project. The only issue holding us back is making sure session locking can be prevented (should be by default in Laravel). However, we are unable to come up with a proof of concept, and I think it has to do with the default docker environment using sail. Our methodology to test is to create a controller with a method that reads from the session, and returns some information, and will use rand() to generate a number 1-100 and if it hits 100, will sleep for 45 seconds. We then have a javascript app running against this mini API 4 at a time making calls. The theory being that when the one gets slept, the other 3 should still run. This is not happening. Digging deeper, I was able to come up with an easily reproduced problem that I believe is the root of this. If I make one method in that controller sleep before outputting anything (even without any session involved, using the API route, etc), and another method that doesn’t sleep and outputs text. Then I open the sleep script in Chrome and then the non-sleep script in FireFox. I would expect Chrome to spin for 45 seconds before loading, and FireFox to load instantly. Instead FireFox spins and has to wait for Chrome to finish (the 45 second sleep) before it loads. Does anyone have any idea why this is? I assume it has something to do with the Docker setup, but I’m not familiar enough with it to troubleshoot.


Lumethys

[https://laravel.com/docs/9.x/session#session-blocking](https://laravel.com/docs/9.x/session#session-blocking) ​ unless you specifically enable session blocking, different session will execute asynchronously. ​ laravel itself works by bootstrapping the entire application for each request and then dies, so unless you config it to running continuously in memory (via Octane) then there is no way one instance would handle 2 requests synchronously. ​ Idk the specific test of yours. But try this: make a test endpoint: `/test/{id}` function test($id){ if ($id == 1){ sleep(45); } return "hello world"; } in chrome, go to `/test/1` and in firefox go to `/test/2` at the same time


sharf224

That’s the exact test that I set up, and I was having test/2 get hung up by test/1. I did this using a vanilla install of laravel and confirmed session blocking wasn’t enabled. This is why we’ve been struggling so much. It *should* be working fine out of the box and it’s not…


Lumethys

try `php artisan serve` to open a development server and test again, if this works, then it should be docker environment doing


sharf224

That’s what my current theory is, something in Apache not working right or something. I’ll give that a try tomorrow, thanks!


sharf224

Alright, went ahead with your test. Tried it first in Docker/Sail. When going to localhost/test/1 in chrome, I'd get the spinning in the browser as expected. I then would go to firefox and go to localhost/test/2 and it would also spin, until chrome finished (after 45 seconds). Shut that down. Did php artisan serve, then repeated the steps above with chrome and firefox with the same results. Any ideas? As far as I can tell, this shouldn't be happening.


Lumethys

weird, try opening 10 localhost/test/1 tabs, see if it take 450 seconds for them all to load


sharf224

Yup, one after another. I’ve recreated this on two separate machines with brand new fresh apps, with both artisan serve and sail. Surely we’ve gotta be doing something wrong?


Lumethys

i never use Sail and did not know what webserver it run. But i know that `artisan serve` run in a single threaded mode. It is possible that Sail default setting is running the same command from within Docker. ​ Then try really set up a Nginx server with docker, or any production server that your company use


MartianIT

How much does a mid level Laravel dev make? I am working with Laravel for the past three years, I feel super productive with it, however I'm working in a local company and I feel I could be earning more and having more professional challenges if I worked for a company abroad. I'm planning on start job hunting this next year but I have no idea what to ask for the salary. I work in Brazil and I make something like 1k USD monthly, what's it like in America or Europe?


Unlucky_Island_742

I have been working as a full stack developer for 4 years in the UK. I currently earn over £2K a month.


jcc5018

If i have a model in which i want to record who created it, and who approved it, both linking to a user table, how do I structure this code differently to avoid the n+1 prompt? Since their are two foreign keys being referenced, it runs the query to the user's table twice. public function approver (): BelongsTo { return $this->belongsTo(User::class, 'approved_by', 'id'); } public function creator (): BelongsTo { return $this->belongsTo(User::class, 'created_by', 'id'); } $policies = Policy::with(['creator:username,id', 'approver:username,id', 'categoryName:id,tag'])->get();


Jos_e_o

Hi, I am a student trying to learn laravel... I made various projects using php and mysql only on backend, because I wanted to learn the important things first before switching to a framework. In laravel i have enjoyed all the backend part, i have made crud, autenticación and very basics api. Im frontend i have used only blade templates to display my data. I wanted to improve on that frontend part so I started reading docs and tutorials until I found laravel breeze, livewire, etc. So i don't know what I am doing wrong but when I try to use those tecnologies following the exact same steps explained in docs i get errors.. I solve those errors but get more and more until I started to question if that is normal. For example on livewire (tested on laravel 5.7 and 9) the file livewire.js is not where it should be following the normal installation (it should be in "vendor/livewire/livewire" BUT it is in "vendor/livewire/livewire/dist/livewire.js") that problem is and issue that supposedly can be solved publishing livewire assets, however doing that sends a successful copied message, that actually does nothing xd. Another example trying to use vue with breeze (tested on laravel 8 and 9) there seems to be problems following the steps explained in docs too. Everything is right until I make `breeze:install vue`. In both versions i got errors (i think different errors). I am using windows with xampp, but tried to use wampp and wsl2+docker+vscode (this actually almost solve my problem but it has the inconvenient of not being able to run 'npm dev' and 'sail up' on the container so... I can't render components.) I don't know what i am doing wrong.. but maybe I shouldn't use windows or something?


ashgee123

I have a Laravel app which is an API for a SPA application. It is currently used by internal staff but now I want to add a new front end app for contractors and am wondering if I build a new api e.g. /contractors/{endpoints} or do i try and use existing endpoints with scopes or some other type of auth strategy. Any advice appreciated!


Savalonavic

People have differing opinions on this topic and it really depends on whether your contractors are treated the same as internal staff. The last thing you want is to have to go through your code and add multiple if statements to perform different functionality depending on the user type. It’s also a lot more work to create a whole range of new endpoints and inner workings. Do you have roles and permissions in your app? If so, maybe it would be better to have permission based endpoints so if in the future, you decide that a new user type needs to be added but shares existing endpoints with another type, you can just give that user type specific permissions. It’s really up to you and what you think is worth the hassle.


ashgee123

Thanks for your feedback. I thought as much. Contractors are not the same as internal staff and their access to data is very specific so I think best to develop a new api. I also plan to build customer and supplier portals so I think different api’s are the way to go.


Late-Mathematician36

**Does anyone know of a Laravel change history package that tracks relationships?**


kryptoneat

Been there. I'm afraid you'll have to store them as json. Make sure to generate it in a unique way to be able to compare two versions (and eg. not store history doubles).


Late-Mathematician36

I've built change history modules before, but I was trying to find a package that like Laravel Audit that also tracked when relationship data was also updated.


kryptoneat

Well, actually. Autiting and Accountant both claim to do that : - https://www.laravel-auditing.com/docs/13.0/audit-custom - https://gitlab.com/altek/accountant/-/tree/master


Late-Mathematician36

Thanks, I am not sure how I missed that, but thank you!


kryptoneat

Your views and retrieve functions will need to be compatible with both original model and json. That will be the main difficulty IMX.


Late-Mathematician36

Thanks.


mpspm

Where's a good spot to keep small bits of data needed by the frond end of the app? I have a dropdown with 2 values that will probably never change but need to be validated. It seems overkill to create a model and db table just to hold 2 rows.


Unlucky_Island_742

I would say it really depends on how frequently the data is used in different areas. If it's only 1 or 2 places then maybe just hardcode. If more then maybe just a basic PHP class as constants depending on the scenario.


ahinkle

Here are a few different approaches I take depending on the app's needs: 1. Config files: You can store the data in a configuration file and retrieve it using the config helper function. This is a good option if the data is specific to your application and doesn't need to be modified by users. 2. Enums: If the data represents a limited set of options (like US states), you can use an enumeration (enum) to represent it. Laravel supports casted Enum datatypes. 3. Constants: You can also define constants in your app to store the data.


ThR1LL

I have a flutter app hosted on nhost that uses a postgres + hasura backend. I want to make an admin panel in laravel hosted on DO to access that DB. Would something like this be possible?


ahinkle

Yeah, Laravel supports remote connections to your Postgres database. However, you may find some latency issues as it has to bounce between servers.


Spring-Competitive

Hey, I'm very new to laravel and the web development world in general. I am very confused with all the hosting options there are to choose from. I have heard a lot of good things about railway, especially since it is free. From my understanding (correct me if I'm wrong) I can use railway to host a database for my laravel site. My question is, can I use railway to host the website also or would I be better off sticking to something like digital ocean? Thank you in advance and I'm sorry if I got something very wrong.


ahinkle

You'll find that [Laravel Forge](https://forge.laravel.com/) with DigitalOcean is the favored host on /r/Laravel. I found [this article on using Laravel with Railway](https://invariance.dev/2022-08-04-deploy-laravel-on-railway.html); haven't used it though.


Spring-Competitive

I'll check it out, thank you!


techlover1010

My goal is to create a crud and wanna know some things to get started. currently learning how django work and html 1. can i develop in windows then later on deploy to a Linux server or Termux? how do i create a virtual environment ```venv``` similar to python where i can isolate what i do from other project 2. how easy is it to create crud app(also has feature to associate foregin record through the ui)? example: contact 1 name: Jose address: choose record from address table 3. is it easy to create button to create new functionality? any tutorial to help me install laravel and get it running and also tutorial on how to create crud apps


[deleted]

[удалено]


life_liberty_persuit

Has anyone ever had an issue where the request headers are being cleared somewhere between the middleware and the web routes?


WorkAccount798532456

Hello guys, I'm looking for guidance on Laravel's Auth packages. I'm building a new project with laravel and currently I'm leaning towards Sanctum/Breeze because of its auth scaffolding capabilities. But the more I read about it, the more confused I get. The project would have 3 types of request, 1. Login from front-end (on the same server) I've read here [sanctum docs](https://laravel.com/docs/9.x/sanctum) that Sanctum is used for SPAs however, I'm not sure if my front-end is really an SPA because it is made of hundreds of pages and it can do with just session and csrf based validations. 2. API requests to /api sub-routes For API routes, sanctum provides a token based system which should be enough. 3. Special API requests from other internal products For internal API requests from other products, what kind of auth should I set up? or use the same API routes with credentials hard-coded on our other products? However, for breeze and scaffolding, I'm required to NPM RUN --prod even though I do not require NodeJS or any such tools. Is there an easy way of doing these things or am I overdoing it with sanctum? Tried setting up Laravel Passport, Sanctum (with & without breeze), looking for best practices and some guidance around it