Aron-Spiess

Experience

1,540

0 Best Reply Awards

  • Member Since 3 Months Ago
  • 9 Lessons Completed
  • 2 Favorites

12th July, 2018

Aron-Spiess started a new conversation Working With Datatables And Other Collections • 1 week ago

I need some help with returning more than just the datatables data, I'd like to return results from two other sql queries.

// normal way to call back the datatable
        return DataTables::of($comments_list)
            ->rawColumns(['title'] ,['comment'] ,['created_by'] ,['comment_date'])
            ->make(true);
// normal way to call back sql query collections
return view('dashboard.commentslist', compact('owners','admins'));

I assume I can add the compact('owners','admins')); but when I try to reference these in my blade I get an undefined variable

4th July, 2018

Aron-Spiess left a reply on Ajax Request Not Showing On Return View • 2 weeks ago

// metrics.blade.php view

   <script type="text/javascript">
        $(function(){
            // Enables popover
            $("[data-toggle=popover]").popover();
        });

        var viz;
        var workbook;
        var activeSheet;

        function tabSwitch() {

            //alert(activeSheet);
            $.ajaxSetup({
                headers: {
                    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                }
            });

            $.ajax({
                type: "GET",
                url: "{{route('comment.return_comment')}}",
                data: {activeSheet:activeSheet},
                dataType : "json",
                success: function(response) {
                    console.log(response);
                }
            });
        };

        window.onload = function () {
            var vizDiv = document.getElementById('container-metric');
            var visURL = "{{$metrics->tile_url}}";
            var options = {
                width: '{{$metrics->tile_width}}px',
                height: '{{$metrics->tile_height}}px',
                background: 'white',
                hideTabs: {{$tabs}},
                hideToolbar: {{$toolbar}},
                onFirstInteractive: function () {

                    workbook = viz.getWorkbook();

                    activeSheet = workbook.getActiveSheet().getName();

                    tabSwitch();

                }

            };
            viz = new tableau.Viz(vizDiv, visURL, options);

            //add Event Listener

            viz.addEventListener('tabswitch', function (event) {

                activeSheet = workbook.getActiveSheet().getName();

                tabSwitch();

                //alert("TAB CHANGE");

                //console.log(event);

            });

        };
        var tableau;
    </script>


// body with sidebar overlay, this include works as expected

           <div class="overlay"></div>

            @include('dashboard.comment_create')    <!--- this comment does not display 
                                                here even though chrome shows it 
                                                --->

            <button type="button" id="sidebarCollapse" class="btn btn-info navbar-btn">
                <i class="glyphicon glyphicon-comment"></i>
                <span>Comments</span>
            </button>

            <script type="text/javascript">

                //https://bootstrapious.com/p/bootstrap-sidebar

                $(document).ready(function () {
                    $("#sidebar").mCustomScrollbar({
                        theme: "minimal"
                    });

                    $('#dismiss, .overlay').on('click', function () {
                        $('#sidebar').removeClass('active');
                        $('.overlay').fadeOut();
                    });

                    $('#sidebarCollapse').on('click', function () {
                        $('#sidebar').addClass('active');
                        $('.overlay').fadeIn();
                        $('.collapse.in').toggleClass('in');
                        $('a[aria-expanded=true]').attr('aria-expanded', 'false');
                    });
                });
            </script>

// comment_create.blade.php

<!-- Sidebar Holder -->
    <nav id="sidebar">
        <div id="dismiss">
            <i class="glyphicon glyphicon glyphicon-remove"></i>
        </div>

        <div class="sidebar-header">
            <h3>Comments</h3>
        </div>


        <form action="../comments" method="post" class="pure-form pure-form-aligned">
            <fieldset>

                {{csrf_field()}}

                @if(!empty($comment))
                    <?php $commentseqno = $comment->seq_no; ?>
                    <?php $title= $comment->title; ?>
                    <?php $comments = $comment->comment; ?>
                    <?php $createdBy = $comment->created_by; ?>
                    <?php $metaData = $comment->meta_data; ?>
                    <?php $metricKey = $comment->metric_key; ?>
                @else
                    <?php $title = ''; ?>
                    <?php $comments = ''; ?>
                    <?php $createdBy = ''; ?>
                    <?php $metaData = ''; ?>
                    <?php $metricKey = ''; ?>
                @endif

                <!-- hidden fields -->
                    @if(!empty($comment))
                        <input type="hidden" name="comment_seqno" id="comment_seqno" value="{{$commentseqno}}">
                        <input type="hidden" name="created_by" id="created_by" value="{{$createdBy}}">
                        <input type="hidden" name="meta_data" id="meta_data" value="{{$metaData}}">
                        <input type="hidden" name="metric_key" id="metric_key" value="{{$metricKey}}">
                    @endif

                @include('sections.commentform')

                <hr>

                {{$comments}}    <!--- this is where I expect the comment to show 
                            only appears when I run comment_create.blade.php by             
                            itself rather than an include  --->

            </fieldset>
        </form>

    </nav>
// controller
    // show max seq_no and comment from ajax post using unique metric key
    public function return_comment(Request $request)
    {
        $inputs = \Request::all();

        $metric_key = reset($inputs);

        // get comment related to metric_key.
        $comment = \DB::table('metrics_comments')
            ->where('seq_no', \DB::raw("(select max(seq_no) from metrics_comments
                                    where metric_key = '$metric_key')"))
            ->get()
            ->first();

        return view('dashboard.comment_create', compact('comment'));
    }

3rd July, 2018

Aron-Spiess started a new conversation Ajax Request Not Showing On Return View • 2 weeks ago

I can't seem to get my ajax request to return its success back to my view. I suspect it's probably because my view is an include rather than part of the actual page. And my ajax does not do anything with the success. I expected the controller would return the data to the include, but it seems not to. It's probably a matter of timing.

Everything posts correctly with no errors and if I display only the include page then it displays what I expect.

My return view with include still thinks my return from the controller is empty.

Aron-Spiess left a reply on Trying To Send Js Variable After Load To Controller • 2 weeks ago

Got it working. Ended up changing my "post" route to "get".

// getting all the request parameters and then returning just the first parameter
$inputs = \Request::all();

$input = reset($inputs);

Aron-Spiess left a reply on Trying To Send Js Variable After Load To Controller • 2 weeks ago

I did that so I could see the data, when I do just this

$identifier =  $request->activeSheet;

I get my past error: "Object of class stdClass could not be converted to string"

Aron-Spiess left a reply on Trying To Send Js Variable After Load To Controller • 2 weeks ago

I did a dd($request) and I see the value I need, just need a way to decode the request and get the only string I need

  "<span class=sf-dump-key>**activeSheet**</span>" => "<span class=sf-dump-str title="25 characters">**Monthly Features Accepted**</span>"

Aron-Spiess left a reply on Trying To Send Js Variable After Load To Controller • 2 weeks ago

the response tab says: Object of class stdClass could not be converted to string in file /app/laravel-simple-ldap-auth/vendor/laravel/framework/src/Illuminate/Support/Str.php on line 338

Aron-Spiess left a reply on Trying To Send Js Variable After Load To Controller • 2 weeks ago

I added the csrf token but I'm still getting a 419

$.ajaxSetup({
      headers: {
            'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
        }
    });

Aron-Spiess left a reply on Trying To Send Js Variable After Load To Controller • 2 weeks ago

I don't think I can do the second option; my tabs are using the tableau js api; unless I can figure out a way to trigger the unique key to display in the url. Currently my progress consists of grabbing the current tab and any tab switch. I'll post my code in a minute... not at my work pc

2nd July, 2018

Aron-Spiess started a new conversation Trying To Send Js Variable After Load To Controller • 2 weeks ago

My site has some pages that have javascript tabs. Each tab has a unique identifier. I'd like to send that unique identifier to a controller so I can query info using that unique identifier on page load and return the results to the page

20th June, 2018

Aron-Spiess started a new conversation Can't Seem To Update A Database Record • 4 weeks ago

I have a form that writes a 1 record, sounds pretty easy right...

But when I try to edit what I just created, the form submits again as if I did a post store...

here's my code:

AccessController:

namespace App\Http\Controllers;

class AccessController extends Controller
{

    public function access($id)
    {
        // get access group
            select query
            ->where('seq_no', '=', $id)

    return view create
    }

    public function create()
    {
        // get access group
        select query
    ->where('seq_no', '=', $id)

        return view create
    }

/// this is what runs even though I'm updating
    public function store()
    { 
    \app\model::create([ columns and request fields ])
    return redirect index page
     }

    public function edit($id)
    { 
    select query
    ->where('seq_no', '=', $id)

        return view edit view
    }
    public function update()
    {
    validate some fields
    update field array
    update statement
    
    return redirect /view/$id/edit
    }
}

routes\web.php

// form for creating a Secure Access group relation
Route::get('/access/create','[email protected]')->name('access.create');

// form for creating a Secure Access group relation
Route::get('/access/{id}/edit','[email protected]')->name('access.edit');

// form for posting an update to an access group
Route::post('/access/{id}','[email protected]');

// form for posting an access group to database
Route::post('/access','[email protected]');

// get access view i.e. nhs tableau prod view
Route::get('/access/{id}','[email protected]')->name('access');

edit form and create form action post

create: action="../access"
edit: action="/index.php/access"

18th June, 2018

Aron-Spiess left a reply on Check If Authenticated Username Equals • 1 month ago

I'm validating against an ldap database and using the username which will always be unique.

Aron-Spiess left a reply on Check If Authenticated Username Equals • 1 month ago

I ended up using a combination of the last two answers

Aron-Spiess started a new conversation Check If Authenticated Username Equals • 1 month ago

I can't seem to verify if a username equals anything. I want to identify a couple of usernames as admins then redirect those users to an admin page and redirect others back to my index. I am able to redirect users back to the index only so far.

6th May, 2018

Aron-Spiess left a reply on Ldap Authentication • 2 months ago

Is there an update to this?

10th April, 2018

Aron-Spiess left a reply on Need Correct Usage Of Unions • 3 months ago

i ended up just writing it in sql.

Aron-Spiess started a new conversation Need Correct Usage Of Unions • 3 months ago

I keep getting a "collection" error followed by a number

   // get employee ids of direct reports to vp
        $directs = \DB::table('metrics_employees')
            ->select('employee_id')
            ->where([
                ['supervisor_Id', '=', '010101010'],
                ['status', '=', 'Active']
            ]);

        // get direct reports to vp
        $uniondirects = \DB::table('metrics_employees')
            ->select('seq_no','name_full','user_id')
            ->where([
                ['supervisor_Id', '=', '010101010'],
                ['status', '=', 'Active']
            ])
            ->get();

        // get direct reports to direct reports of jamie and then union results
        $managers = \DB::table('metrics_employees')
            ->select('seq_no','name_full','user_id')
            ->whereIn ('supervisor_Id', $directs)
            ->where ('status', '=', 'Active')
            ->unionAll($uniondirects)        /***this is breaking  ****/
            ->get();

        $leaders = \DB::table(DB::raw("({$managers -> toSql()}) as l"))
            ->join('metrics_employees as s','l.Supervisor_Id','=','s.Employee_Id')
            ->select('s.name_full AS supervisor','l.seq_no','l.name_full','l.user_id')
            ->get()
            ->toArray();

7th April, 2018

Aron-Spiess left a reply on Watchlist Remove Buttons Labelled "add To Watchlist" • 3 months ago

is it me or when I try to save something to my watch list, nothing gets marked permanently in my watch list.

22nd March, 2018

Aron-Spiess started a new conversation How To SelectRaw Two Or More Columns • 3 months ago

I assume I'm not going to use selectRaw to select two columns, but I don't understand what to write inside my controller. The following does not seem to work, it errors with "Class 'App\Http\Controllers\DB' not found", basically don't want to always use the model; I want to be able to use multiple tables and multiple columns.

$services = DB::table('metrics')
->select('seq_no','tile_name')
->where('tile_type', '=', 'service')
->orderBy('tile_name', 'asc')
->get();
->toArray;

Aron-Spiess left a reply on How To Pass {id} From Url To Controller • 3 months ago

okay, got it working thank you all. Here's what I had:

web.php:
Route::get('metrics/{id}','[email protected]')->name('metrics');

MetricsController:
->first()    // this must be declared, just -get() was not cutting it.\

view:
{{$metrics->url}}

21st March, 2018

Aron-Spiess started a new conversation How To Pass {id} From Url To Controller • 3 months ago

I'm trying to write my query to use {id} from the url. Here's my controller

class MetricsController extends Controller
{
    public function metrics($id)
    {   // get common tiles cost incident fulfillment etc
        $metrics = Metric::selectRaw('url')
            ->where('tile_id', $id)
            ->get()   
            ->toArray();

        return view('dashboard.metrics', compact('metrics'));
    }
}

Lastly, since it's just one record that returns, can I change ->get() to ->first() and how do I return it in my view {{$metrics->'url'}}

Aron-Spiess left a reply on My Links Only Work When I Have Index.php Included In The Address. • 3 months ago

updated last post, it's "server/sub_folder/laravel/public"

I could not find mod_rewrite in the httpd.conf file

Aron-Spiess left a reply on My Links Only Work When I Have Index.php Included In The Address. • 3 months ago

it's set to "/laravel/public"

Aron-Spiess left a reply on My Links Only Work When I Have Index.php Included In The Address. • 3 months ago

this is what's in there

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews -Indexes
    </IfModule>

    RewriteEngine On

    # Handle Authorization Header
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} (.+)/$
    RewriteRule ^ %1 [L,R=301]

    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>

Aron-Spiess started a new conversation My Links Only Work When I Have Index.php Included In The Address. • 3 months ago

My links only work when I have index.php included in the address. my server is running apache

http://server.com/index.php/dashboards/1  -- working
http://server.com/dashboards/1  -- not working

Aron-Spiess left a reply on Having Trouble Understanding Routes And Views • 3 months ago

capitalization was the issue, thank you. One other quirky thing... my links only work when I have index.php included in the address.

http://server.com/index.php/dashboards/1  -- working
http://server.com/dashboards/1  -- not working

Aron-Spiess left a reply on Having Trouble Understanding Routes And Views • 3 months ago

@roman.gutkin: when I click the link, I get "View [dashboard.Dashboards] not found."

Aron-Spiess started a new conversation Having Trouble Understanding Routes And Views • 3 months ago

I'm trying to link to views that are inside a folder.

example link from my leaders.blade.php onClick="window.location.href='{{route('Dashboards', ['id'=>$key])}}

Here's my views folder: -->views --> -->dashboard --> -->leaders.blade.php --> -->dashboards.blade.php --> -->metrics.blade.php

here's my web.php // get dashboard view i.e. cost, incident Route::get('dashboards/{id}', function () { return view('dashboard.Dashboards'); })->name('Dashboards');

// get metric view i.e. cost per ticket, custom Route::get('metrics/{id}', function () { return view('dashboard.Metrics'); })->name('Metrics');

Edit Your Profile
Update

Want to change your profile photo? We pull from gravatar.com.