php - How to set a boolean to true if the button is clicked?


I'm trying to set myisApprove boolean to true if the button is clicked for the currentid.


 public function up()
    Schema::create('approve_document', function (Blueprint $table)



        $table->timestamp('dateModified')->default(DB::raw('CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP'));


public function documentsSentForApproval()

    $pendingDocumentLists = DB::table('approve_document')
    ->select('documents.title', 'documents.content', 'categories.category_type', 'users.username', 'approve_document.dateReceived', '', 'approves.approver_id', 'approve_document.document_id', 'approve_document.isApprove')
    ->join('documents', '', '=', 'approve_document.document_id')
    ->join('categories', '', '=', 'documents.category_id')
    ->join('approves', '', '=', 'approve_document.approve_id')
    ->join('users', '', '=', 'approves.approver_id')
    ->where('approver_id', '=', Auth::id())
    ->orWhere('requestedBy', '=', Auth::id())

    return view ('document.pending')
    ->with('pendingDocumentLists', $pendingDocumentLists);


@foreach ($pendingDocumentLists as $list)
        <tr class = "info">

            <td>{{ $list->title }}</td>
            <td>{{ strip_tags(substr($list->content, 0, 50)) }} {{ strlen($list->content) > 50 ? "..." : '' }}</td>
            <td>{{ $list->category_type }}</td>
            <td>{{ $list->username }}</td>
            <td>{{ date('M, j, Y', strtotime($list->dateReceived)) }}</td>

                <a href = "{{ route ('document.viewPending', $list->id) }}"><button type = "submit" class = "btn btn-primary glyphicon glyphicon-open"> Read</button></a>

                <a href = ""><button type = "submit" class = "btn btn-info glyphicon glyphicon-edit"> Edit</button></a>

                <button type = "submit" class = "btn btn-danger glyphicon glyphicon-trash"> Delete</button>

                @if (Auth::id() == $list->approver_id)

                    <a href = "{{ route ('document.pending', $list->document_id) }}">
                        <button type = "submit" onclick = "approveFunction()" class = "btn btn-success glyphicon glyphicon-thumbs-up"> Approve</button>

                    <button type = "submit" class = "btn btn-warning glyphicon glyphicon-thumbs-down"> Reject</button>




I'm little bit stuck here in my if condition. Where if I hit the Approve button I'm getting the current id of thedocument but I need to set a condition here to set itisApprove to true. Any help how can I achieve this?


If($list->document_id) is approve. SetisApprove column to true for the currentdocument_id




Mayb you looking this:

add new

<input type="hidden" name="approved" value="0">

when click button with javascript change value to 1;

Or you can send via ajax, but don't forget add token.

P.s true and false can be replaced with 1 ad 0

People are also looking for solutions to the problem: http - How to preserve Integer in PHP CURL request


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.