Create feeds | Laravel Feeds

Laravel Feeds Help

Create feeds

To create a feed class, use the make:feed console command:

php artisan make:feed <name>

This will create a feed file. For example, app/Feeds/UserFeed.php.

Also, this console command can create classes of the element and information along with the feed class. To do this, use --item and --info parameters.

# Create a feed class and information class php artisan make:feed <name> --info # Create a feed class and item class php artisan make:feed <name> --item # Create a feed class, item class and information class php artisan make:feed <name> --item --info

Shortcuts are also available:

# Create a feed class and item class php artisan make:feed <name> -t # Create a feed class and info class php artisan make:feed <name> -i # Create a feed class, item class and information class php artisan make:feed <name> -it

Filling feeds

Feed

Fill in the main feed class. For example:

namespace App\Feeds; use App\Feeds\Items\UserFeedItem; use App\Models\User; use DragonCode\LaravelFeed\Feeds\Feed; use DragonCode\LaravelFeed\Feeds\Items\FeedItem; use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Model; class UserFeed extends Feed { public function builder(): Builder { return User::query() ->whereNotNull('email_verified_at') ->where('created_at', '>', now()->subYear()); } public function item(Model $model): FeedItem { return new UserFeedItem($model); } }

Feed Item

Fill in the feed item class. For example:

namespace App\Feeds\Items; use DragonCode\LaravelFeed\Feeds\Items\FeedItem; /** @property-read \App\Models\User $model */ class UserFeedItem extends FeedItem { public function toArray(): array { return [ 'name' => $this->model->class, 'email' => $this->model->email, ]; } }
03 September 2025