@php /* To Add new notice go to /public_html/public/uploads/placement/Placement Notice/#Read me! .txt And read the Read me! Everything is going to update automatically. */ @endphp @php // Create an empty array to store the notices $notices = []; // Set the folder path where the placement notices are stored $folderPath = public_path('uploads/placement/Placement Notice/'); try { // Get all the files in the folder $files = \File::files($folderPath); // Loop through each file foreach ($files as $file) { // Get the filename and extension of the file $filename = pathinfo($file, PATHINFO_FILENAME); $extension = pathinfo($file, PATHINFO_EXTENSION); // Check if the file has a pdf extension and matches the specified pattern if (strtolower($extension) === 'pdf' && preg_match('/^(\d{4}-\d{2}-\d{2})--(.*?)--(\d{4}-\d{2}-\d{2})--(.*?)--(.*?)$/', $filename, $matches)) { // Extract the date, post by, drive date, company, and post for from the filename [$date, $postby, $drivedate, $company, $postfor] = [$matches[1], str_replace(['_', '-'], ' ', $matches[2]), $matches[3], str_replace(['_', '-'], ' ', $matches[4]), str_replace(['_', '-'], ' ', $matches[5])]; // Create a notice array with the extracted information $notices[] = [ 'date' => date('M d, Y', strtotime($date)), 'drivedateraw' => $drivedate, 'drivedate' => date('M d, Y', strtotime($drivedate)), 'postfor' => $postfor, 'postby' => $postby, 'company' => $company, 'description' => 'Description goes here', 'pdfLink' => "/uploads/placement/Placement Notice/{$filename}.{$extension}", 'status' => getStatus($drivedate), ]; } } // Reverse the order of notices to show the latest first $notices = array_reverse($notices); } catch (\Exception $e) { // Handle exceptions here, for example, log or display an error message dd('An error occurred: ' . $e->getMessage()); } function getStatus($driveDate) { $currentDate = strtotime(date('Y-m-d')); $driveDateTimestamp = strtotime($driveDate); if ($driveDateTimestamp < strtotime('2001-01-01')) { return 'Active'; } elseif ($driveDateTimestamp < $currentDate) { return 'Expired'; } else { return 'Active'; } } @endphp @php $currentPage = \Illuminate\Pagination\Paginator::resolveCurrentPage(); $perPage = 10; $noticesCollection = collect($notices); // Convert the array to a collection $items = new \Illuminate\Pagination\LengthAwarePaginator( $noticesCollection->all(), // Use the 'all()' method to get the underlying array $noticesCollection->count(), $perPage, $currentPage, ['path' => \Illuminate\Pagination\Paginator::resolveCurrentPath()], ); $chunkedItems = $items->forPage($currentPage, $perPage); @endphp @extends('frontend.mainlayout') @section('title', 'Placement Notice') @section('banner')

Placement Notice

{{--

All notices from RERF Group of Institutions, RIST & SVIMS.

--}}
@endsection @section('main')
@foreach ($chunkedItems as $notice)
{{ $notice['company'] }} {!! $notice['status'] === 'Expired' ? 'Expired' : '' !!}
  • Hiring for: {{ $notice['postfor'] }}
  • Notice by: {{ $notice['postby'] }}
  • Last Date for Apply/Drive Date: {{ $notice['status'] === 'Active' && strtotime($notice['drivedateraw']) > strtotime('2010-01-01') ? $notice['drivedate'] : ($notice['status'] === 'Expired' ? $notice['drivedate'] : 'Will be declared soon') }}
  • Posted on: {{ $notice['date'] }}
{!! !$loop->last ? '
' : '' !!} @endforeach
{{ $items->links() }}
@endsection