glasstream2000

glasstream2000

Member Since 1 Year Ago

Experience Points 6,700
Experience Level 2

3,300 experience to go until the next level!

In case you were wondering, you earn Laracasts experience when you:

  • Complete a lesson — 100pts
  • Create a forum thread — 50pts
  • Reply to a thread — 10pts
  • Leave a reply that is liked — 50pts
  • Receive a "Best Reply" award — 500pts
Lessons Completed 49
Lessons
Completed
Best Reply Awards 0
Best Reply
Awards
  • start-engines Created with Sketch.

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • first-thousand Created with Sketch.

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • 1-year Created with Sketch.

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • 2-years Created with Sketch.

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • 3-years Created with Sketch.

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • 4-years Created with Sketch.

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • 5-years Created with Sketch.

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • school-session Created with Sketch.

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • welcome-newcomer Created with Sketch.

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • full-time-student Created with Sketch.

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • pay-it-forward Created with Sketch.

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • subscriber-token Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer-token Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • lara-evanghelist Created with Sketch.

    Laracasts Evangelist

    Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.

  • chatty-cathy Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

12 Aug
6 days ago

glasstream2000 left a reply on Error Message Not Showing Up On Incorrect Entry

Figured it out! Sometimes just posting the problem helps you see more clearly!

I had this:

return redirect()->back()->withMessage('You did not give the correct keyword for registration');

But needed this:

return redirect()->back()->withErrors([ 'You did not give the correct keyword for registration']);

glasstream2000 left a reply on Error Message Not Showing Up On Incorrect Entry

I have tried adding in my layouts.app:

<div class="container">
                @include('inc.messages')
            @yield('content')
            </div>

then including in an inc file:

@if(count($errors) > 0)
    @foreach($errors->all() as $error)
        <div class="alert alert-danger">

            {{$error}}
            
        </div>
    @endforeach
@endif

@if(session('success'))
    <div class="alert alert-success">

        {{session('success')}}

    </div>
@endif

@if(session('error'))
    <div class="alert alert-danger">

        {{session('error')}}

    </div>
@endif

glasstream2000 left a reply on Error Message Not Showing Up On Incorrect Entry

Well it is going back after you hit the submit button, so I would need to have something to add a message on that view correct?

glasstream2000 left a reply on Error Message Not Showing Up On Incorrect Entry

I don't have anything that I have added, if you enter in a wrong email format or don't fill in one of the fields you get a message since it is required, so I assumed that since it is required field and that I have, hmmm

return redirect()->back()->withMessage('You did not give the correct keyword for registration');

Yes this is stating to redirect back to another page which I don't need!

glasstream2000 started a new conversation Error Message Not Showing Up On Incorrect Entry

I have a registration form to register with a keyword. If the user enters in the wrong keyword is should say incorrect keyword, right now it just resets the form. If they enter in the correct keyword is registers them and redirects like it should. Any help would be appreciated!

My field on the registration page:

<form method="POST" action="{{ route('register') }}" aria-label="{{ __('Register') }}">
                        @csrf

                        <div class="form-group row">
                            <label for="name" class="col-md-4 col-form-label text-md-right">{{ __('Full Name') }}</label>

                            <div class="col-md-6">
                                <input id="name" type="text" class="form-control{{ $errors->has('name') ? ' is-invalid' : '' }}" name="name" value="{{ old('name') }}" required autofocus>

                                @if ($errors->has('name'))
                                    <span class="invalid-feedback" role="alert">
                                        <strong>{{ $errors->first('name') }}</strong>
                                    </span>
                                @endif
                            </div>
                        </div>

                        <div class="form-group row">
                            <label for="email" class="col-md-4 col-form-label text-md-right">{{ __('E-Mail Address') }}</label>

                            <div class="col-md-6">
                                <input id="email" type="email" class="form-control{{ $errors->has('email') ? ' is-invalid' : '' }}" name="email" value="{{ old('email') }}" required>

                                @if ($errors->has('email'))
                                    <span class="invalid-feedback" role="alert">
                                        <strong>{{ $errors->first('email') }}</strong>
                                    </span>
                                @endif
                            </div>
                        </div>
                        
                        <div class="form-group row">
                            <label for="name" class="col-md-4 col-form-label text-md-right">{{ __('Keyword') }}</label>

                            <div class="col-md-6">
                                <input id="keyword" type="text" class="form-control{{ $errors->has('keyword') ? ' is-invalid' : '' }}" name="keyword" value="{{ old('keyword') }}" required autofocus>

                                @if ($errors->has('keyword'))
                                    <span class="invalid-feedback" role="alert">
                                        <strong>{{ $errors->first('keyword') }}</strong>
                                    </span>
                                @endif
                            </div>
                        </div>

My register controller:

<?php

namespace App\Http\Controllers\Auth;

use App\User;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Validator;
use Illuminate\Foundation\Auth\RegistersUsers;
use Illuminate\Http\Request;
use Illuminate\Auth\Events\Registered;

class RegisterController extends Controller
{
    /*
    |--------------------------------------------------------------------------
    | Register Controller
    |--------------------------------------------------------------------------
    |
    | This controller handles the registration of new users as well as their
    | validation and creation. By default this controller uses a trait to
    | provide this functionality without requiring any additional code.
    |
    */

    use RegistersUsers;

    /**
     * Where to redirect users after registration.
     *
     * @var string
     */
    protected $redirectTo = '/dashboard';

    /**
     * Create a new controller instance.
     *
     * @return void
     */
    public function __construct()
    {
        $this->middleware('guest');
    }

    /**
     * Get a validator for an incoming registration request.
     *
     * @param  array  $data
     * @return \Illuminate\Contracts\Validation\Validator
     */
    protected function validator(array $data)
    {
        return Validator::make($data, [
            'name' => 'required|string|max:255',
            'email' => 'required|string|email|max:255|unique:users',
            'password' => 'required|string|min:6|confirmed',
            'keyword' => 'required|string',
        ]);
    }

    /**
     * Create a new user instance after a valid registration.
     *
     * @param  array  $data
     * @return \App\User
     */
    protected function create(array $data)
    {
        return User::create([
            'name' => $data['name'],
            'email' => $data['email'],
            'password' => Hash::make($data['password']),
        ]);
    }
    
    public function register(Request $request)
    {

    if($request->keyword != env('REGISTRATION_KEYWORD')) {
        return redirect()->back()->withMessage('You did not give the correct keyword for registration');
        //return redirect()->back('success', 'You did not give the correct keyword for registration');
    }
        $this->validator($request->all())->validate();

        event(new Registered($user = $this->create($request->all())));

        $this->guard()->login($user);

        return $this->registered($request, $user)
                        ?: redirect($this->redirectPath());
    }
    
}

My env field to validate against:

REGISTRATION_KEYWORD=future2019
29 Apr
3 months ago

glasstream2000 started a new conversation Pre Append Numbers To A Form Field Randomly

I'm looking for a way to add numbers randomly to the beginning of the last 4 of a social number. I don't want to keep the entire ssn as I don't need it but need to have 9 digits for importing to another program.

So basically I have an input field that asks for the last 4 of the ssn, I want to have a random generator to add 123-34- to the input field in front of what is sent to the database to make dummy ssn's so the other program will import since it requires 9 digits.

Is this a possibility with laravel 5.6 and has anyone done this or point me in the right direction, or is there a better way to do this?

04 Dec
8 months ago

glasstream2000 left a reply on Redirect

This is working perfectly!

if(!isset($_SERVER['HTTP_REFERER'])){
    // redirect them to your desired location
    header('location:../C3');
    exit;
}
03 Dec
8 months ago

glasstream2000 left a reply on Redirect

Ok I have this and it redirects if you try and go to A9 directly

A8

function myTestFunction() {
            var referrer = document.referrer;
             alert(referrer);
        }

A9

var referrer =  document.referrer;
    
 var referrer =  document.referrer;
   if(referrer.indexOf("A8") > -1) {          
    window.location.replace("A9");
   }
 
   if(referrer.indexOf("") > -1) {           
    window.location.replace("C3");
   }

BUT it will also redirect to C3 if you come from A8, do I need == to or, sorry don't know javascript to much yet.

glasstream2000 left a reply on Redirect

Trying this on the page before:

function myTestFunction() {
            var referrer = document.referrer;
             alert(referrer);
        }

and this on the page after:

var referrer =  document.referrer;
    
    if(referrer.indexOf("exam.test/A8") > -1) {
      
     if(referrer.indexOf("A8") > -1) {          
      window.location.replace("A9");
     }
 
    }
     
    else
     {
     redirect("exam.test/C3");
     }

Not working on my local enviroment by visting exam.test/A9 directly, still shows the page. On the right track?

glasstream2000 left a reply on Redirect

Good question, I haven't seen anything that I can use to accomplish that, It wouldn't be session based as they would already be logged in, or would it. I'm still new to Laravel and learning by examples. Have seen some instances using javascript like

on the previous page

window.onload = function() {
    var window.parentPage = true;
    localStorage.setItem("storageName",window.parentPage);

On the page i'm trying to prevent direct access

window.onload = alert(localStorage.getItem("window.parentPage"));

but it doesn't work. If sessions would be better I would rather do that in Laravel, guess i looking for any resources that someone might know about that I haven't found via Google yet.

I see you used document referrer, I also tried using the below in @php tags but didn't work

$referrer = $_SERVER['HTTP_REFERER'];
if (!preg_match("/main/index.html",$referrer)) {
header('Location: http://www.mywebsite.org/main/index.html');
} ;

glasstream2000 started a new conversation Redirect

I'm just looking for a simple javascript in add in my PHP pages in Laravel that will check to see if the user came from the correct page and if not redirect them back to the home page. So the home page is index.php and they are at page9.php and then click a link and go to page10.php, if they tried to skip page 9 then redirect back to index.php

I know it isn't like secure since it is client side, but I'm not looking for secure like that, just to keep most on track. Anyone have any examples I can try, everything on the net that I have found seems not to work.

Thanks in advance!

16 Nov
9 months ago

glasstream2000 left a reply on Hiding URL

Hey Cronix, after searching about what you said I came up with the idea of my pages using numbers like 1,2, 3 etc... and then using hashids to scramble the page number in the url so someone couldn't just enter in app.test/AW/3 and jump ahead. I know people use it for the id from what i have read. My pages could be up to 50+ if that would make any difference

Think that could work? I'm still new to laravel and not looking for an unbreakable thing, just something that makes it harder to try and pass pages. Or do you think sessions is still the way to go and do you know of any articles that could get me going in the right direction?

15 Nov
9 months ago

glasstream2000 started a new conversation Hiding URL

Question, when you take a course online and the only way to navigate the site is via a next or back button, using the back on the browser will error or even trying to put the URL in the browser will error also. Like giving a test online and forcing the user to go through without being able to cheat. Are all those made out of Javascript or does anyone have anything they can pass my way to look up on how to achieve something like that?

14 Nov
9 months ago

glasstream2000 left a reply on Not Passing Var

Thanks, Talinon, I'm still new at Laravel! your suggestions worked perfectly! it is showing the listing id properly. Question, why once i take out the dd I'm getting the Undefined variable: listing or Undefined variable: listing_id ? It is passing the information as i can see it via the dd

public function store(Request $request)
    {
        //dump($request->all());
          //dd($request['listing_id']);
          
         $listing_id->addFavorite();
        
         return view('rates/show');
    }

glasstream2000 started a new conversation Not Passing Var

Have a button that when a user clicks on it it will favorite that listing. Using ChristianKuri/laravel-favorite package. When I click on the button and dd before it goes into the controller, it is just showing "$listing_id" so It isn't passing the actual listing id to the controller which is why it says the $listing_id in undefined.

controller

public function store()
    {
        dd('$listing_id');
         $listing_id->addFavorite();
        
         return view('rates/show');
    }

blade

 @foreach($listings as $listing)
                                <tr>
                                <td>{{$listing->category}}</td>
                                <td>{{$listing->item}}</td>
                                <td>{{$listing->right_rate}}</td>
                                <td>{{$listing->left_rate}}</td>
                                <td>{{$listing->right_rate1}}</td>
                                <td>{{$listing->left_rate1}}</td>
                                <td>{{$listing->comments}}</td>
                                <td>{{$listing->balance_with}}</td>
                                <td>{{$listing->check_name_1}}</td>
                                <td>{{$listing->check_name_2}}</td>
                                <td>{{$listing->check_name_3}}</td> 
                                <td>{{$listing->check_name_4}}</td>
                                <td>{{$listing->frequency}}</td>
                                <td>
                                    
 
                                    
                                    {!!Form::open(['action' => '[email protected]','method' => 'POST'])!!}
                                    {{ Form::hidden('listing-id', $listing->id) }}
                                    <button name="submit" type="submit" class="btn btn-primary">Submit</button>
                                    {!! csrf_field() !!}
                                
                                {!! Form::close() !!}
                                
                            </tr>         
                    @endforeach  

route

Route::middleware(['auth'])->group(function() {
    
    Route::get('/dashboard', '[email protected]');

    //Testing new routes

    Route::post('listing/show', '[email protected]');


    
    //Route::resource('listings', 'ListingsController');
    
    Route::get('rates', '[email protected]'); 
12 Nov
9 months ago

glasstream2000 started a new conversation Jeffery Ways "Favorite This"

I'm at a loss since his works and mine does not. It is exactly like his except the ->before('auth|csrf') at the end of the routes as it threw an error. Only thing i can think of is a different Laravel version? I'm using 5.7, he dosen't state what he uses and if it was a version issue, you would think he would state that.

The below gives me "Undefined variable: favorites (View: /Users/admin/Code/app/resources/views/rates.blade.php)" even though it is just like his. Any idea's?

rates.blade

@extends('layouts.app')

@section('content')

    <div class="row justify-content-center">
        <div class="col-lg-12">
            <div class="card">
                <div class="card-header">Betar Rates <span class="float-right"><a href="/dashboard" class="btn btn-success btn-xs">Back</a> | @if (auth()->user()->isAdmin())<a href="/admin/index" class="btn btn-info btn-xs">Admin Dashboard</a> @endif </span></div>
                <div class="container">
                  <div class="row justify-content-md-center">
                   <div class="col col-lg-6">
        
    <input type="search" class="light-table-filter form-control here" data-table="order-table" placeholder="Custom Search..." />
  
  
  <select type="search" class="select-table-filter custom-select" data-table="order-table">
          <option value="">Reset</option>  
          <option value="planet">Planet</option>
          
  <select>
                     </div>
                      </div>
                    </div>
                <div class="card-body">
                    @if (session('status'))
                        <div class="alert alert-success" role="alert">
                            {{ session('status') }}
                        </div>
                    @endif
                    @if(count($listings))
                        <table class="order-table table table-striped" id="myTable">
                            <tr>
                                <th>Category</th>
                                <th>Item</th>
                                <th>Right Rate</th>
                                <th>Left Rate</th>
                                <th>Right Rate 2</th>
                                <th>Left Rate 2</th>
                                <th>Comments</th>
                                <th>Balance With</th>
                                <th>Check Name 1</th>
                                <th>Check Name 2</th>
                                <th>Check Name 3</th>
                                <th>Check Name 4</th>
                                <th>Frequency</th>
                                <th>Favorite</th>
                                
                            </tr>
                    @foreach($listings as $listing)
                                <tr>
                                <td>{{$listing->category}}</td>
                                <td>{{$listing->item}}</td>
                                <td>{{$listing->right_rate}}</td>
                                <td>{{$listing->left_rate}}</td>
                                <td>{{$listing->right_rate1}}</td>
                                <td>{{$listing->left_rate1}}</td>
                                <td>{{$listing->comments}}</td>
                                <td>{{$listing->balance_with}}</td>
                                <td>{{$listing->check_name_1}}</td>
                                <td>{{$listing->check_name_2}}</td>
                                <td>{{$listing->check_name_3}}</td> 
                                <td>{{$listing->check_name_4}}</td>
                                <td>{{$listing->frequency}}</td>
                                <td>
                                @if ($favorited = in_array($listing->id, $favorites))
                                {{ Form::open(['method' => 'DELETE', 'route' => ['favorites.destroy', $listing->id]]) }}


                                @else
                                {{ Form::open(['route' => 'favorites.store']) }}
                                {{ Form::hidden('listing-id', $listing->id) }}
                                @endif
                                <button type="submit" class="">
                                    <i class="fa fa-star {{ $favorited ? 'favorited' : 'not-favorited' }}"></i>
                                </button>
                                {{ Form::close()}}
                             
                            </tr>         
                    @endforeach  

                        

                    @else
                        <p>No Rates Found!</p>
                    @endif
                    </table>
                </div>
            </div>
        </div>
    </div>

@endsection

<script>

        (function(document) {
    'use strict';

    var LightTableFilter = (function(Arr) {

        var _input;
    var _select;

        function _onInputEvent(e) {
            _input = e.target;
            var tables = document.getElementsByClassName(_input.getAttribute('data-table'));
            Arr.forEach.call(tables, function(table) {
                Arr.forEach.call(table.tBodies, function(tbody) {
                    Arr.forEach.call(tbody.rows, _filter);
                });
            });
        }
    
        function _onSelectEvent(e) {
            _select = e.target;
            var tables = document.getElementsByClassName(_select.getAttribute('data-table'));
            Arr.forEach.call(tables, function(table) {
                Arr.forEach.call(table.tBodies, function(tbody) {
                    Arr.forEach.call(tbody.rows, _filterSelect);
                });
            });
        }

        function _filter(row) {
      
            var text = row.textContent.toLowerCase(), val = _input.value.toLowerCase();
            row.style.display = text.indexOf(val) === -1 ? 'none' : 'table-row';

        }
    
        function _filterSelect(row) {
     
            var text_select = row.textContent.toLowerCase(), val_select = _select.options[_select.selectedIndex].value.toLowerCase();
            row.style.display = text_select.indexOf(val_select) === -1 ? 'none' : 'table-row';

        }

        return {
            init: function() {
                var inputs = document.getElementsByClassName('light-table-filter');
                var selects = document.getElementsByClassName('select-table-filter');
                Arr.forEach.call(inputs, function(input) {
                    input.oninput = _onInputEvent;
                });
                Arr.forEach.call(selects, function(select) {
         select.onchange  = _onSelectEvent;
                });
            }
        };
    })(Array.prototype);

    document.addEventListener('readystatechange', function() {
        if (document.readyState === 'complete') {
            LightTableFilter.init();
        }
    });

})(document);
</script> 

User Model

<?php

namespace App;

use Illuminate\Notifications\Notifiable;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Foundation\Auth\User as Authenticatable;
use App\Listing;

class User extends Authenticatable
{
    use Notifiable;

    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [
        'name', 'email', 'password', 'created_at', 'isAdmin', 'superAdmin',
    ];

    /**
     * The attributes that should be hidden for arrays.
     *
     * @var array
     */
    protected $hidden = [
        'password', 'remember_token',
    ];

    // Add One to many relationship
    public function listings(){
        return $this->hasMany('App\Listing')->latest();
    }

    public function favorites()
    {
        return $this->beLongsToMany('App\Listing', 'favorites')->withTimestamps();
    }
    
    
    public function isAdmin()
    {
        
        return $this->isAdmin;
    }
    
    public function superAdmin()
    {
        
        return $this->superAdmin;
    }
    
}

routes

Route::get('/rates', function()
{
    $listings = Listing::all();
    return View::make('rates', compact('listings'));
});

Route::get('users/{id}/favorites', function ($userId)
{
    $listings = User::findOrFail($userId)->favorites;
    return View::make('rates', compact('listings'));
});


    Route::post('favorites', ['as' => 'favorites.store', function() {

        Auth::user()->favorites()->attach(Input::get('listing-id'));

        return Redirect::back();

    }]);

    Route::delete('favorites/{listingId}', ['as' => 'favorites.destroy', function($listingId) {

        Auth::user()->favorites()->detach('listingId');

        return Redirect::back();

    }]);
09 Nov
9 months ago

glasstream2000 left a reply on Auth If Statement

Ok been trying different versions of Gate and maybe i'm missing something or doing something wrong since it acts like it does nothing for me on that page.

route

 Route::get('/globaladmin', function () {
                if (Gate::allows('superAdmin', Auth::user())) {
                return view('admin/users');
                    }
            });

Auth Service Prov

public function boot()
    {
        $this->registerPolicies();

       Gate::define('superAdmin', function ($user) {
           
           if ($user->superAdmin == 1) {
               return true;
           }
           
            return false;
           
       });
    }

User Model

public function superAdmin()
    {
        
        return $this->superAdmin;
    }
    
08 Nov
9 months ago

glasstream2000 left a reply on Auth If Statement

Gate has me a little blown away and so far all it does is make the site inaccessible following https://laracasts.com/series/laravel-from-scratch-2018/episodes/27

Any other docs that might help explain it in a more of an example way?

glasstream2000 started a new conversation Auth If Statement

I have a column that is called isAdmin and i want to allow an admin marked as a 1 to view everything a user can, plus the admin dashboard. Then I want a super admin marked as 3 to view everything a user can and an admin can plus other pages. I assume an if statement but the below didn't work. thoughts?

public function handle($request, Closure $next)
    {

        if (Auth::check() && Auth::user()->isAdmin == 1): 
            
            return view('admindashboard');
            
        elseif (Auth::check() && Auth::user()->isAdmin == 3):
                    
            return $next($request);
            
        else: return redirect('/dashboard');

        endif;
    }

glasstream2000 left a reply on Middleware Not Working

Ok figured it out, looks like i needed to change the route group to:

Route::middleware(['isAdmin'])->group(function() {   

    routes in here


});

works like a charm!

glasstream2000 left a reply on Middleware Not Working

Tried all 3 ideas and not go, took off the quotes and it made not difference. Added the backslash and still the same result and changing the Middleware to lowercase only through an error as the Middleware folder in 5.6 is capitalized. Any other idea's, did I implement it wrong or something?

For what it is worth this actually works - shows a button depending on if the user isAdmin or not

<div class="card-header border-success"><span style="font-size: 22px"><i class="fa fa-home fa-fw"></i> Dashboard</span> <span class="float-right">@if (auth()->user()->isAdmin()) <a href="/admindashboard" class="btn btn-success btn-xs">Admin Dashboard</a>@else @endif</span></div>
07 Nov
9 months ago

glasstream2000 started a new conversation Controllers

My understanding is that you use a route to different functions on a controller, so if you had a CRUD set of pages for one controller, can you use the same controller for a different set of CRUD pages or would you have to make another controller, best practice?

glasstream2000 left a reply on Error On Updating Users

Wow thanks, Cronix, you're a genius! I have stared at it so long! question the Difference between using find vs findOrFail?

glasstream2000 started a new conversation Middleware Not Working

My middleware doesn't seem to be working, I have a field in my users table that has isAdmin column and if it is set to 1 then they are admin and if it is 0 then they are not. But someone that is not can still get to my admin pages. I thought I implemented it correctly but maybe missed something.

user model

use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;
use App\Http\Middleware\isAdmin;
use App\Http\Controllers\Controller;
use App\Listing;

class User extends Authenticatable
{
    use Notifiable;

    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [
        'name', 'email', 'password', 'created_at', 'isAdmin'
    ];

    /**
     * The attributes that should be hidden for arrays.
     *
     * @var array
     */
    protected $hidden = [
        'password', 'remember_token',
    ];
    
    // Add One to many relationship
    public function listings(){
        return $this->hasMany('App\Listing')->latest();
    }
    
    
    public function isAdmin()
    {
        
        return $this->isAdmin;
    }
    
    public function setPasswordAttribute($password)
    {   
        $this->attributes['password'] = bcrypt($password);
    }
    
}

kernel

protected $routeMiddleware = [
        'auth' => \Illuminate\Auth\Middleware\Authenticate::class,
        'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
        'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class,
        'can' => \Illuminate\Auth\Middleware\Authorize::class,
        'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
        'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
        'isAdmin' => 'App\Http\Middleware\isAdmin::class',
    ];

Route

Route::group(['Middleware' => ['auth', 'isAdmin']], function()
        {
            
            
           Route::get('/admindashboard', '[email protected]');
           Route::get('export-file/{type}', '[email protected]')->name('export.file');
            
           Route::get('admin', '[email protected]');
           Route::get('index', '[email protected]');
            
            
            
            // global admin
            Route::get('/globaladmin', function () {
                return view('admin/index');
            });
            
           Route::resource('admin/users', 'GlobalAdminController');
           Route::get('admin/users/create', '[email protected]');
           Route::get('admin/users/edit', '[email protected]');
            
                }

in my controllers i have

 public function __construct()
    {
        $this->middleware('auth');

       
    }

my middleware class

namespace App\Http\Middleware;

use Closure;
use Illuminate\Support\Facades\Auth;
use App\Http\Middleware\isAdmin;

class isAdmin
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @param  string|null  $guard
     * @return mixed
     */
    public function handle($request, Closure $next)
    {

        if (Auth::check() && Auth::user()->isAdmin()) {
            
            return $next($request);
            
        }

        return redirect('/dashboard');
    }

glasstream2000 started a new conversation Error On Updating Users

I'm getting an error trying to update a user with my form.

(1/1) ErrorException
Creating default object from empty value

in GlobalAdminController.php line 135
at HandleExceptions->handleError(2, 'Creating default object from empty value', 'C:\inetpub\wwwroot\BanksCounty\app\Http\Controllers\GlobalAdminController.php', 135, array('request' => object(Request), 'id' => '$user->id', 'usercreate' => object(stdClass)))
in GlobalAdminController.php line 135
at GlobalAdminController->update(object(Request), '$user->id')

controller

use Illuminate\Http\Request;
use App\Listing;
use App\User;
use App\Location;

class GlobalAdminController extends Controller
{
    
    public function __construct()
    {
        $this->middleware('auth');

        //$this->middleware('log')->only('index');

        
    }
    
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        
        //$users = User::orderBy('name', 'desc')->get();
        
        //return view('admin.users.index')->with('users', $users);
        
        $users = User::all();
        
        return view('admin/users/index', compact('users'));
    }
    
    

    /**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function create()
    {
        
        
        return view('admin/users/create');
    }
    

    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function store(Request $request)
    {
        $this->validate($request, [
            
            'name' => 'required',
            'isAdmin' => 'required',
            'email' => 'required',
            'password' => 'required',
            
            
            
        ]);
        
        // create the listing now
        
        $usercreate = new User;
        $usercreate->name = $request->input('name');
        $usercreate->isAdmin = $request->input('isAdmin');
        $usercreate->email = $request->input('email');
        $usercreate->password = $request->input('password');
        
        
        $usercreate->save();
        
        return redirect('admin/users')->with('success', 'User Added!');
    }

    /**
     * Display the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function show($id)
    {
      
    }

    /**
     * Show the form for editing the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function edit($id)
    {
        
        $user = User::find($id);
        
        return view('admin.users.edit')->with('user', $user);
    }

    /**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function update(Request $request, $id)
    {
        $this->validate($request, [
            
            'name' => 'required',
            'isAdmin' => 'required',
            'email' => 'required',
            'password' => 'required',
            
            
            
        ]);
        
        // create the listing now
        
        $usercreate = User::find($id);
        $usercreate->name = $request->input('name');
        $usercreate->isAdmin = $request->input('isAdmin');
        $usercreate->email = $request->input('email');
        $usercreate->password = $request->input('password');
        
        
        $usercreate->save();
        dd('$usercreate');
        //return redirect('admin/users')->with('success', 'User Updated!');
    }

    /**
     * Remove the specified resource from storage.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function destroy($id)
    {
        $user = User::find($id);
        $user->delete();
        
        return redirect('admin/users')->with('success', 'Log Deleted!');
    }
}

edit blade file

{!!Form::open(['action' => ['[email protected]','$user->id'], 'method' => 'PUT'])!!}
<form>
  
  <div class="form-group row">
    <label for="name" class="col-2 col-form-label">Name</label> 
    <div class="col-10">
      <div class="input-group">
        <div class="input-group-prepend">
          <span class="input-group-text" id="inputGroupPrepend"><i class="fa fa-chevron-right"></i></span>
        </div> 
        <input id="name" name="name" placeholder="Name" type="text" class="form-control here" value="{{$user->name}}">
      </div>
    </div>
  </div>
      <div class="form-group row">
    <label for="email" class="col-2 col-form-label">Is Admin</label> 
    <div class="col-10">
      <div class="input-group">
        <div class="input-group-prepend">
          <span class="input-group-text" id="inputGroupPrepend"><i class="fa fa-chevron-right"></i></span>
        </div> 
        <input id="isAdmin" name="isAdmin" placeholder="isAdmin" type="text" class="form-control here" value="{{$user->isAdmin}}">
      </div>
    </div>
    </div>
  <div class="form-group row">
    <label for="email" class="col-2 col-form-label">Email</label> 
    <div class="col-10">
      <div class="input-group">
        <div class="input-group-prepend">
          <span class="input-group-text" id="inputGroupPrepend"><i class="fa fa-chevron-right"></i></span>
        </div> 
        <input id="email" name="email" placeholder="Email" type="text" class="form-control here" value="{{$user->email}}">
      </div>
    </div>
  </div> 
    <div class="form-group row">
    <label for="id" class="col-2 col-form-label">Password</label> 
    <div class="col-10">
      <div class="input-group">
        <div class="input-group-prepend">
          <span class="input-group-text" id="inputGroupPrepend"><i class="fa fa-chevron-right"></i></span>
        </div> 
        <input id="password" name="password" placeholder="Password" type="text" class="form-control here" value="{{$user->password}}"></input>
      </div>
    </div>
  </div>
  <div class="form-group row">
    <div class="offset-2 col-10">
      <button name="submit" type="submit" class="btn btn-primary">Submit</button>
    </div>
  </div>
</form>
                        {!! Form::close() !!}

route - create user works fine!

Route::get('admin/users/create', '[email protected]');
           Route::get('admin/users/edit', '[email protected]');

Any ideas? using mysql as the database, standard laravel 5.6 user table...

06 Nov
9 months ago

glasstream2000 left a reply on List From Database With Links To Other Pages

Thanks, Tykus, I have a lot to try and still a lot to learn as well! but I think I'm following you, i will let you know! Ty for your replies and help!

glasstream2000 left a reply on List From Database With Links To Other Pages

So my link would then have the module id in it and just use that in the route to go to the correct page basically? What would a route look like? something like the below?

return redirect()->route('/Module/page1', ['id' => 1]);
return redirect()->route('/Module/page2', ['id' => 2]);

or

return redirect()->action(
    '[email protected]', ['id' => 1]
);

And then return the view from the controller under id1?

glasstream2000 started a new conversation List From Database With Links To Other Pages

What I'm trying to do is create unique links that will go to different pasges for each of the modules that the foreach loop returns, is that possible?

blade

<tbody>
        @foreach($modules as $module)
      <tr>
        <td><a href="/listings/create">{{$module->modules}}</a></td>
      </tr>
        @endforeach 

Controller

public function create()
   {
       $modules = Module::orderBy('modules', 'desc')->get();
        
        return view('dashboard', compact('modules'));
   }

glasstream2000 left a reply on Dropdown List

Nevermind! I just saw after i posted that my protect fillable was location and suppose to have been locations!

glasstream2000 started a new conversation Dropdown List

I have a drop-down list that is populating from a table in my database, I want to be able to select something from the dropdown and submit the form and whatever is selected in the drop-down get entered in the database. Right now it is not putting anything in. Maybe I'm missing something obvious...

Controller

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Listing;
use App\Location;
use DB;
use Yajra\Datatables\Datatables;

class ListingsController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        
      
    
    }
    
    
    // Pull all records from DB and modify route and controller
    public function getData() 
    {
       
     }
    
    

    /**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function create()
    {
        
       $locations = Location::orderBy('locations', 'desc')->get();
        
       return view('createlisting', compact('locations'));
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function store(Request $request)
    {
        $this->validate($request, [
            'first_name' => 'required',
            'last_name' => 'required',
            'year_born' => 'required',
            'last_four' => 'required',
            'location' => '',
            'email' => 'email'
        ]);
        
        
        // create record
        $listing = new Listing;
        $listing->first_name = $request->input('first_name');
        $listing->last_name = $request->input('last_name');
        $listing->year_born = $request->input('year_born');
        $listing->last_four = $request->input('last_four');
        $listing->location = $request->input('location');
        $listing->email = $request->input('email');
        $listing->module = $request->input('module');
        $listing->user_id = auth()->user()->id;
        
        $listing->save();
        
        return redirect('/dashboard')->with('success', 'Module Completed');
        
    }

Blade - my table in the database that the dropdown is pulling from is locations and the table listings that I need it to go into, the field is called location.

<div class="form-group row">
    <label for="location" class="col-2 col-form-label">Location</label> 
    <div class="col-10">
      <select id="location" name="location" class="custom-select" required="required">
        <option value="">Please select a location</option>
          @foreach ($locations as $location)
        <option value="{{ $location->locations }}">{{ $location->locations }}</option>
        @endforeach
      </select>
    </div>
  </div>

Model

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Location extends Model
{
    protected $fillable = ['location'];
}

route

Route::resource('listings', 'ListingsController');

glasstream2000 left a reply on Pulling From Database

You are the man Seriu17! thanks worked perfectly!

05 Nov
9 months ago

glasstream2000 left a reply on Pulling From Database

Wouldn't I need different variables to place the modules in to count them individually?

01 Nov
9 months ago

glasstream2000 left a reply on Pulling From Database

When I dd that it comes up with nothing. What I want is each different item in that Column pulled into a different variable like

$amp = Listing::groupBy('modules')->select('modules', DB::raw('count('amp') as total'))->get();
$speakers = = Listing::groupBy('modules')->select('modules', DB::raw('count('speakers') as total'))->get();

etc..

glasstream2000 started a new conversation Pulling From Database

I have a table that has a column called modules and in that column, i have data like Amp - Speakers - projectors etc..

Is there a way in Laravel to pull the count for just Speakers from that column. Likewise, I would do the same for Amp and Projectors.

Using this method to pull the entire count from the table as a whole. My Question is how would i add the count for the Amp and then Speakers from above? I have tried a foreach loop which I haven't been able to get working with my chart code.

$module = Listing::count();
31 Oct
9 months ago

glasstream2000 left a reply on Query And Charts

Clicked the check on accident!

glasstream2000 left a reply on Query And Charts

$modules = Listing::pluck('module', 'module')->count();

Got it working, it shows the total for that column! Is there any way to count the entries that match amp and that match speakers and then pull those into separate variables?

glasstream2000 left a reply on Query And Charts

This is showing a blank, and also would only pull the total number of all modules, not the individual name totals.

tried:

$modules = Listing::pluck('module')->count();

glasstream2000 left a reply on Query And Charts

I am pulling the count correctly for the listing count and user count, my question is on another column in the same table.

glasstream2000 started a new conversation Query And Charts

Question, i have a chart that shows a bar for the count of my listings table. I would like to take a column from the same table and count each of the entries by name. Example, my column is called modules and in that column, it has entries like: cd, amp, speakers, cd, speakers, amp, amp, amp etc..

How could i pull that column and count by name so i would have 1 bar showing 2 for "cd", another bar showing 4 for "amp" and another bar showing 2 for speakers etc... Using Laravel 5.6 as well

Also, how would one pass that to the chart using chartjs, tried a foreach loop but that doesn't render anything, just a blank space. My code below, thanks for any thoughts.

Controller:

use Illuminate\Http\Request;

use App\Listing;
use App\User;
use APP\Module;
use DB;

class ChartController extends Controller
{
    
    public function index(){
         
        $listingCount = Listing::count();
        $user = User::count();
         
        //$listingCount = DB::table('listings')->list('module');

        return view('/admindashboard', compact('listingCount', 'user'));
        
    }

Route:

Route::get('/admindashboard', '[email protected]');

Blade script for chartjs

<canvas id="myModules" width="400" height="100"></canvas>



<script>
var ctx = document.getElementById("myModules").getContext('2d');
var myChart = new Chart(ctx, {
    type: 'bar',
    data: {
        labels: ["Total Modules", "Total Users"],
        datasets: [{
            label: 'Modules',
            data: [{{$listingCount}}, {{$user}}],
            backgroundColor: [
                'rgba(255, 99, 132, 0.2)',
                'rgba(54, 162, 235, 0.2)',
                'rgba(255, 206, 86, 0.2)',
                'rgba(75, 192, 192, 0.2)',
                'rgba(153, 102, 255, 0.2)',
                'rgba(255, 159, 64, 0.2)'
            ],
            borderColor: [
                'rgba(255,99,132,1)',
                'rgba(54, 162, 235, 1)',
                'rgba(255, 206, 86, 1)',
                'rgba(75, 192, 192, 1)',
                'rgba(153, 102, 255, 1)',
                'rgba(255, 159, 64, 1)'
            ],
            borderWidth: 1
        }]
    },
    options: {
        scales: {
            yAxes: [{
                ticks: {
                    beginAtZero:true
                }
            }]
        }
    }
});
</script>
30 Oct
9 months ago

glasstream2000 left a reply on Undefined Var

Question, i got the above working and my chart shows a bar for the count of the listings table. I would like to take a column for the same table and count the entries by name. Example, i have a column called modules and in that column, it has entries like: cd, amp, speakers, cd, speakers, amp, etc..

How could i pull that and count by name so 1 bar showing 2 for cd, another bar showing 2 for amp etc...

and how would one pass that to the chart using chartjs, tried a foreach loop but that doesn't render anything, just a blank space

29 Oct
9 months ago

glasstream2000 left a reply on Undefined Var

I got Ya! TY all!

glasstream2000 left a reply on Undefined Var

I have these routes as I'm getting other data to that page, would having multiple routes cause the issue? Any way that I can consolidate them?

Route::group(['middleware' => ['auth', 'isAdmin']], function()
        {
            Route::get('/admin', function () {
                return view('admin');
                });
            
            Route::get('/admin', '[email protected]');
            
            // get all items from DB
            Route::get('/admin', '[email protected]');
            
           Route::get('admin', '[email protected]');
            Route::get('index', '[email protected]');

glasstream2000 started a new conversation Undefined Var

This is driving me crazy, I have to be missing something really obvious, please help!

Undefined Variable listingCount in admin.blade

admin.blade

<canvas id="myModules" width="400" height="400"></canvas>



<script>
var ctx = document.getElementById("myModules").getContext('2d');
var myChart = new Chart(ctx, {
    type: 'bar',
    data: {
        labels: ["Posts", "Categories", "Comments"],
        datasets: [{
            label: 'Modules',
            data: [{{$listingCount}},],
            backgroundColor: [
                'rgba(255, 99, 132, 0.2)',
                'rgba(54, 162, 235, 0.2)',
                'rgba(255, 206, 86, 0.2)',
                'rgba(75, 192, 192, 0.2)',
                'rgba(153, 102, 255, 0.2)',
                'rgba(255, 159, 64, 0.2)'
            ],
            borderColor: [
                'rgba(255,99,132,1)',
                'rgba(54, 162, 235, 1)',
                'rgba(255, 206, 86, 1)',
                'rgba(75, 192, 192, 1)',
                'rgba(153, 102, 255, 1)',
                'rgba(255, 159, 64, 1)'
            ],
            borderWidth: 1
        }]
    },
    options: {
        scales: {
            yAxes: [{
                ticks: {
                    beginAtZero:true
                }
            }]
        }
    }
});
</script>

Route

Route::get('/admin', '[email protected]');

Controller

class ChartController extends Controller
{

   
       //
    
    public function index(){
        
        
        $listingCount = Listing::count();
        

        
        return view('/admin', ['listingCount' => $listingCount]);
        
        
    }

Model

class Listing extends Model
{
    
    protected $fillable = [

        'module',
        'location'

    ];
    

    }
19 Oct
9 months ago

glasstream2000 started a new conversation Laravel Structure

I have about 90 different businesses and each will have their own database and their own css and stuff since they are different looking. I also have what I would call modules, that would be shared with all of them so I would not have to update 90 of the same module but I need some way when they finish the module to go into the proper database for that business. They will also have custom modules tailored to them as well that will be unique and only available to them.

My question is, how can I use a single Laravel install to do all that with, like folder structure, individual database connections to their respective database and able to route them to the proper database after the "common" modules are taken. Or is this even possible? Could a single Laravel instance handle that?

I'm learning Laravel and love it so far, so please explain if you have any ideas in lamens terms! Thank you for reading and any ideas this great community might have!

18 Oct
10 months ago

glasstream2000 left a reply on Order By Created_at

Thank you! So many different ways of doing the same thing, it is sometimes confusing lol

glasstream2000 started a new conversation Order By Created_at

New here, trying to sort the listings by created_at in desc value.

This code pulls my listings with the newest on the bottom.

$user_id = auth()->user()->id;
        
        $user = User::find($user_id);
        
        return view('dashboard')->with('listings', $user->listings);

This isn't working and I have tried sortBy and nothing seems to work, I'm sure i'm doing/missing something easy here. thanks for any help as i'm learning!

$user_id = auth()->user()->id;
        
        $user = User::find($user_id);
        
        return view('dashboard')->with('listings', $user->listings)->orderBy('created_at', 'desc');
17 Oct
10 months ago

glasstream2000 left a reply on Ajax And Datatables

Here is the last few:

#47 C:\inetpub\wwwroot\ConsultantLogs\CLogs\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#48 C:\inetpub\wwwroot\ConsultantLogs\CLogs\vendor\laravel\framework\src\Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode.php(62): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#49 C:\inetpub\wwwroot\ConsultantLogs\CLogs\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(151): Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode->handle(Object(Illuminate\Http\Request), Object(Closure))
#50 C:\inetpub\wwwroot\ConsultantLogs\CLogs\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#51 C:\inetpub\wwwroot\ConsultantLogs\CLogs\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(104): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#52 C:\inetpub\wwwroot\ConsultantLogs\CLogs\vendor\laravel\framework\src\Illuminate\Foundation\Http\Kernel.php(151): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#53 C:\inetpub\wwwroot\ConsultantLogs\CLogs\vendor\laravel\framework\src\Illuminate\Foundation\Http\Kernel.php(116): Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter(Object(Illuminate\Http\Request))
#54 C:\inetpub\wwwroot\ConsultantLogs\CLogs\public\index.php(55): Illuminate\Foundation\Http\Kernel->handle(Object(Illuminate\Http\Request))
#55 {main}
"} 
16 Oct
10 months ago

glasstream2000 started a new conversation Ajax And Datatables

I'm getting a 500 (Internal Server Error) when trying to load the page. Maybe other eyes might see what I did wrong...

Controller

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Listing;
use Datatables;
use Yajra\DataTables\EloquentDataTable;

class AjaxdataController extends Controller
{
   function dataAdmin()
   {
       return view('ajaxdata');
   }
    
    function getData()
    {
        $listing = Listing::select('id', 'name');
        //$listing = new EloquentDataTable($query);
        
        return Datatables::of($listing)->make(true);
    }
}

ajaxdata blade file

<!DOCTYPE html>
<html>
<head>
    <title>Datatables Server Side Processing in Laravel</title>
    <meta name="csrf-token" content="{{ csrf_token() }}">
    
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" />
    <script src="https://cdn.datatables.net/1.10.12/js/jquery.dataTables.min.js"></script>
    <script src="https://cdn.datatables.net/1.10.12/js/dataTables.bootstrap.min.js"></script>       
    <link rel="stylesheet" href="https://cdn.datatables.net/1.10.12/css/dataTables.bootstrap.min.css" />
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
    
</head>
<body>

<div class="container">
    <br />
    <h3 align="center">Datatables Server Side Processing in Laravel</h3>
    <br />
    <table id="student_table" class="table table-bordered" style="width:100%">
        <thead>
            <tr>
                <th>First Name</th>
                <th>Last Name</th>
            </tr>
        </thead>
    </table>
</div>

<script type="text/javascript">
$(document).ready(function() {
    $.ajaxSetup({
  headers: {
    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
  }
});
    
     $('#student_table').DataTable({
        "processing": true,
        "serverSide": true,
        "ajax": "{{ route('ajaxdata.getData') }}",
        "columns":[
            { "data": "id" },
            { "data": "name" }
        ]
         
     });
    
});
    
</script>
</body>
</html>

Route

Route::get('ajaxdata', '[email protected]')->name('ajaxdata');
Route::get('ajaxdata/getData', '[email protected]')->name('ajaxdata.getData');

Listing Model

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Listing extends Model
{
    public function user()
    {
        return $this->belongsTo('App\User');
    }
}
26 Jul
1 year ago

glasstream2000 left a reply on Charts

That is from my first post, I totally reworked it to the post after that one after watching the video.

glasstream2000 left a reply on Charts

Here is whats return in chrome

data: {
        labels: [&quot;Sexual Harrasment&quot;,&quot;Sexual Misconduct&quot;,&quot;Mandated Reporting&quot;,&quot;Mandated Reporting&quot;,&quot;FERPA&quot;,&quot;FERPA&quot;,&quot;Awareness Walks&quot;],
        datasets: [{
            label: "My First dataset",
            backgroundColor: 'rgb(255, 99, 132)',
            borderColor: 'rgb(255, 99, 132)',
            data: [&quot;Sexual Harrasment&quot;,&quot;Sexual Misconduct&quot;,&quot;Mandated Reporting&quot;,&quot;Mandated Reporting&quot;,&quot;FERPA&quot;,&quot;FERPA&quot;,&quot;Awareness Walks&quot;],
        }]

Look normal? It is pulling the records from the DB