Skip to content

Tag: laravel

Get primary key of Eloquent model instance

I’m happy enough to work on a project with (not) very consistent column names in our MySQL database. We have camelCase, PascalCase, ‘Id’, ID and it’s driving me nuts. I’ve decided to start using Eloquent in our application (which is NOT Laravel). I would love to have a method of …

Default value for username in SQL database

I’m writing a Laravel application, and for testing in sqlite you need to specify ->nullable() or ->default(“123”) for all fields in your migration. This confuses me as my User-migration currently looks like this: Many of these make no sense to add neither ->default(“123”…

Laravel Eloquent hasMany relationship

Hi I am new to Laravel and currently in am using Laravel 4.2. I am trying to create an application where I have users, posts and comments table and have the following model User Model Post Model Comment Model What I want to achieve : user’s Post and comment for Post What I have done So far::: I am able

Redirect 302 on Laravel POST request

I’m developing a Laravel Web Service. When I try my POST routes with web forms, everything works fine, but when I try the same with a REST Client like Postman it doesn’t get me the response that should. It gives me status code 302, and redirects to “/”. What’s the problem? Answer…