Пример #1
0
 public function getNextCode()
 {
     $latest = Parcels::max('code');
     $latestfromBatch = Batch::max('code');
     $thisDay = Carbon::now()->format('ymd');
     if (!$latest || $thisDay != substr($latest, 0, 6)) {
         return Carbon::now()->format('ymdH') . '001';
     }
     if ($latestfromBatch && $latestfromBatch > $latest) {
         return ++$latestfromBatch;
     }
     return ++$latest;
 }
Пример #2
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy(Parcels $parcel)
 {
     if ($parcel->hasAlreadyBeenTracked()) {
         alert()->info('Parcel could not be deleted because it has been processed', 'Oops');
         return redirect('parcel');
     }
     // Limit authorization
     $parcel->track()->delete();
     event(new ActivityLog(auth()->user()->username . ' deleted the parcel ' . $parcel->description . ' with the code ' . $parcel->code . ' successfully.'));
     $parcel->delete();
     alert()->success('Parcel deleted successfully', 'Success');
     return redirect('parcel');
 }
Пример #3
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function edit(Batch $batch)
 {
     $parcels = Parcels::whereStatusId(1)->lists('description', 'id')->all();
     //dd($batch->parcel->lists('parcel_id'));
     return view('batch.edit', compact('batch', 'parcels'));
 }
Пример #4
0
 /**
  * Bootstrap any application services.
  *
  * @return void
  */
 public function boot()
 {
     view()->composer('layouts.dashboard', function ($view) {
         $view->with('parcels', Parcels::all())->with('deliveredparcels', Parcels::take(5)->latest()->where('status_id', '=', 4)->get())->with('undeliveredparcels', Parcels::take(5)->latest()->where('status_id', '!=', 4)->get())->with('users', User::all()->count())->with('towns', Towns::all()->count())->with('shipments', ParcelsTowns::all()->count());
     });
 }