有个小需求,需要使用php代码对图片进行颜色调整,比如变成灰色,改变图片的亮度,对比度等等。而php中就内置了一个图片的滤镜函数 imagefilter() ,下面就来具体说说这个函数的用法。php
2021-10-23 14:36:59
35
<?php
namespace App\Console;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
use Illuminate\Support\Facades\Log;
class Kernel extends ConsoleKernel
{
    /**
     * The Artisan commands provided by your application.
     *
     * @var array
     */
    protected $commands = [
        \App\Console\Commands\EsInit::class,
        \App\Console\Commands\EnterpriseStatus::class,
        \App\Console\Commands\ExportExcel::class,
        \App\Console\Commands\OldData::class,
        \App\Console\Commands\DeleteRemoved::class,//将自定义注入到console中
    ];
    /**
     * Define the application's command schedule.
     *
     * @param \Illuminate\Console\Scheduling\Schedule $schedule
     * @return void
     */
    protected function schedule(Schedule $schedule)
    {
        $schedule->command('es:init')->dailyAt('1:00');
        $schedule->command('enterprise:status')->dailyAt('2:00');
        $schedule->command('delete:removed')->sundays();//每周日执行一次
    }
    /**
     * Register the commands for the application.
     *
     * @return void
     */
    protected function commands()
    {
        $this->load(__DIR__ . '/Commands');
        require base_path('routes/console.php');
    }
}<?php
namespace App\Console\Commands;
use App\Models\Product\KnowledgeDict;
use App\Models\Product\LibraryCheckList;
use App\Models\Product\LibraryCheckSystem;
use App\Models\Product\LibraryQuestionList;
use App\Models\Product\LibraryQuestionSystem;
use App\Models\Product\LibrarySection;
use App\Models\Product\Notice;
use Illuminate\Console\Command;
class DeleteRemoved extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'delete:removed';
    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'remove field data';
    protected $removeClass = [
        KnowledgeDict::class,
        LibraryQuestionList::class,
        LibraryQuestionSystem::class,
        LibraryCheckList::class,
        LibraryCheckSystem::class,
        LibrarySection::class,
        Notice::class,
    ];
    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }
    /**
     * Execute the console command.
     *
     * @return int
     */
    public function deleteRemoved()
    {
        if ($this->removeClass) {
            foreach ($this->removeClass as $value) {
                $model = new $value;
                $model::where('isRemoved', 1)->delete();
            }
        }
        return true;
    }
    public function handle()
    {
        $this->deleteRemoved();
    }
}15
2022-09
23
2021-10
28
2021-06