James_Moore

James_Moore

Member Since 2 Years Ago

Windsor

Software Developer at Flex-N-Gate Corp.

Experience Points 23,260
Experience Level 5

1,740 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 215
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.

08 Jul
2 weeks ago

James_Moore left a reply on Developing Composer Package Locally

2 seconds after posting tried and got what i wanted by running npm run dev inside vendor\protoqol\prequel if anyone has better or more "right" options let me know

James_Moore started a new conversation Developing Composer Package Locally

Running app on laravel homestead, and running all commands on local machine, because the changes I'm going to be making are all front end changes.

I recently began trying to contribute to an open source composer package. https://github.com/Protoqol/Prequel the closest I got was following this https://barryvanveen.nl/blog/44-package-development-run-a-package-from-a-local-directory , through lots of trail and error.

added this to laravel project

    "repositories":[
        {
            "type": "path",
            "url": "../prequel"
        }
    ],

ran composer require protoqol/prequel dev-master

no errors

  - Installing protoqol/prequel (dev-master): Junctioning from ../prequel
Writing lock file

so when making a change on a vue component in my local master branch in the prequel package repo the change appears in my test app vendor folder prequel vue component code

so i run $ php artisan vendor:publish --tag=config $ php artisan vendor:publish --tag=public

The front end change just changed some text, doesnt show up on the actual web site. I tried to run npm run dev, npm run watch, clear caches etc, the change still doesnt appear what am i missing.

30 May
1 month ago
29 May
1 month ago

James_Moore started a new conversation Vue Router, Nice Looking Routes And Passing Data

Currently i have a router link like such

<router-link to="/search/quotes"><li class="hover:bg-gray-200 px-6 py-3">{{tag.name}}</li></router-link>

it loads the following route

    mode: 'history',

    linkActiveClass: 'border-b-2 border-black font-medium text-black',

    routes: [

        {
            path: '/',
            component: Home
        },
        {
            path: '/search/quotes',
            component: QuoteSearchPage
        }
    ]
};

how would one do something like <router-link to="/search/quotes/{{tag.name}}">

  • {{tag.name}}
  • </router-link>

    and then the address bar would have say /search/quotes/red, then how do I access that last /red, I've look into passing data via vue js router but the address bar would always says something like%object and more random stuff that looks strange
    
    14 May
    2 months ago

    James_Moore left a reply on Laravel Policy Always Throwing Error

    I did use a view policy on the quotescontroller create method it uses Route::get('/quotes/create', '[email protected]'); in web.php

    James_Moore left a reply on Laravel Policy Always Throwing Error

    So I tested using a policy on a controller that uses a route in web.php and it worked.... my routes that I actually want the policies set on are api.php

    web.php

    Route::get('/quotes/create', '[email protected]');
    
    Route::get('/account', 'UserAccountController[email protected]');
    
    Route::get('/quotes-download', '[email protected]');
    
    Auth::routes();
    
    Route::get('/home', '[email protected]')->name('home');
    

    api.php

    <?php
    
    use Illuminate\Http\Request;
    
    /*
    
    Route::get('/quotes', '[email protected]');
    
    Route::post('/quotes','[email protected]');
    
    Route::delete('/quotes/{quote}', '[email protected]');
    
    Route::get('/quotes/{quote}/tags', '[email protected]');
    
    Route::post('/quotes/{quote}/tags/{tag}', '[email protected]');
    
    Route::delete('/quotes/{quote}/tags/{tag}', '[email protected]');
    
    Route::get('/tags/{tag}', '[email protected]');
    
    Route::post('/tags', '[email protected]');
    
    Route::delete('/tags/{tag}', '[email protected]');
    
    Route::post('/likes', '[email protected]');
    
    Route::patch('/account', '[email protected]');
    
    Route::patch('/account/quotes/{quote}', '[email protected]');
    
    Route::get('/random-quote', '[email protected]');
    
    
    13 May
    2 months ago

    James_Moore left a reply on Laravel Policy Always Throwing Error

    sadly still getting a 403 action unauthorized when logged in

    James_Moore left a reply on Laravel Policy Always Throwing Error

    I was under the impression that registering them in auth service provider was unesscary in 5.8,

    <?php
    
    namespace App\Policies;
    
    use App\User;
    use App\Quote;
    use Illuminate\Auth\Access\HandlesAuthorization;
    
    class QuotePolicy
    {
        use HandlesAuthorization;
    
        /**
         * Determine whether the user can view the quote.
         *
         * @param  \App\User  $user
         * @param  \App\Quote  $quote
         * @return mixed
         */
        public function view(User $user, Quote $quote)
        {
    
        }
    
        /**
         * Determine whether the user can create quotes.
         *
         * @param  \App\User  $user
         * @return mixed
         */
        public function create(User $user)
        {
            return $user;
        }
    
        /**
         * Determine whether the user can update the quote.
         *
         * @param  \App\User  $user
         * @param  \App\Quote  $quote
         * @return mixed
         */
        public function update(User $user, Quote $quote)
        {
            //
        }
    
        /**
         * Determine whether the user can delete the quote.
         *
         * @param  \App\User  $user
         * @param  \App\Quote  $quote
         * @return mixed
         */
        public function delete(User $user, Quote $quote)
        {
            //
        }
    
        /**
         * Determine whether the user can restore the quote.
         *
         * @param  \App\User  $user
         * @param  \App\Quote  $quote
         * @return mixed
         */
        public function restore(User $user, Quote $quote)
        {
            //
        }
    
        /**
         * Determine whether the user can permanently delete the quote.
         *
         * @param  \App\User  $user
         * @param  \App\Quote  $quote
         * @return mixed
         */
        public function forceDelete(User $user, Quote $quote)
        {
            //
        }
    }
    
    <?php
    
    namespace App\Providers;
    
    use App\Policies\QuotePolicy;
    use Illuminate\Support\Facades\Gate;
    use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
    
    class AuthServiceProvider extends ServiceProvider
    {
        /**
         * The policy mappings for the application.
         *
         * @var array
         */
        protected $policies = [
            // 'App\Model' => 'App\Policies\ModelPolicy',
            'App\Quote' => 'App\Policies\QuotePolicy',
        ];
    
        /**
         * Register any authentication / authorization services.
         *
         * @return void
         */
        public function boot()
        {
            $this->registerPolicies();
    
            //
        }
    }
    
    

    James_Moore started a new conversation Laravel Policy Always Throwing Error

    I created a policy with the artisan helper QuotePolicy in Policies folder and registered it with App\Quote Model.

    I added to create method whether or not user can create a quote. and call this from the begging of store method like so.

    public function store()
        {
            $this->authorize('create');
    
            $attributes = request()->validate([
                'author' => 'required',
                'quote' => 'required',
                'user_id' => 'required',
            ]);
    
            $quote = Quote::create($attributes);
    
            return response()->json([
                'quote_id' => $quote->id,
                'message' => 'quote was successfully created'
            ]);
        }
    

    It never makes it past the authorize method and i set a few break points and it never hits the QuotePolicy create method. It hits down the line Gate.php authorize method

    public function authorize($ability, $arguments = []) { $result = $this->raw($ability, $arguments); // this returns null // inside it $user = $this->resolveUser(); returns null ..... }

    which triggers the deny which throws the exception, i tested this as a logged in user

    25 Mar
    3 months ago

    James_Moore started a new conversation Heroku Not Loading App.css Or App.js

    currently im loading the following two assets like so

     <!-- Scripts -->
        <script src="{{ asset('js/app.js') }}" defer></script>
    
        <!-- Styles -->
        <link href="{{ secure_asset('css/app.css') }}" rel="stylesheet">
    

    but when push to a heroku production environment it doesn't load the css or js sadly and chrome console gives me a warning Mixed Content: The page at 'https://fast-earth-73631.herokuapp.com/' was loaded over HTTPS, but requested an insecure script 'http://fast-earth-73631.herokuapp.com/js/app.js'. This request has been blocked; the content must be served over HTTPS.

    There are a few of these for each asset i have in my layout, after logging in my css works. I tried to use secure_asset() but then that doesnt work locally and does the same thing my production environement does and thats not load the css. Anyone have any ideas. link to production https://fast-earth-73631.herokuapp.com/ user: [email protected] pw:tester

    23 Mar
    3 months ago

    James_Moore started a new conversation Markdown Mailable Button Component As Submit Button

    I cant seem to find anything online so I'm not entirely sure if its possible. But I'm currently sending a Laravel markdown email to a specified email. I want to put a html form in this email with the fields pre populated with the model fields passed into it. I like the mailable button component is there any way to make this button a submit button so that i can trigger a post request to my web app so the person can add this resource to there database.

    03 Feb
    5 months ago

    James_Moore started a new conversation PHP MYSQL Heroku

    My Connection class which just returns a new instance of PDO is throwing an error that i have an invalid name when trying to connect to a JAWSDB on heroku. Works great when im connected locally. I've tested the database im trying to connect to with the same credentials in my config.php, I get the error

    invalid data source name
    
    public static function make($config)
        {
            try {
                return new PDO(
                    $config['connection'] . ';dbname=' . $config['name'],
                    $config['username'],
                    $config['password'],
                    $config['options']
                );
            } catch (PDOException $e) {
                die($e->getMessage());
            }
        }
    
    29 Jan
    5 months ago

    James_Moore left a reply on Laravel Docker Setup

    At the moment this would be for a windows environment, we currently in a waiting period for whether or not we get macbook pros. I have a feeling well end up with new Windows machines though and using vagrant is just to much of a pain when doing any Vue things with our current setup. Thanks for reply's guys ! much appreciated.

    James_Moore started a new conversation Laravel Docker Setup

    Does anyone know of an up to date tutorial or a series that could get me up and running with a docker container. Coming from 0 docker knowledge, just wanna get a demo for my team to see if its worth switching from vagrant, hoping to potentially solve our problem of longnpm run dev times/npm run watch, considering we dont get them when using our personal development environments that dont use vagrant virtualization. Thanks !

    03 Jan
    6 months ago

    James_Moore started a new conversation Migration To Add Foreign Keys

    So recently we realized our database storage engine was MyISAM and not InnoDB, because of this none of our foreign keys seemed to be working / exist at all. So I'm trying to write a migration to add them back. But on my local development environment im getting this

      SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update
      a child row: a foreign key constraint fails (`table_name`.`#sql-3db_3a2`, 
    etc etc
    

    does anyone have any experience getting something like this #sql-3db_3a2 im not sure if somethings being cached or what. very strange, thanks again !

    07 Dec
    7 months ago

    James_Moore left a reply on Routes Creating

    https://laravel.com/docs/5.7/controllers#resource-controllers You want to follow Laravels standards and all the magic will happen for you.

    05 Dec
    7 months ago

    James_Moore started a new conversation Recursive Directory Traversal

    I'm just doing a problem off of the web developer roadmap, print a directory in JSON Format. But I'm stuck for the case when it comes up to a subdirectory, it should go into it and traverse it and print the files. but when II tried passing the path to thedirectory iterator it says that it doesnt see in the current working directory even though im doing ~/Pictures/Photo Booth Library or what ever. Any ideas ?

        function printDirectoryRecursivly(DirectoryIterator $iterator) {
        
        // Base Case 
            if(!$iterator->valid()) {
                echo "Not a valid Iterator ";
                return;
            }
        
        // Logic
            if($iterator->isDir()) {
                if(!$iterator->isDot()) { // not a dot file 
                    echo "Directory ! \n"; // yay its a directory 
            // create a new directory iterator for the directory 
            // then recursivly call the function passing that new directory iterator
                    $iterator = new DirectoryIterator(); // not sure what would work here);
                    return printDirectoryRecursivly($iterator);
                } else {
            // dot file just traverse over it 
                    $iterator->next();
                    printJsonRecursivly($iterator);
                }
            } else if($iterator->isFile()) {
                echo "File ! \n";
                $iterator->next();
                return printDirectoryRecursivly($iterator);
            }
        } 
    
    30 Nov
    7 months ago

    James_Moore started a new conversation PHP Console App To Windows.exe / OSX ... Dmg ?

    Is there a way to take a simple php console application and have it compiled down to a simple double click windows exe or osx executable that would open the command prompt or terminal and allow some body to use it, with out having to have them go into the command prompt or terminal and php index.php to run it.

    26 Nov
    7 months ago

    James_Moore started a new conversation Guzzle Response

    I'm trying to create a get request to url /r/programming.json , reddits api docs are confusing and seem to want you to do some OAUTH stuff that I don't understand yet. Anyways the following returns some json looking data in my browser, but im guessing its not actually json but a Guzzle stream ?? anyways ! how could I , or is there a completely better way to do the following i have already. How do I access the title of each children > data> child

    <?php
    
    require 'vendor/autoload.php';
    
    $client = new GuzzleHttp\Client();
    
    $response = $client->request('GET', 'https://www.reddit.com/r/programming.json', [
        'headers' => [
            'User-Agent' => 'testing/1.0'
        ]
    ]);
    
    $jsonResponse = $response->getBody();
    jsonFormatter($jsonResponse);
    
    function jsonFormatter($response)
    {
        echo "<pre>";
        echo $response;
        echo "</pre>";
    }
    

    The following returns

    "kind": "Listing",
    "data": {
    "modhash": "",
    "dist": 25,
    "children": [
    {
    "kind": "t3",
    "data": {
    "approved_at_utc": null,
    "subreddit": "programming",
    "selftext": "",
    "author_fullname": "t2_dhf7w",
    "saved": false,
    "mod_reason_title": null,
    "gilded": 0,
    "clicked": false,
    "title": "\"I don't know what to say.\"– Backdoor in popular event-stream NPM repo (github.com)", 
    
    25 Nov
    7 months ago

    James_Moore left a reply on How Do With Eloquent?

    Start by creating an eloquent model for the tagli table, so you can, use App\Tagli at the top of your controller, and then

    ->where('data_registrazione', $anno) // assuming this is a year || whereYear(...)
    ->groupBy(same as before)
    ->get('data_registrazione as giorni')->count(); ```
    
    resources: 
    https://laravel.com/docs/5.7/eloquent
    https://stackoverflow.com/questions/18621243/laravel-3-eloquent-how-to-select-column-as
    https://stackoverflow.com/questions/33534677/mysql-year-equivalent-in-laravel-query-builder
    https://stackoverflow.com/questions/20914650/how-do-you-wrap-laravel-eloquent-orm-query-scopes-in-parentheses-when-chaining
    
    23 Nov
    7 months ago

    James_Moore left a reply on Extending User Model

    @GLOBALS - Thank you recommending the package it seems awesome and simple to use ! Tightenco seem to really use the Laravel framework quite a bit.

    James_Moore started a new conversation Extending User Model

    I'm not sure how to go about this, but is it a good idea to extend the user model, or just give the user model a role id. If I want my users to be separated into different groups Organizations, Associations, Clubs, Admins or Directors, Officials, Coaches, Players. Each having the same functionality of having a login and all the other goodies that come with Laravel Auth scaffolding out of the box. Yet different privileges, profile page layouts etc.

    James_Moore left a reply on Loop Though Array

    you can even give this a watch , Symmetric Array Destructuring

    https://laracasts.com/series/whats-new-in-php-7-1/episodes/2

    deffs an option to make it nice and clean and have those two variables incase you want to pass them to something or what ever you want in the future.

    06 Nov
    8 months ago

    James_Moore started a new conversation Redirect To A View From Api

    After creating a model on the Controller in my API namespace, how do i redirect the user to another page. Currently, under Network, response, its just returning the html code to the view. So its hitting the route and returning the view, but how do i actually redirect and view the VIEW lol return redirect(url('/cms/requisitioners/' . '1' . '/edit')); the ones hardcoded for current testing purposes

    02 Oct
    9 months ago

    James_Moore left a reply on FCC Responsive Web Tribute Page

    @wilburpowery Yup thanks ! Just threw it in a code pen so i could share it easier with forums. Thanks again !

    James_Moore started a new conversation FCC Responsive Web Tribute Page

    https://codepen.io/James_M0025/pen/WaQrLr First project for free code camp Responsive web just wondering if anyone has any recommendations for the html and CSS. I'd post on fcc forum but its down.

    13 Jul
    1 year ago

    James_Moore started a new conversation XDebug Laravel Valet, OSX

    I've been searching and searching, I cant seem to find a straight answer to get XDebugg working for laravel development with Valet on the OSX operating system. Anyone have this working ??

    10 Jul
    1 year ago

    James_Moore started a new conversation Using Oh-my-zsh Homestead

    I just installed a fresh copy of homestead to use with Vagrant. I noticed when typing ls -la that it comes with .zsh I use this on my macbook and was just wondering how to change from bash to zsh on homestead mainly because I like using https://github.com/denysdovhan/spaceship-prompt . I like it for the git things it shows, if you've made changes / what branch your on etc, Thanks !

    19 Jun
    1 year ago

    James_Moore started a new conversation Beginner Friendly Open Source Projects

    Anyone know of any first timer / beginner friendly projects going on being done with vue / laravel. My own personal project keeps me busy but I like the idea of helping out someone else to.

    22 May
    1 year ago

    James_Moore started a new conversation Laracon Tickets

    Hey has anyone ever had any luck finding tickets for Laracon after they've been sold out ? Whether it be Ebay or even just people who cant go posting there tickets for sale in here... Just wondering cause me and a Co Worker would like to go and we missed out on ticket sales.

    17 May
    1 year ago

    James_Moore left a reply on I Don't Like Change

    @m-rk thought it was ok to post in general. I may, of thought wrong, and it does work @jlrdw ! thank you for your condolences @martinbean <3

    James_Moore started a new conversation I Don't Like Change

    GITHUB Repositories thingy www.github.com IS ON THE LEFT SIDE.

    James_Moore left a reply on Refactoring Account Settings Page Front/backend

    @Devmaurice dude thanks for the feed back, I'm gonna leave this open still for more feedback incase anyone actually looks at the repository and sees other things that I can add to my tasks.

    James_Moore left a reply on How To Parse This JSON

    @bensholdice @m-rk Thanks for getting back to me guys I ended up just tossing this one in the trash going to circle back to my issue later haha, Thanks again !

    16 May
    1 year ago

    James_Moore started a new conversation Refactoring Account Settings Page Front/backend

    Currently I'm making a page that allows a user to update certain things on there profile, the controllers starting to look quite large, and I'm pretty sure this is most definitely not the best way to go about this. Figured I'd use this as some motivation to get back into my Open source project. Repository link , please heck even create an issue if you want ! Open source newbie haha ! https://github.com/James-N-M/box-off <3

    Front end Account settings page

    @extends('layouts.app')
    
    @section('content')
    <main class="col-md-8 offset-md-2 my-3 p-3">
            <div class="card">
                <div class="card-header">
                    <h5 class="card-text text-capitalize">Your account</h5>
                </div>
                <div class="card-body">
    
                   <form action="/settings" method="POST" enctype="multipart/form-data">
                        {{ csrf_field() }}
                        
                        <div class="form-row">
                            <div class="form-group col-md-6">
                                <label for="name">Name</label>
                                <input type="text" class="form-control" id="name" name="name" value="{{ old('name', Auth::user()->name) }}" readonly>
                            </div>
                            <div class="form-group col-md-6">
                                <label for="email">E-mail</label>
                                <input type="email" class="form-control" id="email" name="email" value="{{ old('email', Auth::user()->email) }}" readonly>
                            </div>
                            <div class="form-group col-md-6">
                                <label for="password">New Password: </label>
                                <input type="password" class="form-control" id="password" name="password" >      
                            </div>
                            <div class="form-group col-md-6">
                                <label for="password_confirmation">Password Confirmation: </label>
                                <input type="password" class="form-control" id="password_confirmation" name="password_confirmation" >      
                            </div>
                            <div class="form-group col-md-6">
                                <label for="avatar">Avatar</label>
                                <input id="avatar" type="file" class="form-control" name="avatar">
                            </div>
                            <div class="form-group col-md-6">
                                <label for="about">Something Me</label>
                                <input id="hi" type="textfield" class="form-control" name="hey">
                            </div>
                            <div class="form-group col-md-12">
                                <label for="about">About Me <i>Char Max: 230</i></label>
                                <textarea class="form-control" id="about" name="about" rows="3" maxlength="230"></textarea>
                            </div>
                            <div class="form-group col-md-6">
                                <label for="status">Status</label>
                                <select class="form-control" id="status" name="status">
                                    <option></option>
                                    <option value="2">Boxer</option>
                                    <option value="3">Coach</option>
                                    <option value="4">Doctor</option>
                                    <option value="5">Referee</option>
                                </select>
                            </div>
                            <div class="form-group col-md-3">
                                <label for="wins">Wins</label>
                                <input class="form-control"type="number" name="wins">
                            </div>
                            <div class="form-group col-md-3">
                                <label for="loss">Loses</label>
                                <input class="form-control"type="number" name="loses">
                            </div>
                            <div class="form-group col-md-6">
                                <label for="location">Location</label>
                                <select class="form-control" id="location" name="location">
                                    <option value=""></option>  
                                    @foreach($locations as $location)
                                        <option value="{{$location->id}}">{{$location->city}}</option>
                                    @endforeach
                                </select>
                            </div>
                            <div class="form-group col-md-6">
                                <label for="club">Club</label>
                                <select class="form-control" id="club" name="club">
                                    <option value=""></option>
                                    @foreach($clubs as $club)
                                        <option value="{{$club->id}}">{{$club->name}}</option>
                                    @endforeach
                                </select>
                            </div>
                        </div>
    
                        <hr>
                        <button class="btn btn-sm btn-danger" type="submit"><strong>UPDATE</strong></button>
                        @include('partials.errors')
                    </form>
    
                </div>
            </div>
        </main>
    @endsection
    

    Back end account controller

    <?php
    
    namespace App\Http\Controllers\Users;
    
    use Auth; 
    use Image; 
    use App\About; 
    use App\Location;
    use App\Club; 
    
    use Illuminate\Http\Request;
    use App\Http\Controllers\Controller;
    
    class AccountController extends Controller
    {
        public function show()
        {
            $clubs = Club::all();
            $locations = Location::all(); 
            return view('settings.account', compact('clubs', 'locations'));
        }
    
        public function update(Request $request)
        {
            if($request->get('password'))
            {
                $this->validate(request(), [
                    'password' => 'confirmed|min:6'
                ]);
                Auth::user()->password = bcrypt($request->input('password'));
                Auth::user()->save(); 
            }
    
            if($request->get('about')){
                $this->validate(request(), [
                    'about' => 'min:10'
                ]);
                if(!Auth::user()->about){
                    return About::create([
                        'id' => Auth::user()->id,
                         'body' => $request->get('about'),
                    ]);
                }
                else{
                    $about = Auth::user()->about;
                    $about->body = $request->get('about');
                    $about->save(); 
                }
            }
    
            if($request->get('status')){
                Auth::user()->status_id = $request->get('status');
                Auth::user()->save(); 
            }
    
            if($request->get('location')){
                Auth::user()->location_id = $request->get('location');
                Auth::user()->save(); 
            }
    
            if($request->get('club')){
                Auth::user()->club_id = $request->get('club');
                Auth::user()->save(); 
            }
    
            if($request->get('wins')){
                Auth::user()->record->wins = $request->get('wins');
                Auth::user()->save(); 
            }
    
            if($request->get('loses')){
                Auth::user()->record->loses = $request->get('wins');
                Auth::user()->save(); 
            }
            
            if($request->hasFile('avatar')){
                $avatar = $request->file('avatar'); 
                $filename = time() . '.' . $avatar->getClientOriginalExtension(); 
                Image::make($avatar)->resize(300,300)->save( public_path('/uploads/avatars/' . $filename));
    
                Auth::user()->avatar = $filename; 
                Auth::user()->save(); 
            }
    
            flash('Great Job Profile Successfully Updated'); 
            return redirect()->back(); 
        }
    }
    
    08 May
    1 year ago

    James_Moore started a new conversation How To Parse This JSON

    {
    "Contamination": {
    "October": [
    {
    "defect": "Contamination",
    "month": "October",
    "count": 1
    }
    ]
    },
    "Cosmetic": {
    "August": [
    {
    "defect": "Cosmetic",
    "month": "August",
    "count": 3
    }
    ],
    "December": [
    {
    "defect": "Cosmetic",
    "month": "December",
    "count": 1
    }
    ],
    "January": [
    {
    "defect": "Cosmetic",
    "month": "January",
    "count": 5
    }
    ],
    "July": [
    

    This is a snip from a json return im getting, I cant seem to parse it properly to access the count of every month.

    right now this

    return $result["Cosmetic"]["August"];
    

    This returns from the Controller to the api endpoint. How do i parse it on the front end ... to show just count

    [
    {
    "defect": "Cosmetic",
    "month": "August",
    "count": 3
    }
    ]
    

    how do i access the count now

    07 May
    1 year ago

    James_Moore started a new conversation Group By

    public function qualityClaimsCountByMonth($id)
        {
            $qualityClaims = QualityClaim::SelectRaw(
                'defect,
                MONTHNAME(plm.quality_claims.created_on) month,
                COUNT(*) as count'
            )
            ->join('plm.defects', 'plm.quality_claims.defect_id', '=', 'plm.defects.id')
            ->where('plm.quality_claims.created_on', '>=', Carbon::now()->subMonth(12))
            ->where('plm.quality_claims.organization_id', '=', $id)
            ->groupBy('defect')->groupBy('month')
            ->get();
            return $qualityClaims;
        }
    

    this currently returns

    [
    {
    "defect": "Cosmetic",
    "month": "May",
    "count": 1
    },
    {
    "defect": "Packaging",
    "month": "May",
    "count": 1
    },
    {
    "defect": "Cosmetic",
    "month": "May",
    "count": 1
    },
    {
    "defect": "Cosmetic",
    "month": "May",
    "count": 1
    },
    {
    "defect": "Labeling/Mixed Parts",
    "month": "May",
    "count": 1
    },
    {...
    

    how do i make it look more like

    [
        {
            "defect":"Costmetic"
            {
                "month": "June",
                "count": (all totaled up with june)
            },
            {
                "month": "July",
                "count": (all totaled up with june)
            }, .. all the way till no more Cosmetic
        }
        {
            "defect":Something else
            {
                "month": "May",
                "count": (all totaled up with record may)
            },
            {
                "month": "June",
                "count": (all totaled up with june)
            }, .. all the way till no more Cosmetic
        }
    ..]
    
    
    01 May
    1 year ago

    James_Moore left a reply on Profile Page Content Not Yet Set

    <?php
    
    namespace App\Http\Controllers;
    
    use Illuminate\Http\Request;
    use Validator; 
    use App\User; 
    
    class ProfileController extends Controller
    {
        public function show($id){
            $user = User::find($id); 
    
            $rules = [
                'name' => 'min:20',
            ]; 
    
            $messages = [
                'min' => 'Please create an about me', 
            ];
    
            $validator = Validator::make($user->about->toArray(), $rules, $messages); 
            
            return $validator->errors(); // here it just returns a empty array 
    
            return view('profile.show', compact('user', 'validator'));
        }
    }
    
    

    Lol last attempt before I just hack it up, but the following will just return an empty array, I tried doing something like $user->toArray() and checking for name to have like 20 characters and it will return the error "create" an about me. I tested to make sure that $user->about->toArray() returns a about me object, and it does for that user the body being empty "" should return please create about me. but returns a [] empty array to the page. when testing... @martinbean

    James_Moore left a reply on Profile Page Content Not Yet Set

    @martinbean Ill give it a go thanks man

    30 Apr
    1 year ago

    James_Moore left a reply on Profile Page Content Not Yet Set

    Ive tried a couple of the things you listed and messed and dug a bit still not workin,

    James_Moore left a reply on Profile Page Content Not Yet Set

    @martinbean I've tried your couple examples. I think im missing something or some includes perhaps ?? It doesnt seem to pass an error back to the view when I write this stuff in the controller. And when I write Validator::make I get an error

    <?php
    
    namespace App\Http\Controllers;
    
    use Illuminate\Http\Request;
    use Illuminate\Validation\Validator; 
    use App\User; 
    
    class ProfileController extends Controller
    {
        public function show($id){
            $user = User::find($id); 
    
            $validator = Validator::make($user->about->toArray(),[
                'body' => 'min:10',
            ]); 
    
            return view('profile.show', compact('user'));
        }
    }
    

    Trying to get a error to appear on the page "no about me set" or something I do have a empty about me instance in the database for the user id, Id rather it be that the about me doesnt even exist yet, then have it do the error so they go to settings and make one, then it gets saved to the database.

    27 Apr
    1 year ago

    James_Moore left a reply on Profile Page Content Not Yet Set

    Ok I definitely see what your saying, I think what I'm after is a tad different though. I want them to be able to go on the profile page,. wish I could draw a picture but kinda like facebook, eg. Right now theres a section for featured pictures I havnt added yet so it just says "add featured photos", I want the same thing. Thanks for the idea though @martinbean If I cant figure out Its definitely my fall back

    26 Apr
    1 year ago

    James_Moore started a new conversation Profile Page Content Not Yet Sent

    So, I'm building a little social network-ish kind of web app, I have a user login by registers a username and password .... but theres a tab on the nav bar for profile, the profile page displays there about me etc etc, but i had to create this about me in the database, how can i make it so when a new user registers when they click on the profile tab that it shows something like "Hey your about me isnt set yet go to settings to do so" "hey your age isnt set yet go to settings to do so", My settings page would then alow the user the enter in the remaining credentials they need to do more with the site etc.

    25 Apr
    1 year ago

    James_Moore left a reply on Ordering From 2017 - 2018 Months

    @ejdelmonico I ended up with this, I think it needs some refactoring but,,,, for now seems legit

            $qualityClaims = QualityClaim::select(
                DB::raw('count(MONTHNAME(created_on)) as `count`'),
                DB::raw('MONTHNAME(created_on) month'),
                DB::raw('MONTH(created_on) number'),
                DB::raw('YEAR(created_on) year'))
                ->where('created_on', '>=', Carbon::now()->subMonth(12))
                ->where('plm.quality_claims.organization_id', '=', $id)
                ->groupBy('year','month','number')
                ->orderBy('year')
                ->orderBy('number')
                ->get();
    
            return $qualityClaims;
    
    [
    {
    "count": 4,
    "month": "April",
    "number": 4,
    "year": 2017
    },
    {
    "count": 11,
    "month": "May",
    "number": 5,
    "year": 2017
    },
    {
    "count": 29,
    "month": "June",
    "number": 6,
    "year": 2017
    },
    {
    "count": 17,
    "month": "July",
    "number": 7,
    "year": 2017
    },
    {
    "count": 17,
    "month": "August",
    "number": 8,
    "year": 2017
    },
    {
    "count": 8,
    "month": "September",
    "number": 9,
    "year": 2017
    },
    {
    "count": 20,
    "month": "October",
    "number": 10,
    "year": 2017
    },
    {
    "count": 16,
    "month": "November",
    "number": 11,
    "year": 2017
    },
    {
    "count": 7,
    "month": "December",
    "number": 12,
    "year": 2017
    },
    {
    "count": 18,
    "month": "January",
    "number": 1,
    "year": 2018
    },
    {
    "count": 7,
    "month": "February",
    "number": 2,
    "year": 2018
    },
    {
    "count": 4,
    "month": "March",
    "number": 3,
    "year": 2018
    }
    ]
    

    James_Moore started a new conversation Ordering From 2017 - 2018 Months

    $qualityClaims = QualityClaim::select( DB::raw('count(MONTHNAME(created_on)) as `count`'), DB::raw('MONTHNAME(created_on) month'))
                ->where('created_on', '>=', Carbon::now()->subMonth(12))
                ->where('plm.quality_claims.organization_id', '=', $id)
                ->groupBy('month')
                ->get();
            return $qualityClaims;
    

    The return is so

    [
    {
    "count": 4,
    "month": "April"
    },
    {
    "count": 17,
    "month": "August"
    },
    {
    "count": 7,
    "month": "December"
    },
    {
    "count": 7,
    "month": "February"
    },
    {
    "count": 18,
    "month": "January"
    },
    {
    "count": 17,
    "month": "July"
    },
    {
    "count": 29,
    "month": "June"
    },
    {
    "count": 4,
    "month": "March"
    },
    {
    "count": 11,
    "month": "May"
    },
    {
    "count": 16,
    "month": "November"
    },
    {
    "count": 20,
    "month": "October"
    },
    {
    "count": 8,
    "month": "September"
    }
    ]
    

    I need this to return records from 2017 to 2018 but everythings just completely out of order, like it should from last year to this year months in order.

    23 Apr
    1 year ago

    James_Moore left a reply on User Model Creation Foreign Keys

    @Cronix Thanks ! Its just my user model was getting quite large with the following properties, location , club, record, avatar, and all the others.

    James_Moore started a new conversation User Model Creation Foreign Keys

    Just wondering, is it normal to include many foreign keys in your user model ?? to link to things that have to do with the user. For instance if a user has a win lose record, would i include a record_id in the user model. Or just make a record model and have each user that enters there record update the table with a $id, $win, $lose, $user_id foreign key ? Refactoring an old project that where a-lot was rushed to meet a school deadline.

    20 Apr
    1 year ago

    James_Moore left a reply on Portfolio Friendly Project

    I watched them all last summer I have to watch them over again, all I can say is definitely take your time with php practitioner ! jamesm0025@gmail.com email me and I'll send you my assignment pdfs from my web class this past semester/(slides), the assignments were simple and really made this php stuff actually work. Tutorials are garbage if you don't apply them 150 % literally useless. James-N-M is my Github facebooks james moore get at me and well learn again together I start next Monday at work again. @wildside

    James_Moore left a reply on Portfolio Friendly Project

    I came on this board today with the same question in mind, I been given instructions to go back over php practitioner its been about a year since last summer internship (didn't do much last summer) looking for some kind of guide on what side projects to complete to use what I've learned from, in the following order, I was told to watch these videos then actually do some practical as I go by my mentor but that was it.

    tldr; So I'm looking for simple project ideas as well <3

    1. php practioner
    2. OOP
    3. laravel scratch 5.4