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

30 lines
749 B
PHP

<?php
namespace App\Http\Controllers;
use App\Models\Plant;
use Illuminate\Http\Request;
use App\Models\CompanyProject;
use Illuminate\Support\Facades\Auth;
class ClienteController 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('dashboardClient',compact('allProjectsClient'));
}
}