Skip to content
Advertisement

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 receiving the value of the primary key easily without knowing

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”) nor ->nullable() to. Username is a good example, I can’t have null as a username in the

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 it looks like in postman you should point

Laravel where on relationship object

I’m developing a web API with Laravel 5.0 but I’m not sure about a specific query I’m trying to build. My classes are as follows: and Now, I want to get all the events with a specific participant. I tried with: but the where condition is applied on the Event and not on its Participants. The following gives me an

Advertisement