Browse AI Field GuideForum Podcast
All ThreadsLeaderboard
  1. Discussions

    1. Popular This Week
    2. Popular All Time
    3. Solved
    4. Unsolved
    5. No Replies Yet

jaspercreel's avatar

Eager loading a relationship returning empty

Hi all, Eager loading a many-to-many relationship with a "wherePivot" clause is making it empty, even though there is data. I can do this: $thing->relations; and there is data. But if I do this: $thing->load('relations'); it is empty. The relationship looks like this: public function relations() { return $this->belongsToMany(Relation::class)->withPivot

jaspercreel's avatar
jaspercreel's avatar Snapey6mos agoEloquent
2
1
Last reply by Snapey 6mos ago
SeanKimball's avatar

Scoped bindings on controllers using traits

OK - I have an application that has several models that can relate to several other types of models example Resources(files) can be related to an index, an account, a user etc. anything that is "resourceable" That becomes problematic in the respect that adding all the resource crud methods to every controller for a resourceable model is a lot of problematic duplicati

SeanKimball's avatar
SeanKimball's avatar SeanKimbal...6mos agoDesign
1
2
Last reply by SeanKimball 6mos ago
MossGuy's avatar

include Alpine object in Laravel with @vite()

Hello, I'm a junior developer learning about Laravel and Alpine and I ran into a problem with linking an alpine object to my view. context: I've imported alpine into my project via the terminal with: ./vendor/bin/sail npm install alpinejs Then I included the following code in my app.js: import Alpine from 'alpinejs'; window.Alpine = Alpine; Alpine.start(); In my js folder is a

MossGuy's avatar
MossGuy's avatar MossGuy6mos agoLaravel
7
1
Last reply by MossGuy 6mos ago
Cavalcantefilipe's avatar

laragon week

I'm thinking of buying Laracasts Forever and it's on sale during Laracasts Week, or should I keep waiting for Black Friday?

Cavalcantefilipe's avatar
Cavalcantefilipe's avatar Tray27mos agoTips
1
1
Last reply by Tray2 7mos ago
shaneomac's avatar

Laravel for Ecom

What is out there for building a custom ecom store on Laravel? I am curious if there is anything similar to MedusaJS but on Laravel/PHP. Has anyone built ecom on Laravel/PHP before?

shaneomac's avatar
shaneomac's avatar LaryAI7mos agoLaravel
1
1
Last reply by LaryAI 7mos ago
earmsby's avatar

change title of audits relation manager tab

I'm using owen-it / laravel-auditing along with TappNetwork / filament-auditing to show an audit trail on one or more resources in my Filament app. All is working well with basics of it, but I'd like to simply change the name of the tab from "audits" to "Audit Trail." It seems I should be able to simply add protected function getTableHeading(): ?string {

earmsby's avatar
earmsby's avatar LaryAI7mos agoFilament
1
1
Last reply by LaryAI 7mos ago
earmsby's avatar

Audit trail for attaching relation

I am using owen-it/laravel-auditing package to log audits on my Laravel/Filament app. It's working great for create, update, and delete operations on the Contract model. I'd like to add the ability to log attach and detach events for a relationship (files) on the model I have the audit trail set up for. Searching online I found a suggestion to add a relationship listener event

earmsby's avatar
earmsby's avatar earmsby7mos agoLaravel
3
4
Last reply by earmsby 7mos ago
ainahid's avatar

Filament resource sub folder

How could i make a resource using artisan command as Filament Demo resources goes to Subfolder Resources\ Blog\ Post Authors Comments Blog have three resources in the Blog Folder

ainahid's avatar
ainahid's avatar Eimmaarose7mos agoFilament
2
1
Last reply by Eimmaarose 7mos ago
jhorngacher's avatar

Using Livewire's hooking possibilities properly to cancel an updating Event?

I am pretty new to the Livewire ecosystem and trying to figure out the following thing. So I have a component which uses a Trait to determine if a user can perform the updating method on a specific variable. So far so good, the check is working fine by using the updating{Trait} hook. The method throws an exception as I expect it. So I am going to use another hook exception{Trai

jhorngacher's avatar
jhorngacher's avatar jhorngache...7mos agoLivewire
3
1
Last reply by jhorngacher 7mos ago
baris61's avatar

Structuring Blade resources in a project with public and admin sections

I’m currently organizing the Blade files for my Laravel project, and I’d love to get some input on best practices regarding directory structure. The application has two clear sections: Public — accessible to all visitors (news, vacancies, contact pages, etc.) Admin — private dashboard for managing content (CRUD for news, vacancies, etc.) At the moment, I’m not sure what the mos

baris61's avatar
baris61's avatar LaryAI7mos agoTips
1
53
Last reply by LaryAI 7mos ago
russellxu's avatar

Run command in schedule, command run successfully but echo Failed?

I have a command, I run it directly in command line, it works file and have success info printed out. Then I put this command to schedule running every minute. When I run php artisan schedule:run , it marked this command as 'FAILED' instead of 'DONE'. But the code in this command are successfully runned. So,What might cause this problem?

russellxu's avatar
russellxu's avatar squiaios7mos agoLaravel
2
1
Last reply by squiaios 7mos ago
glaucon's avatar

419 Page Expired error in subdomain

I am encountering a 410 Page Expired issue on my subdomain while working with a project running in production on primarydomain.com. My setup includes a subdomain test.primarydomain.com for testing, and everything works fine on the primary domain and locally (thankfully). However, on the subdomain, I am facing this "Page Expired" issue, especially with forms. On the te

glaucon's avatar
glaucon's avatar olivsinz7mos agoLaravel
6
4
Last reply by olivsinz 7mos ago
Frostist's avatar

Livewire & Flux Routes exposed?

Hi guys. If I run php artisan route:list I see the following in the response: GET|HEAD flux/editor.css generated::2bgScuHRO1iqIrjM › Flux\AssetManager@editorCss › AssetManager@editorCss GET|HEAD flux/editor.js ... generated::E7Gn0gDkt8QICUgE › Flux\AssetManager@editorJs › AssetManager@editorJs GET|HEAD flux/editor.min.js generated::SZnULyhA6rducCgw › Flux\AssetManager

Frostist's avatar
Frostist's avatar Frostist7mos agoLivewire
2
1
Last reply by Frostist 7mos ago
Shivamyadav's avatar

Which broadcast should I use and why?

Pusher (cloud, managed) Redis (self-hosted, needs Echo server) Laravel WebSockets (BeyondCode, self-hosted) Laravel Reverb (official Laravel 11+ solution)

Shivamyadav's avatar
Shivamyadav's avatar martinbean7mos agoLaravel
1
1
Last reply by martinbean 7mos ago
laracoft's avatar

Cron some tasks as `root`

Is there a Laravel way setup cron to run most tasks as www-data and some tasks as root? The docs show only https://laravel.com/docs/12.x/scheduling#running-the-scheduler which implies only 1 user can be specified. It feels dangerous to set it as root.

laracoft's avatar
laracoft's avatar JussiManni...7mos agoLaravel
5
2
Last reply by JussiMannisto 7mos ago
Pixelairport's avatar

vendor:publish vars on workbench:build not working

I use orchestra testbench and in my testbench.yaml I have: ... build: - asset-publish - create-sqlite-db - db-wipe - vendor:publish --provider="Spatie\Permission\PermissionServiceProvider" - migrate-fresh ... But --provider="Spatie\Permission\PermissionServiceProvider" ist not used, when I use workbench:build. When I only use vendor:p

Pixelairport's avatar
Pixelairport's avatar Pixelairpo...7mos agoTesting
4
4
Last reply by Pixelairport 7mos ago
rohitjangir's avatar

SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 1000 bytes (Connection: mysql, SQL: alter table `users` add unique `users_email_unique`(`email`))

Hello friends, when I try to install Laravel 12 project, every time i get this issue. what is the permanent solution for this. rohitjangir@DESKTOP-BP29VVL MINGW64 /c/wamp64/www/test-project $ php artisan migrate:fresh Dropping all tables ................................................................................................................. 75.40ms DONE INFO Preparing

rohitjangir's avatar
rohitjangir's avatar ajinaniyan7mos agoGeneral
9
45
Last reply by ajinaniyan 7mos ago
bvfi-dev's avatar

Collapsing a <div> section is laggy only in the initialization

I have a pretty simple form. Basically I have a status select dropdown and I want an animation when the status is a certain ID: <div class="grid grid-cols-1 gap-6" x-data="{statusId: $wire.entangle('courseForm.status_id'),ztComing: {{ (int) $ztCourseComingSoon }},isComingSoon(){ return Number(this.statusId) === this.ztComing; }}"> <!-- Section 1 =&

bvfi-dev's avatar
bvfi-dev's avatar bvfi-dev7mos agoLivewire
3
1
Last reply by bvfi-dev 7mos ago
laracoft's avatar

Planning work

I have several repos and many issues across all of them Is there any tool that can help me go through them and sort out which one the team should work on first? Update I'm already using Issues in Gitea But seeing 100s of issues is overwhelming and I'm not sure where is the best place to start After some thoughts, I realized a big factor is that some issues are clear, e.g. bu

laracoft's avatar
laracoft's avatar laracoft7mos agoGeneral
6
1
Last reply by laracoft 7mos ago
thesimons's avatar

Sharing private function among different controllers

Hello, what's the best way to share a private function among different controllers? I have an area of my about Working Hours with partners: always, everyday (same hours for every day), custom. I have split the logic in 3 different controllers. However there are 3 private functions to be used in each controller. What's the best approach to share them? Thanks, Simon

thesimons's avatar
thesimons's avatar june237mos agoLaravel
3
1
Last reply by june23 7mos ago
SPresnac's avatar

whereRelation using another connection

I do have a relation in one of my models, that uses a different db-connection. So, some code: Model Employee: class Employee extends Model { protected $connection = 'kpidashboard'; protected $table = 'employees'; protected $fillable = [ 'employee_name', 'kuerzel', 'username', 'active_employee', ]; public function user(): Has

SPresnac's avatar
SPresnac's avatar krisi_gjik...7mos agoEloquent
3
1
Last reply by krisi_gjika 7mos ago
bearbytestudio's avatar

How do I set form data, and then immediately submit? Getting stale data sent to controller.

Hi everyone! Using React / Inertia / Laravel, I'm having a hard time updating form data using setData, then immediately making an AJAX request with the updated data. The data becomes stale. Here is the code, the "due" field being submitted is stale: const {data, setData, put} = useForm({ "due": "", }); const updateDate = (d) => { setDat

bearbytestudio's avatar
bearbytestudio's avatar noxioustoo7mos agoInertia
4
1
Last reply by noxioustoo 7mos ago
rmsc-dev's avatar

Extend ShadcnUI components

Is possible to make an extension of the base components i.e the Button, I want to inherent all variants and properties to like a MyButton with my custom variants and properties?

rmsc-dev's avatar
rmsc-dev's avatar rmsc-dev7mos agoReact
0
1
jekinney's avatar

SEO and structured data

Been a few posts about seo. I thought I'd share this tid bit: Meta tags with site description and keywords is pretty much ignored by search engine spiders along with hidden content because devs abused them and the search results were unpredictable for the user. Now I work a lot in the Google eco system including apps, analytics and search console to ensure and monitor client we

jekinney's avatar
jekinney's avatar Whomesee7mos agoTips
8
2
Last reply by Whomesee 7mos ago
bvfi-dev's avatar

Reply doesn't appear

I replied to my own post about a significant update and I am unable to see what I have written, eventhough its mentioned that I have done it on the "Forums" frontpage. The related post is: Post When I am in the post it says "2 Replies", however on the frontpage it says 3, which is correct if my Reply is included.

bvfi-dev's avatar
bvfi-dev's avatar JussiManni...7mos agoFeedback
1
1
Last reply by JussiMannisto 7mos ago

Want us to email you occasionally with Laracasts news?

Nine out of ten doctors recommend Laracasts over competing brands. Come inside, see for yourself, and massively level up your development skills in the process.

Learn
BrowseSeriesCreatorSeriesLaravel PathLarabitsPlayground
Discuss
ForumPodcastSupport
Extras
Gift CertificatesApparelFAQiOS AppTerms
Social
X(Twitter)TikTokYoutube

© Laracasts 2026. All rights reserved. Yes, all of them. That means you, Todd.

Proudly hosted with Laravel Forge and DigitalOcean.

Want us to email you occasionally with Laracasts news?

Nine out of ten doctors recommend Laracasts over competing brands. Come inside, see for yourself, and massively level up your development skills in the process.

Learn
BrowseSeriesCreatorSeriesLaravel PathLarabitsPlayground
Discuss
ForumPodcastSupport
Extras
Gift CertificatesApparelFAQiOS AppTerms
Social
X(Twitter)TikTokYoutube

© Laracasts 2026. All rights reserved. Yes, all of them. That means you, Todd.

Proudly hosted with Laravel Forge and DigitalOcean.