Esempio n. 1
0
 /**
  * Display a listing of the resource.
  *	GET /rental
  * @return Response
  */
 public function index()
 {
     $equipment = Equipment::with('categories')->get();
     $categories = array();
     foreach (Category::all() as $category) {
         $categories[$category->id] = $category->name;
     }
     //var_dump($equipment);
     return View('/rental.index')->with('equipment', $equipment)->with('categories', $categories);
 }
Esempio n. 2
0
 /**
  * @return View
  */
 public function index()
 {
     $equipment = Equipment::with('transactions')->get();
     $overdue = $equipment->filter(function ($item) {
         $lastTransaction = $item->transactions->last();
         if (!is_null($lastTransaction) && !is_null($lastTransaction->due_date) && $lastTransaction->due_date->lt(Carbon::today())) {
             return true;
         }
     });
     return view('inventory.index', compact('equipment', 'overdue'));
 }
Esempio n. 3
0
 public static function search($query)
 {
     # If there is a query, search the library with that query
     if ($query) {
         # Eager load categories
         $quipment = App\Equipment::with('categories')->whereHas(function ($q) use($query) {
             $q->where('name', 'LIKE', "%{$query}%");
         })->orWhereHas('categories', function ($q) use($query) {
             $q->where('name', 'LIKE', "%{$query}%");
         })->orWhere('brand', 'LIKE', "%{$query}%")->orWhere('LIKE', "%{$query}%")->get();
         # Note on what `use` means above:
         # Closures may inherit variables from the parent scope.
         # Any such variables must be passed to the `use` language construct.
     } else {
         # Eager load categories
         $equipment = App\Equipment::with('categories')->get();
     }
     return $equipment;
 }
 public function overdue()
 {
     $equipment = Equipment::with('transactions')->get();
     $overdue = $equipment->filter(function ($item) {
         $lastTransaction = $item->transactions->last();
         if (!is_null($lastTransaction) && !is_null($lastTransaction->due_date) && $lastTransaction->due_date->lt(Carbon::today())) {
             return true;
         }
     });
     if (!$overdue->isEmpty()) {
         foreach ($overdue as $item) {
             $this->generateOverdueEmail($item->transactions->last());
         }
     }
     return;
 }