Skip to content

Tag: laravel

Laravel Broadcast authentication

How do I authenticate an user to a channel with a custom auth method? For example, in my app I use a token auth (stored in the db for each user) for my API, passed via header and read by a custom middleware. How do I control the access with these custom auth methods for channels? How would be the

Laravel 5.5 autodiscovery not registering

I’m installing the spatielaravel-backup package. According to the instructions, I just need to composer require spatielaravel-backup and the package should be recognized and auto-installed. It looks like this is happening: But looking in /config/app.php there’s no mention of backup anywhere in the…

Upload image in Laravel

I try these code in controller: My Html input file: but i can’t upload. Any idea? Answer you can use storage::putFile(‘folder_name’, $request->image) this will return automatic generated filename and you can store that in your database. And make sure your have your default file system set…

Laravel: Count number of rows in a relationship

I have the following relationship: A venue has many offers A offer has many orders I have the following Eloquent model to represent this: I want to determine the total number of orders for venues with location_id = 5 using Laravel’s Eloquent model. The only way I managed to do this is as follows: Howeve…

Laravel : How to add days to datetime field?

How to add days to datetime field in Laravel? For example, there is a updated_at field in articles table: I want to add 30 days to updated_at field. In Carbon, it could be done like this: But how to do it in above example? Answer Since updated_at and created_at fields are automatically cast to an instance of …