I want to get the ID of a user in a middleware by searching with his email. I thought about doing it like this in one of two ways. First, creating a function in the model User: public function …
Tag: laravel
Laravel – Maintenance mode just for some urls
I need to use the Maintenance mode using the artisan command “down”, but just for some urls… In my case, i want that all urls that starts with “/admin/*” continue working. Is there a solution?
retrieving multiple records associated to multiple records laravel 4.2
recently i asked this question which got one answer but unfortunately didn’t solve the problem, after that i got no more answers and i really need to fix this problem i have. Alright so i have to make a quiz website for my school in which a user should be able to play the quiz, this page need to show
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
How to make artisan serve work in virtual host?
I’m on Windows 8 and I’m using WAMP to run my laravel project. I have configured apache and I created a virtual host, to access my app through http://myapp.dev. I would like to know if it’s possible …
How to use groupBy() to group a Collection object
My goal is to retrieve all of a user’s ‘items’ and display then in my view grouped by their ‘status’. There are 4 possible statuses, each with their own <div> on the page containing the items’ info. After some poking around I believe I need to use the groupBy() method like so: This does seem to do some sort of
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