UserManageActivityFilter.php 2.24 KB
<?php

namespace App\ModelFilters;

use App\Support\ModelFilter;
use Arr;

class UserManageActivityFilter extends ModelFilter
{
    /**
     * @param string $name
     * @return void
     */
    public function nickName(string $name): void
    {
        $this->whereRelation('user', 'nick_name', 'like', '%' . $name . '%');
    }

    /**
     * @param string $name
     * @return void
     */
    public function realName(string $name): void
    {
        $this->whereRelation('user', 'real_name', 'like', '%' . $name . '%');
    }

    /**
     * @param string $name
     * @return void
     */
    public function songName(string $name): void
    {
        $this->whereRelation('activity', 'song_name', 'like', '%' . $name . '%');
    }

    /**
     * @param string $name
     * @return void
     */
    public function projectName(string $name): void
    {
        $this->whereRelation('project', 'name', 'like', '%' . $name . '%');
    }

    /**
     * @param string $email
     * @return void
     */
    public function email(string $email): void
    {
        $this->whereRelation('user', 'email', 'like', '%' . $email . '%');
    }

    /**
     * @param string $phone
     * @return void
     */
    public function phone(string $phone): void
    {
        $this->whereRelation('user', 'phone', 'like', '%' . $phone . '%');
    }

    /**
     * @param int $status
     * @return void
     */
    public function status(int $status): void
    {
        $this->whereRelation('user', 'status', $status);
    }

    /**
     * @param array|int $key
     * @return void
     */
    public function activityKey(array|int $key): void
    {
        $this->whereIn('activity_id', Arr::wrap($key));
    }

    /**
     * @param array|int $key
     * @return void
     */
    public function project(array|int $key): void
    {
        $this->whereIn('project_id', Arr::wrap($key));
    }

    /**
     * @param array|int $status
     * @return void
     */
    public function activityStatus(array|int $status): void
    {
        $this->whereIn('activity_status', Arr::wrap($status));
    }

    /**
     * @param string $permission
     * @return void
     */
    public function permission(string $permission): void
    {
        $this->whereJsonContains('permission', $permission);
    }
}