ispt4.0_laravel/app/Http/Controllers/ClientController.php

34 lines
834 B
PHP

<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use App\Models\Plant;
use App\Models\CompanyProject;
class ClientController extends Controller
{
public function receiveProjectsClient()
{
$client = Auth::user()->user_id;
$recevePlantClient = Plant::where('user_id', $client)->get();
// Extrai os plant_id da coleção $recevePlantClient
$plantIds = $recevePlantClient->pluck('plant_id');
// Busca todos os CompanyProject que têm um plant_id dentro da lista $plantIds
$allProjectsClient = CompanyProject::whereIn('plant_id', $plantIds)->get();
return view('userClient.dashboardClient',compact('allProjectsClient'));
}
public function receiveManageAssetsClient(){
// return view()
}
}