If you have specified a different connection that should be used when interacting with a particular model.
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
Soketi defaults to app-id, app-key, and app-secret after configuring broadcasting environment variables in the.env file. To use our own values, we should define them in docker-compose.yml
as follows:
soketi:
image: "quay.io/soketi/soketi:latest-16-alpine"
environment:
SOKETI_DEBUG: "1"
Laravel provides excellent support for email sending. Sometimes you need to record the status of outgoing emails in the system. You must construct two tables: email_logs
and email_log_statuses
. The 'email_logs' table contains all outgoing emails, while the email_log_statuses
table contains all email statuses such as sent, failed, queued, scheduled to send, and so on.
Now, create Event Listeners During the email-sending process, Laravel triggers multiple events. You can set up event listeners to record these events and update the email log accordingly.
php artisan make:listener SendEmailListener --event='Illuminate\Mail\Events\MessageSending'
php artisan make:listener SentEmailListener --event='Illuminate\Mail\Events\MessageSent'
php artisan make:listener FailedEmailListener --event='Illuminate\Mail\Events\MessageFailed'
Ensuring the security of user sessions is critical in web applications, and Laravel Sanctum offers a strong solution for API authentication in Laravel projects. Implementing an automatic logout function when users are idle for an extended length of time is critical for improving security and user privacy. In this post, we'll look at how to integrate idle timeout capabilities with the Laravel API using Sanctum. Let's look at how to set up automated user logout for inactive sessions in a Laravel Sanctum-powered API.
Open AuthServiceProvider.php
and add this code accordingly to this file:
use Carbon\Carbon;
Artisan make commands build stuff (models, jobs, etc.) from templates. Want to edit those templates? Use php artisan stub:publish
to copy them to your app for easy tweaks! This command will publish all the variety of classes available in Laravel inside stubs
directory.
Using custom stubs, create your own starter template file in Laravel from scratch.
While I was working on one of my projects using Laravel Sanctum using SPA Authentication. This project has multiple sub-domains for different environments, like DEV
, STG
, UAT
and is hosted in the same domain, like dev.domain.tld
, stg.domain.tld
. In the .env
file, the SESSION_DOMAIN
variable should include a leading dot (.) before the subdomain. This ensures that the session cookie is available to all subdomains. For example:
SESSION_DOMAIN=.domain.tld
sanctum/csrf-cookie
to initialize CSRF protection; it will set the session for the request and XSRF-TOKEN as a cookie in the browser. With this session, it will persist.By default, the Laravel application skeleton does not include the lang
directory. If you would like to customize Laravel's language files or create your own, you should scaffold the lang
directory via the lang:publish
Artisan command. The lang:publish
command will create the lang
directory in your application and publish the default set of language files used by Laravel:
php artisan lang:publish
Create ja
directory inside lang
with en
directory. Copy the following files inside it.
Both TIMESTAMP and DATETIME store date and time information, but they have some differences in terms of the range they support and the way they handle time zones.
Here are a few things to consider: