myke2424
1 week ago

Need assistance with DB Table design / passing data to view.

Posted 1 week ago by myke2424

I need some assistance with the format of my DB times_table and advice on how I could pass the data to show method to fill out the following table. I'm not really sure how to structure this.

Table: https://i.imgur.com/HuFBhlL.png

Here's my form: https://i.imgur.com/HR0Jsvy.png

Here's my table for the form: times_db_table: https://i.imgur.com/uUEVR6S.png

I made the table using CSS grid - here's the code for the table (show.blade.php)

<div class="container">
    <div class="wrapper">
                <div>Month</div>
                <div>Overtime Hours</div>
                <div>Compensation Hours</div>
                <div>Vacation</div>
                <div>Personal Hours</div>
                <div>Sick Hours</div>

                <div>Carry Over</div>
                <div></div>
                <div></div>
                <div></div>
                <div></div>
                <div></div>


                <div>Allotted</div>
                <div></div>
                <div></div>
                <div></div>
                <div></div>
                <div></div>

                <div>Starting Total</div>
                <div></div>
                <div></div>
                <div></div>
                <div></div>
                <div></div>

                <div>Jan</div>
                <div></div>
                <div></div>
                <div></div>
                <div></div>
                <div></div>


                <div>Feb</div>
                <div></div>
                <div></div>
                <div></div>
                <div></div>
                <div></div>

                <div>March</div>
                <div></div>
                <div></div>
                <div></div>
                <div></div>
                <div></div>

                <div>April</div>
                <div></div>
                <div></div>
                <div></div>
                <div></div>
                <div></div>

                <div>May</div>
                <div></div>
                <div></div>
                <div></div>
                <div></div>
                <div></div>

                <div>Jun</div>
                <div></div>
                <div></div>
                <div></div>
                <div></div>
                <div></div>

                <div>Jul</div>
                <div></div>
                <div></div>
                <div></div>
                <div></div>
                <div></div>

                <div>Aug</div>
                <div></div>
                <div></div>
                <div></div>
                <div></div>
                <div></div>

                <div>Sep</div>
                <div></div>
                <div></div>
                <div></div>
                <div></div>
                <div></div>

                <div>Oct</div>
                <div></div>
                <div></div>
                <div></div>
                <div></div>
                <div></div>

                <div>Nov</div>
                <div></div>
                <div></div>
                <div></div>
                <div></div>
                <div></div>

                <div>Dec</div>
                <div></div>
                <div></div>
                <div></div>
                <div></div>
                <div></div>

                <div>Yearly Total</div>
                <div></div>
                <div></div>
                <div></div>
                <div></div>
                <div></div>

                <div>Balance in Hours</div>
                <div></div>
                <div></div>
                <div></div>
                <div></div>
                <div></div>

                <div>Balance in Days</div>
                <div></div>
                <div></div>
                <div></div>
                <div></div>
                <div></div>

    </div>
</div>

Here's my controller for Time

  public function create()
    {
        $user = auth()->user();

        return view('timetracker.create', compact('user'));
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function store(Request $request)
    {

        $attributes = request()->validate([
            'start_day'=> 'required',
            'category' => 'required',
            'start_time'=> 'required',
            'finish_time'=> 'required',
            'duration' => 'required',
            'notes'=> 'required'
        ]);

        $attributes['user_id']= auth()->id();

        // dd(request($attributes));

        Time::create($attributes);

       

        return redirect('/timetracker');
    }

    /**
     * Display the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function show(Time $time)
    {
        return view('timetracker.show', compact('time'));
    }

Please sign in or create an account to participate in this conversation.