SystemMaterialsController.php 664 Bytes
<?php


namespace App\Http\Container\AppSection\Controllers;


use App\Helpers\JsonResource;
use Hikoon\LaravelApi\Support\ApiController;
use Illuminate\Http\Request;
use App\Models\SystemMaterial;


class SystemMaterialsController extends ApiController
{
    public function index(Request $request){
        $type = $request->get('type',1);
        $size = $request->get('size',2);
        $data= SystemMaterial::query()
            ->where('type','=',$type)
            ->select(['id','type','url','expand'])
            ->inRandomOrder()
            ->take($size)
            ->get();
        return JsonResource::success(JsonResource::SUCCESS, $data);
    }
}