Articles with tag - laravel

Validate slack slash commands via signing secret

Posted on 2 years ago by Ping Cheng

Here is a gist for validating the slack slash command via the slack signing secret.

The sample is for Laravel middleware. Since the validation process is written below, you can modify to suit your project.

GitHub gist: https://gist.github.com/pingcheng/f7500adf1b1009df3ed341f511305b0d


<?php

namespace App\Http\Middleware;
use Exception;
use Carbon\Carbon;
use Closure;
use Illuminate\Support\Facades\Log;

class SlackRequest
{
    /**
     * Validate a slack request
     * by the slack signing secret (not the token)
     *
     * @param  \Illuminate\Http\Request $request
     * @param  \Closure $next
     *
     * @return mixed
     * @throws Exception
     */
    public function handle($request, Closure $next)
    {
        // define the version number
        $version = 'v0';

        // load the secret, you also can load it from env(YOUR_OWN_SLACK_SECRET)
        $secret = config('services.slack.signing_secret');

        //

...

[ Read More ]


Use Tailwind in Laravel

Posted on 1 year ago by Ping Cheng

Tailwind a very low-level CSS framework that only includes classes but does not contain any pre-defined components. This means you can define your own component styles without override the styles come with the CSS framework.

To have a better understanding of Tailwind, please read the official website: https://tailwindcss.com

Here are the steps that integrates the tailwind into your Laravel project:

Install

First, let's install the tailwind itself

# Using npm
npm install tailwindcss

# Using Yarn
yarn add tailwindcss

Then, let's install the PurgeCSS to cut off classes that we did not use to save our final css file size

# Using npm
npm install laravel-mix-purgecss --save-dev

# Using Yarn
yarn add laravel-mix-purgecss --dev

Create a configuration file

npx tailwind init

After ran the above command, you will find tailwind.config.js was generated on your project root directory.

Import Tailwind

Afte

...

[ Read More ]

Search
Hand crafted with by Ping Cheng