midwestdev

midwestdev

Member Since 5 Years Ago

Experience Points 14,760
Experience Level 3

240 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 139
Lessons
Completed
Best Reply Awards 2
Best Reply
Awards
  • Start Your Engines Achievement

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • First Thousand Achievement

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • One Year Member Achievement

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • Two Year Member Achievement

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • Three Year Member Achievement

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • Four Year Member Achievement

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • Five Year Member Achievement

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • School In Session Achievement

    School In Session

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

  • Welcome To The Community Achievement

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • Full Time Learner Achievement

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • Pay It Forward Achievement

    Pay It Forward

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

  • Subscriber Achievement

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • Lifer Achievement

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • Laracasts Evangelist Achievement

    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 Achievement

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • Laracasts Veteran Achievement

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • Ten Thousand Strong Achievement

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • Laracasts Master Achievement

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • Laracasts Tutor Achievement

    Laracasts Tutor

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

  • Laracasts Sensei Achievement

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • Top 50 Achievement

    Top 50

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

26 Jun
1 day ago

midwestdev left a reply on Laravel In Ubuntu

The A in LAMPP is Apache

Fresh server

sudo apt update && sudo apt upgrade

sudo apt install php7.2-common php7.2-cli php7.2-gd php7.2-mysql php7.2-curl php7.2-intl php7.2-mbstring php7.2-bcmath php7.2-imap php7.2-xml php7.2-zip

curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer

composer create-project --prefer-dist laravel/laravel my_app

@php artisan key:generate --ansi

cd ~/my_app php artisan serve

28 May
4 weeks ago

midwestdev left a reply on Merge Two Arrays Based On Partial String In Key Value

Thank you, with a small modification I was able to get it output exactly how I wanted

public function handle($data1, $data2) {
    

    $grp1 = $data1->groupBy(function ($i) {
        $matches = [];
        preg_match('/\d{6}/', $i['CIRCUIT'], $matches);
        return $matches[0];
    });

    $grp2 = $data2->groupBy(function ($i) {
        $matches = [];
        preg_match('/\d{6}/', $i['CAT_DESCRIPTION'], $matches);
    
        return $matches[0];
    });

    $grp = $grp1->map(function ($i, $k) use ($grp2) {
        $cd = data_get($grp2, $k . '.0.CAT_DESCRIPTION');
        if (!!$cd) $i = array_merge($i->first(), ['CAT_DESCRIPTION' => $cd], ['IN_BOTH'=>'TRUE']);
        
        if (!$cd) $i = array_merge($i->first(), ['CAT_DESCRIPTION' => ''],['IN_BOTH' => 'FALSE']);
        return $i;
    });

    return $grp;
}
23 May
1 month ago

midwestdev left a reply on Merge Two Arrays Based On Partial String In Key Value

This is what I came up with, and it's somewhat close

    $data = $queryClass->builder($query);
    
    $array = json_decode(json_encode($data), true);

    $data2 =  $queryClass->builder($query2);
    
    $array2 = json_decode(json_encode($data2), true);

    $pattern = '/(?:\d{4,7})/';

    $result = Array();
    foreach ($array as $key_1 => &$value_1) {
        // if($value['name'])
        foreach ($array2 as $key_1 => $value_2) {
            if((preg_match($pattern, $value_1['CIRCUIT'])) ==  preg_match($pattern, $value_2['CAT_DESCRIPTION'])) {
                $result[] = array_merge($value_1,$value_2);
            }
        }

    }

    dd($result);

but it's taking every array2 and appending it to every single array1 and created an array of 65000 in length

midwestdev started a new conversation Merge Two Arrays Based On Partial String In Key Value

I have got two arrays that I need to merge, the only way to merge the data is by one tiny partial piece of information in CAT_DESCRIPTION and DESCRIPTION a 6 digit number. I can use a regular expression to /[0-9]{6}/ but I am not sure how to

    $results = $data->map(function($a) use ($data2){
        $description = $a->DESCRIPTION;
        $cat_description = $data2->CAT_DESCRIPTION;



        
    });
14 May
1 month ago

midwestdev left a reply on Laracasts Search

@JLRDW - I have no idea why people keep trying to include their own search, just embed google search.

midwestdev left a reply on Undefined Property: StdClass: (error Happens, Though One Result Is Dumped)

I figured it out, I am an idiot. There is more than one result and one of the results doesn't have CONTACT_INFO

midwestdev left a reply on Undefined Property: StdClass: (error Happens, Though One Result Is Dumped)

Also if anyone has suggestions on how to improve my coding, I will take that advice as well.

midwestdev left a reply on Undefined Property: StdClass: (error Happens, Though One Result Is Dumped)

Just fair warning this is some hideous code and most of it should be in a model instead of the controller.


function SearchByName($name) 
    {
        

        $queryClass = new Connect();
        $query = "select scm.SA_CUST_ID_NBR from SA_CUST_MSTR scm where (scm.SA_DISPLAY_NM LIKE '%$name' or scm.SA_LOOKUP_NM_30 like '%$name') and SA_COMPANY_NBR = 15518";
        $data = $queryClass->builder($query);
        

        $query2 = "select SCM.SA_CUST_ID_NBR from SA_CONTACT_METHOD SCM where SCM.SA_COMPANY_NBR = 15518 and SA_CONTACT_METHOD_TYPE in ('PHONE','WORK','HOME','MOBILE') and SCM.SA_SEQ_NBR = 1 and SCM.SA_CONTACT_INFO like '%$name'";
        $data2 =  $queryClass->builder($query2);

        
        
        $results = array_unique(array_merge($data, $data2), SORT_REGULAR);

        if(count($results) < 1) {
            return view('customertools.noresults');
        }

        $customer_numbers = '';

        foreach($results as $result) {
            $customer_numbers .= $result->SA_CUST_ID_NBR .',';
        }
        $customer_numbers = substr($customer_numbers, 0, -1);
        $data = $this::find_customers($customer_numbers);
        return view('customertools.search', ['data'=>$data]);
        
    }

    function find_customers($ids) 
    {
        $queryClass = new Connect();

    
        $query = "SELECT DISTINCT acct_info.CS_MEM_NBR as member_number, acct_info.SA_CUST_ID_NBR as customer_id, acct_info.SA_DISPLAY_NM as name, acct_info.CUST_DELIVERY_ADDR as address, acct_info.CUST_CITY as city, acct_info.CUST_ST as state, acct_info.CUST_ZIP_5 as zip_5, acct_info.CUST_ZIP_4 as zip_4 
                  FROM RV_SI_ACCT_INFO as acct_info  WHERE acct_info.SA_COMPANY_NBR = 15518 AND acct_info.SA_CUST_ID_NBR in ($ids)";
        
        $data = $queryClass->builder($query);
        
        // add preferred to array 
        $data = array_map(function($obj)
        {
            $obj->PREFERRED = 'FALSE';
            return $obj;
        }, $data);
        // find preferred customers
        $query = "select SA_CUST_ID_NBR from RV_SI_OPN_FLD_CUST where SA_COMPANY_NBR = 15518  and SA_CUST_ID_NBR in ($ids) and SY_TBL_NAME = 'SaCustMstr'
        and SY_OPEN_LBL = 'Preferred Customer' and SY_VALUE = 'Y'";
        
        $preferred = $queryClass->builder($query);
        
        
         
        # If customer is preferred change preferred to true
                
        foreach($preferred as $item)
        {
            $isPreferred = $item->SA_CUST_ID_NBR;
            foreach($data as $datum) 
            {
                if($datum->CUSTOMER_ID == $item->SA_CUST_ID_NBR)
                {
                    $datum->PREFERRED = 'TRUE';
                }
            }
        }

midwestdev left a reply on Undefined Property: StdClass: (error Happens, Though One Result Is Dumped)

{#859 ▼
  +"MEMBER_NUMBER": "0"
  +"CUSTOMER_ID": "3463"
  +"NAME": "Fake Company"
  +"ADDRESS": "123 Sesame Street"
  +"CITY": "City Name"
  +"STATE": "IL"
  +"ZIP_5": "62305"
  +"ZIP_4": "000"
  +"PREFERRED": "FALSE"
  +"CONTACT_INFO": array:1 [▼
    0 => array:2 [▼
      "INFO" => "55512121212"
      "TYPE" => "phone"
    ]
  ]
  +"SPECIAL_CONTACT": array:3 [▶]
  +"AGREEMENT": array:11 [▶]
}

I get this, which looks good...

midwestdev started a new conversation Undefined Property: StdClass: (error Happens, Though One Result Is Dumped)

Basic script loops through array, works perfect when more than one result. But if there is one result, it gives me Undefined property: stdClass:

         @foreach($datum->CONTACT_INFO as $contact_data)
                 <li type="{{ $contact_data['TYPE'] }}">{{ $contact_data['INFO'] }}</li>
             @endforeach

dd returns

array:1 [▼
  0 => array:2 [▼
    "INFO" => "2172244359"
    "TYPE" => "phone"
  ]
]

var_dump returns

Undefined property: stdClass::$CONTACT_INFO

What am I missing here?

08 Mar
3 months ago

midwestdev started a new conversation Ruby On Rails To Laravel Helper Class And How Do I Do This?

I am in the process of moving an existing intranet site from Rails to Laravel. In the Rails app I have a section that generates a page with a slider that shows 35 different charts.

I have a helper view that contains the div for the slider, sample below

        <!-- SLIDE NUMBER 1 @top_signups && @top_interests -->
        <div class="slide" style="height:80vh;">
            <h1>Top Signups and Interest Areas</h1>
            <div style="display:flex;align-items:center;justify-content: space-around;">
                
                <%= graph 'top-signups', 'horizontalBar',  @chkpt_top_signups, "Top Sign Ups", "half-page", "false", "true" %>
                <%= graph 'top-interests', 'bar',  @chkpt_top_interests, "Top 5 Interest Areas (Last 45 days)", "half-page", "false", "true" %>
            </div>
        </div>
        <!-- SLIDE NUMBER 1 @top_signups && @top_interests -->
        <div class="slide" style="height:80vh;">
            <h1>Sales by Package</h1>
            <div style="display:flex;align-items:center;justify-content: space-around;">
                <%= graph 'sales-by-package', 'bar',  @chkpt_sales_by_package, "Sales By Package", "full-page", "false", "true" %>
            </div>
        </div>
        <!-- SLIDE NUMBER 2 @sales_this_year && @installs_this_year -->
        <div class="slide" style="height:80vh;">
            <h1>Sales &amp; Installs This Year</h1>
            <div style="display:flex;align-items:center;justify-content: space-around;">
                <%= graph 'sales-this-year', 'bar',  @chkpt_sales_this_year, "Sales this Year", "half-page", "false", "true" %>
                <%= graph 'installs-this-year', 'bar',  @chkpt_installs_this_year, "Installs this year", "half-page", "false", "true" %>
            </div>
        </div>

This helper is called from the main layout file Inside of this template, I call another function called graph which generates the graph with the values I have above. I am just wondering if there is are helper functions that will allow me to do something similar in laravel?

midwestdev left a reply on StreamDownload Not Forcing Download In Browser

return Response::stream($callback, 200, $headers)->send(); // this is the solution

07 Mar
3 months ago

midwestdev left a reply on StreamDownload Not Forcing Download In Browser

changed response to stream

now it dumps the csv data to the browser without creating a file

return Response::stream($callback, 200, $headers)->sendContent();

midwestdev started a new conversation StreamDownload Not Forcing Download In Browser

Working on a simple script to take some data from an odbc connection and then converting it to a csv. I wrote the following


    public function Export($data) {
        $headers = array(
            "Content-type" => "text/csv",
            "Content-Disposition" => "attachment; filename=summary.csv",
            "Pragma" => "no-cache",
            "Cache-Control" => "must-revalidate, post-check=0, pre-check=0",
            "Expires" => "0"
        );
        $columns = array('Period', 'Revenue Area', 'Subs');
       
        $callback = function() use ($data, $columns)
        {
            $file = fopen('php://output', 'w');
            fputcsv($file, $columns);
            
            foreach($data as $items) {
                fputcsv($file, array($items->PERIOD, $items->REVENUE_AREA, $items->SUBS));
                
            }
            fclose($file);
        };
        return response()->streamDownload($callback, 'prefix-' . date('d-m-Y-H:i:s').'.csv', $headers);
        
    }

The data is there, I can dump it. There are no errors , but the browser is just not forcing the download. Any helps or suggestions would be greatly appreciated.

06 Mar
3 months ago

midwestdev started a new conversation Moving From Ruby On Rails To Laravel

I am in the middle of moving a project from rails to Laravel and I am wondering if there are any tutorials anyone knows about from moving from Ruby hashes to laravel collections.

05 Mar
3 months ago

midwestdev left a reply on Forge Envoyer Deployment Issue 404 Not Found

turns out following instructions that point to /public is completely f'ing wrong.

/current/public

midwestdev left a reply on Forge Envoyer Deployment Issue 404 Not Found

Added ssl cert, no longer returns 404, now it just return php_info() info. That is not part of my app.

midwestdev left a reply on Forge Envoyer Deployment Issue 404 Not Found

Solved the problem, forgot to add an ssl cert. All Good in the hood.

midwestdev started a new conversation Forge Envoyer Deployment Issue 404 Not Found

I am using Forge and Envoyer to deploy my laravel app. I keep getting a 404 Not Found when I type in the IP Address. This site can’t be reached yourdomain.app unexpectedly closed the connection when I type in the url. Everything was successfully deployed, database, files, what not. Nothing in the error logs.

01 Mar
3 months ago

midwestdev left a reply on Uploading File From One Server To Another

What have you attempted so far?

21 Feb
4 months ago

midwestdev left a reply on 419 Error When Submitting Form In Production - Sorry, Your Session Has Expired. Please Refresh And Try Again

Yep, that is what he means. Just make sure it is temporary while you do the rest of the development. Just make sure you note to come back to it later. Other things you can try, include of course changing environments, browsers, and whatever else you need to isolate the issue.

midwestdev left a reply on NGINX Configuration File For Non-Laravel Projects

Centos? Ubuntu? What is your server configuration

The default configuration is located /etc/nginx/conf.d/default.conf on centos

There are also configuration blocks

Make sure to study some tutorials for setting up nginx and configuring it before you start messing around, it will help you out in the long run

midwestdev left a reply on How Do You Guys Create Admin Panel In Laravel

Kind of depends on your requirements for the application. I use Voyager for most applications, but my current project is more custom and I can't go that route. There is also NOVA which is a paid admin from Taylor, I have not used it yet, so I can't give advice.

If you roll your own admin, it like writing any application, you will have model views controllers and etc.

Ultimately what you do depends on your use case. What are you doing? Who will have access to it, and will what you use or create still work for your needs 3 years from now.

midwestdev left a reply on Laravel-oci8

this seems to answer your question

https://github.com/yajra/laravel-oci8/issues/429

19 Feb
4 months ago

midwestdev left a reply on Reference Two Columns On Another Table Or Reference The Id?

Turns out what I need to do is create a many to many relationship which required creating a pivot table. A one to one or many to one relationship would have ended up with a formula owning the ingredient. Though surprised nobody on here knew that. Or maybe my writing is just hard to follow, I don't know.

18 Feb
4 months ago

midwestdev left a reply on Reference Two Columns On Another Table Or Reference The Id?

@KVITHALANI - Basically there is a parent (formula) a parent can't have multiple formula items, the formula items can have a single ingredient. The parent hasMany formulaItems and formulaItems can have 1 to 1 relationship with ingredients. This is so that in the future if we edit the ingredient any formula we create will be automatically updated with the new ingredient. Otherwise I would just create Ingredient and IngredientName in the formula_items table.

I hope that makes sense. Business logic isn't my strongest suit.

17 Feb
4 months ago

midwestdev started a new conversation Reference Two Columns On Another Table Or Reference The Id?

I have a parent called formula_items that will have many ingredient, and it has a parent that will have many formulas I don't want to have to add ingredients each time so I want to include a dropdown that list the ingredients and when you create the formula item it will reference the ingredients. (doing it this way in case later the ingredients change in some fashion, it will just cascade down to all the formulas and formula items.

I am probably over complicating in my head a simple one to one relationship as I haven't slept in 20 hours, but this is my UP migration.

public function up()
{
    Schema::create('formula_items', function (Blueprint $table) {
        $table->increments('id');
        $table->foreign('ingredients_id')->references('id')->on('Ingredients')
        $table->double('quantity_needed');
        $table->timestamps();
    });
}
22 Oct
1 year ago

midwestdev left a reply on Received A Coupon Code To Comeback Promising Me 50% Off, Got Charged $86.00

Because it said site feedback and I never seen the support link

midwestdev started a new conversation Received A Coupon Code To Comeback Promising Me 50% Off, Got Charged $86.00

I signed up for a year, was suppose to get it for 43 clicked submit, it charged me 86