ThinkingMan

ThinkingMan

Member Since 1 Year Ago

Experience Points 4,360
Experience
Level
Lessons Completed 34
Lessons
Completed
Best Reply Awards 0
Best Answer
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.

10 Nov
6 days ago

ThinkingMan left a reply on How To Determine Installed Version Of Spark?

php artisan spark:version is the command. Figured it out watching a Spark vid.

ThinkingMan left a reply on How To Determine Installed Version Of Spark?

@VIEZEL - But is there a command to determine what version of Spark is installed on my project or where is that file?

ThinkingMan started a new conversation How To Determine Installed Version Of Spark?

Does the Spark version match the version of Laravel or is there a way to determine the version?

17 Oct
4 weeks ago

ThinkingMan left a reply on AWS Deployed App - Viewing The Site?

Just had to set the DNS in AWS then update DNS on my registrar

ThinkingMan started a new conversation AWS Deployed App - Viewing The Site?

I just deployed an app via Forge to an AWS instance that was provisioned by Forge. I go to my AWS console and see the IP address as 11.22.33.44 but when I enter that public address in a browser I get the PHP info only and not the site. What did I miss in the setup? (I have VPC DNS=Yes).

20 Sep
1 month ago

ThinkingMan left a reply on Guzzle To POST To External Hosted Payment Page?

@Snapey Do you think the form_params could actually prevent the redirect?

11 Sep
2 months ago

ThinkingMan left a reply on Guzzle To POST To External Hosted Payment Page?

Here is the challenge, with Redirects = Yes I see the external form embedded in my view yielding a browser URL with http://donate.devel/churchpay/2 (not what I need).

Instead I would have expected the redirect to send me to the First Data page with the proper post detail ultimately with a URL like this https://demo.globalgatewaye4.firstdata.com/check_cookie?ant=a6372e2161cea20cd2035bf2313b41bc&merchant=HCO-KW-EN-279&order=f04701f1845f3542d593a614243d950c7797b56b535c5c324859f679c2284882&purch=5135798&t=1

The funny thing is that the link above is generated when I have redirects = to false. But the app stops at the view which states "You are being redirected."

ThinkingMan left a reply on Guzzle To POST To External Hosted Payment Page?

So I set the redirects = to false and now get a view in my app that states "You are being redirected." with that text being a hyperlink to the correct hosted page, but it never actually redirects to the First Data page. Here is the current function. What is missing?

public function PostFDMSdata($id)
    {
            $datetime = Carbon::now("UTC");
            $x_login = "JUW-MD-KW-972";
            $transaction_key = SomeKeyHere;
            $x_fp_sequence = rand(1000, 100000) + 123456;
            $hmac_data = $x_login . "^" . $x_fp_sequence . "^" . $datetime . "^" . "5.00" . "^" . "USD";
            $x_fp_hash = hash_hmac('MD5', $hmac_data, $transaction_key);

            $client= new Client(['cookies' => true]);
            $response = $client ->post(
                'https://demo.globalgatewaye4.firstdata.com/pay',
                array(
                    'allow_redirects' => false,
                    'form_params' => array(
                        'x_login' => $x_login,
                        'transaction_key' => $transaction_key,
                        'x_amount' => '5.00',
                        'x_fp_sequence' => $x_fp_sequence,
                        'x_fp_timestamp' => $datetime,
                        'x_fp_hash' => $x_fp_hash,
                        'x_currency_code' => 'USD',
                        'x_recurring_billing_amount' => '9.02',
                        'x_recurring_billing' => 'TRUE',
                        'x_recurring_billing_id' => 'MB-MD-KW-25-2323',
                        'x_recurring_billing_start_date' => '2018-09-08',
                        'x_recurring_billing_end_date' => '2035-01-31',
                        'x_show_form' => 'PAYMENT_FORM'
                    )
                )

                );

            var_dump($response->getBody()->__toString());

    }

10 Sep
2 months ago

ThinkingMan left a reply on Guzzle To POST To External Hosted Payment Page?

Read up on the Guzzle docs and found this section on Cookies http://docs.guzzlephp.org/en/stable/quickstart.html#cookies. Able to answer that question on my own.

Now I just need to figure out how to get the First Data page to show and not my own. So after the user clicks the pay button they should redirect to the hosted payment page but that is not happening. It still has my app in the URL. I will read Guzzle's redirect section further. It stated that it should redirect by default but that doesn't seem to be the case or possibly I am not understanding the function of a Guzzle redirect.

ThinkingMan left a reply on Guzzle To POST To External Hosted Payment Page?

Gentlemen - First a big thanks for helping the noob. I seem to be getting more detail from the page now. Not sure if I am making the proper handshake. Should I use something other than var_dump? I am getting a "need to enable cookies page" which is a false negative since they are properly enabled on my browser. Thinking it is more with the handoff.

ThinkingMan left a reply on Guzzle To POST To External Hosted Payment Page?

I have updated my Guzzle post to the following just to see what comes out. The method to var dump is wrong but I did it just to see what gets returned. The good news is I am at least trying to post to the First Data hosted page. Can anyone offer the correct step

   public function PostFDMSdata($id)
    {
            $datetime = Carbon::now("UTC");
            $x_login = "JUW-MD-KW-972";
            $transaction_key = "SomeKeyHere";
            $hmac_data = $x_login . "^" . 195701 . "^" . $datetime . "^" . "5.00" . "^" . "USD";
            $x_fp_hash = hash_hmac('MD5', $hmac_data, $transaction_key);

            $client= new Client();
            $response = $client ->post(
                'https://demo.globalgatewaye4.firstdata.com/pay',
                array(
                    'form_params' => array(
                        '$x_login' => $x_login,
                        '$transaction_key' => $transaction_key,
                        '$x_amount' => '9.01',
                        '$x_fp_sequence' => 'rand(1000, 100000) + 123456',
                        '$x_fp_timestamp' => $datetime,
                        '$x_fp_hash' => $x_fp_hash,
                        '$x_currency_code' => 'USD',
                        '$x_recurring_billing_amount' => '9.02',
                        '$x_recurring_billing' => 'TRUE',
                        '$x_recurring_billing_id' => 'MB-MD-KW-25-2323',
                        '$x_recurring_billing_start_date' => '2018-09-08',
                        '$x_recurring_billing_end_date' => '2035-01-31'
                    )
                )

                );

            var_dump($response->getBody()->__toString());

    }

So after this I get an error page inside my own app from the First Data site. If this worked properly then I should have been shown the https://demo.globalgatewaye4.firstdata.com/pay site with the proper info passed over. What are the correct methods?

08 Sep
2 months ago

ThinkingMan left a reply on Guzzle To POST To External Hosted Payment Page?

I know this isn't exactly correct but this is what I am trying right now just to prove out things. Ideas?

public function PostFDMSdata($id) { $client= new Client(); $client ->post( 'https://demo.globalgatewaye4.firstdata.com/pay', array( 'form_params' => array( '$x_login' => 'JUW-MD-KW-972', '$transaction_key' => 'SomeKeyHere', '$x_amount' => '9.01', '$x_fp_sequence' => 'rand(1000, 100000) + 123456', '$x_fp_timestamp' => 'time()', '$x_fp_hash' => 'ThisHasToBeCalculated', '$x_currency_code' => 'USD', '$x_recurring_billing_amount' => '9.02', '$x_recurring_billing' => 'TRUE', '$x_recurring_billing_id' => 'MB-MD-KW-25-2323', '$x_recurring_billing_start_date' => '2018-09-08', '$x_recurring_billing_end_date' => '2035-01-31' ) )

            );

    dd($client);
}

ThinkingMan left a reply on Guzzle To POST To External Hosted Payment Page?

The Payeezy gateway is expecting this information:

ThinkingMan left a reply on Guzzle To POST To External Hosted Payment Page?

The Payeezy gateway is expecting this information:

Payment Pages: Sample PHP Payment Form label { display: block; margin: 5px 0px; color: #AAA; } input { display: block; } input[type=submit] { margin-top: 20px; }

Processing Please Wait...

ThinkingMan started a new conversation Guzzle To POST To External Hosted Payment Page?

I started down a road of using procedural PHP with Laravel to sent a POST to a FirstData Payeezy hosted payment page. (They have sample code here https://support.payeezy.com/hc/en-us/articles/204011429-Sample-Code-Creating-a-Pay-Button-to-use-with-a-Hosted-Payment-Page) But after feedback from this audience (thanks!) and more research I landed on the potential of using Guzzle. So I am wondering if the audience thinks this is a viable approach.

Here is why I need to use the FirstData Payeezy Hosted Page. (1) The client requires that processor (2) the Payeezy gateway handles the recurring payments (3) the gateway supports check processing (4) removes the app from PCI scope. So many reasons to go with this hosted payment page.

The added challenge with my app is that I will have multiple churches connect from the app (i.e. multi tenant) and thus I need to grab the Payeezy credentials from each church and hand those unique credentials over through the POST call. I can make this happen with a standard HTML & PHP setup but I have chosen to use Laravel for all of it's benefits.

So again, would Guzzle be an approach? The Payeezy gateway is expecting this information:

Payment Pages: Sample PHP Payment Form label { display: block; margin: 5px 0px; color: #AAA; } input { display: block; } input[type=submit] { margin-top: 20px; }

Processing Please Wait...

18 Aug
2 months ago

ThinkingMan left a reply on Send Data From Blade Form View To External POST

@jlrdw thanks for being constructive. Unfortunately I have to use what this church has provided. So will try to keep it simple.

ThinkingMan left a reply on Send Data From Blade Form View To External POST

@jlrdw because First Data is required by the church.

ThinkingMan left a reply on Send Data From Blade Form View To External POST

Yeah, thats what I thought he meant.

I guess I will just ask for an approach with laravel. I will take it from there.

ThinkingMan left a reply on Send Data From Blade Form View To External POST

Thank you in advance everyone. I apologize for simple questions. I do have the HTML and PHP working much like @jlrdw has posted. Works no issue. But I am storing the values for the Church pay pages and some other variables that are needed for posting. I am building this in Laravel because the church can sign up members for historical reasons. That said here is the code thus far:

Here is the Church List/Profile Page

Donations Site - Church List Page

Donations

This will be the church list.

@if($churches)
    @foreach($churches as $church)
        <div class="card" style="width:400px">
            <img class="card-img-bottom" src="\storage\users\default.png" style="width:25%;" alt="Church image">
            <div class="card-body">
                <h4 class="card-title">{{$church->church_name}}</h4>
                <p class="card-text">{{$church->id}}</p>
                <p class="card-text">{{$church->user->name}}</p>
                <a href="{{route('profile',[$church->id])}}" class="btn btn-primary">Church Page</a>

                <form action="{{route('donate',[$church->id])}}" method="post">
                    <input class="form-control" type="text" placeholder="Name">
                    <input class="form-control" type="text" placeholder="Address 1">
                    <input class="form-control" type="text" placeholder="Address 2">
                    <input class="form-control" type="text" placeholder="Address 3">
                    <input class="form-control" type="text" placeholder="City">
                    <input class="form-control" type="text" placeholder="State">
                    <input class="form-control" type="text" placeholder="Zip">
                    <input class="form-control" name="x_amount" value="" placeholder="Payment Amount $" type="text">
                    <br>
                    <a href="{{route('donate',[$church->id])}}" class="btn btn-primary">Donate Route</a>
                    
                </form>

            </div>
            <br>
        </div>
        <br>
    @endforeach
@endif
</div>

Here is my Route

Route::get('churchpay/{id}', '[email protected]')->name('donate');

Here is the Church controller

public function donate($id)
{
    //
    $churches = Church::findOrFail($id);

    return view('churches.churchpay', compact('churches'));
}

Here is the Churchpay view (with detail to post to the Payeezy external site)

Church Donation Page label { display: block; margin: 5px 0px; color: #AAA; } input { display: block; } input[type=submit] { margin-top: 20px; }

{!! Form::model($churches, ['method'=>'GET', 'action'=>['[email protected]', $churches->id], 'files'=>true]) !!}
<div class="card card-body">
    <div class="card-body">
        <h1>Please wait for the secure donation page...</h1>
        <h4 class="card-title">{{$churches->church_name}}</h4>
    </div>
</div>
<br>
<?php
$x_login = "HCO-KW-EN-279"; // Take from Payment Page ID in Payment Pages interface
$transaction_key = "ioSB4gSXyyYiaS23BXc1"; // Take from Payment Pages configuration interface
$x_amount = $_POST["x_amount"];
$x_currency_code = "USD"; // Needs to agree with the currency of the payment page
$x_recurring_billing = "TRUE";
$x_recurring_billing_id = "MB-KW-EN-25-7722";
$x_recurring_billing_amount = "8.89";
$x_recurring_billing_start_date = "2018-08-01";
$x_recurring_billing_end_date = "2035-01-31";
srand(time()); // initialize random generator for x_fp_sequence
$x_fp_sequence = rand(1000, 100000) + 123456;
$x_fp_timestamp = time(); // needs to be in UTC. Make sure webserver produces UTC

// The values that contribute to x_fp_hash
$hmac_data = $x_login . "^" . $x_fp_sequence . "^" . $x_fp_timestamp . "^" . $x_amount . "^" . $x_currency_code;
$x_fp_hash = hash_hmac('MD5', $hmac_data, $transaction_key);

echo ('<input name="x_login" value="' . $x_login . '" type="hidden">' );
echo ('<input name="x_amount" value="' . $x_amount . '" type="hidden">' );
echo ('<input name="x_fp_sequence" value="' . $x_fp_sequence . '" type="hidden">' );
echo ('<input name="x_fp_timestamp" value="' . $x_fp_timestamp . '" type="hidden">' );
echo ('<input name="x_fp_hash" value="' . $x_fp_hash . '" size="50" type="hidden">' );
echo ('<input name="x_currency_code" value="' . $x_currency_code . '" type="hidden">');
echo ('<input name="x_recurring_billing_amount" value="' . $x_recurring_billing_amount . '" type="hidden">' );
echo ('<input name="x_recurring_billing" value="' . $x_recurring_billing . '" type="hidden">');
echo ('<input name="x_recurring_billing_id" value="' . $x_recurring_billing_id . '" type="hidden">');
echo ('<input name="x_recurring_billing_start_date" value="' . $x_recurring_billing_start_date . '" type="hidden">');
echo ('<input name="x_recurring_billing_end_date" value="' . $x_recurring_billing_end_date . '" type="hidden">');

// create parameters input in html
foreach ($_POST as $a => $b) {
    echo "<input type='hidden' name='".htmlentities($a)."' value='".htmlentities($b)."'>";
}

?>

<input type="hidden" name="x_show_form" value="PAYMENT_FORM"/>
document.myForm.submit();

ThinkingMan left a reply on Send Data From Blade Form View To External POST

The form on my site is allowed to post to the variables on the hosted payment page. As mentioned, I have this working with straight HTML and PHP. It is the pass in the Laravel MVC that I am trying to resolve. Obviously I am doing something wrong in Laravel. Will post some more code to illustrate. Thanks

ThinkingMan left a reply on Send Data From Blade Form View To External POST

Is anyone able to see my posts? I am wondering only because I am having issues accessing and a couple of my posts have not been replied to at all.

ThinkingMan started a new conversation Send Data From Blade Form View To External POST

I am creating a simple donation form for my local church and have decided to integrate to Payeezy. So essentially church members will go to the church profile page, fill in their name, address and the amount they want to donate. This can send via POST to the Payeezy hosted page. (Sample code here https://support.payeezy.com/hc/en-us/articles/204011429-Sample-Code-Creating-a-Pay-Button-to-use-with-a-Hosted-Payment-Page)

I have this working in a non-Laravel HTML form. I think my problem is something with routing as I cannot pass the form field data to the First Data hosted page. It doesnt know the value that I entered on the form. I have hard coded all fields except the $x_amount listed below. This amount is filled in on the Church Profile Laravel Blade form then I call the route to the Payeezy POST form and am trying to pass the amount over. But the amount never passes. It just comes back with the error and the variable id.

So what am I doing wrong in trying to send via the POST? Since this is not posting in my application I wasnt using the POST methods in Laravel, just trying to hand over to the Payeezy page.

<?php
$x_login = "HARD CODED FOR NOW"; // Take from Payment Page ID in Payment Pages interface
$transaction_key = "HARD CODED FOR NOW"; // Take from Payment Pages configuration interface
$x_amount = $_POST["x_amount"];
$x_currency_code = "USD"; // Needs to agree with the currency of the payment page
$x_recurring_billing = "TRUE";
$x_recurring_billing_id = "HARD CODED FOR NOW";
$x_recurring_billing_amount = "HARD CODED FOR NOW";
$x_recurring_billing_start_date = "HARD CODED FOR NOW";
$x_recurring_billing_end_date = "HARD CODED FOR NOW";
srand(time()); // initialize random generator for x_fp_sequence
$x_fp_sequence = rand(1000, 100000) + 123456;
$x_fp_timestamp = time(); // needs to be in UTC. Make sure webserver produces UTC
29 Jun
4 months ago

ThinkingMan started a new conversation Payment Gateway Integrations - Other Than Stripe Or Braintree?

Does anyone know of Payment Gateway integrations that work with First Data Merchant Services? Looking for any (current) projects out there that may work with a gateway other than Stripe or Braintree. My client is specifically looking for a gateway that supports FDMS. Thanks

18 May
5 months ago

ThinkingMan left a reply on Pay For Advanced Features

Thanks Cronix. That is the starter info I am after.

ThinkingMan started a new conversation Pay For Advanced Features

I am building an app in Spark that will have multiple tiers one of which is a trial/free tier. I want to setup Spark so that if the customer pays then they get access to whatever features are in that tier. Is there some boilerplate information out there to help me get started? I was thinking about controlling like access permission but the Spark structure is throwing me off a bit.

13 Dec
11 months ago

ThinkingMan left a reply on Access AWS MySQL With Workbench?

All - It was a bit of a process and what I did was essentially follow these two articles to ultimately decipher the basic requirements to connect to AWS over SSH. That was the biggest challenge. I thought it had to do with an endpoint issue but these ultimately were my fix.

https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/putty.html?icmpid=docs_ec2_console

http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-key-pairs.html

So I missed some of the basics of loading the keys to both Forge and using the detail from the AWS key pair.

11 Dec
11 months ago

ThinkingMan left a reply on Access AWS MySQL With Workbench?

Do you use MySQL work bench to access?

ThinkingMan left a reply on Access AWS MySQL With Workbench?

I dont have a Networks tab but rather the ports are managed through security groups.

ThinkingMan started a new conversation Access AWS MySQL With Workbench?

I have tried many things to access the Amazon instance MySQL that was deployed by Forge but have failed. By default, it doesn't appear that Forge will provision an AWS server with phpmyadmin access so I am trying Workbench. However, I cannot get the SSH to work. Need help please.

02 Oct
1 year ago

ThinkingMan left a reply on How Do I Define An API Route?

What version of Laravel? Are you running and returning error checks?

ThinkingMan left a reply on Mails Going To Mailtrap Instead Of Gmail

How about removing .env, run app then add correct .env?

ThinkingMan started a new conversation JSON API Post Queue - Tips And Pointers

Ok laracaster's, this doesn't require a hard and fast answer but just general direction and thought. Started on a new project to post order detail from a POS system to a web delivery platform. I have read only access to the POS MySQL db and was going to setup a job to look for orders with the proper delivery parameter. I was then going to post the job the 3rd part delivery web platform and add it to my application too. The reason to add to my Laravel app is so I can post updates for the merchant for things cancellations, split deliveries, etc...

I am looking for some examples out there that might help get me going. I used Postman to test my outgoing data but I have a lot more to setup. I have watched Laracasts for API's but nothing of this nature. Just looking for some direction so I can research the best approach.

Thanks in advance.

19 Sep
1 year ago

ThinkingMan left a reply on Read Only/External Database

Hey Igor - Hope all is ok with you and thanks for posting now that you are back.

Unfortunately I was not able to resolve this so I have been digging in on my own training and making sure my PHP/Laravel foundations are solid. If you have any additional advice then it is most appreciated.

09 Aug
1 year ago

ThinkingMan left a reply on Read Only/External Database

Ok. At a loss after trying the following function in my controller.


public function show_sales_detail(){

    //$salesdetails = DB::connection('mysql2')->select('SELECT * FROM EAGLEDW.dw_sls_xaction_dtl');

    $salesInfo = [];

        DB::connection('mysql2')
        ->table('EAGLEDW.dw_sls_item_dtl')
        ->join('EAGLEDW.dw_sls_xaction_dtl', 'EAGLEDW.dw_sls_xaction_dtl.dwsx_transaction', '=', 'EAGLEDW.dw_sls_item_dtl.dwsi_transaction')
        ->select('EAGLEDW.dw_sls_xaction_dtl.dwsx_transaction','EAGLEDW.dw_sls_item_dtl.dwsi_item')
        //->where('EAGLEDW.dw_sls_item_dtl.dwsi_transaction', 'A00026')
        ->get()
        ->map(function ($transaction) use (&$salesinfo){
            if(! isset($salesinfo[$transaction->dwsx_transaction])){
                $salesinfo[$transaction->dwsx_transaction] = ['dwsi_transaction' => []];
            }
            return $salesinfo[$transaction->dwsx_transaction]['dwsi_transaction'][] = $transaction->dwsi_item;
            //return view('eaglesalesdetail', compact('salesdetails'));
        });

    return $salesInfo;
}

ThinkingMan left a reply on Read Only/External Database

Igor, I am making progress and will continue to keep adjusting to see if I can resolve but I am getting a "Call to a member function map() on array" error.

Found this article which may be my issue https://laracasts.com/discuss/channels/eloquent/call-to-a-member-function-on-array

ThinkingMan left a reply on Read Only/External Database

Thanks Igor! I am going to play a bit and see what works. One thing that I am curious about is whether or not I should have a model for each table I am connecting to in my external database. I have read that it is wise to do that but that it doesn't really matter. I suppose perhaps it is just good practice?

02 Aug
1 year ago

ThinkingMan left a reply on Read Only/External Database

Thanks Igor for the help. I was playing and this essentially resolved the join problem I was having but I should have explained the end stat that I am trying to arrive at. I want to create an email receipt with header and details. The header transaction info is in one table and the line item details are in a second table. So the header has transaction information like store, cashier, time and the line item detail has item, description, price, etc...

Using your suggestion I joined them but the transaction.I created a Join in my controller which looks like

$salesdetails =DB::connection('mysql2') ->table('DB.sls_item_dtl') ->join('DB.sls_xaction_dtl', 'DB.sls_item_dtl.transaction', '=', 'DB.sls_xaction_dtl.transaction') ->where('DB.sls_item_dtl.transaction', '12345') ->get(); return view('salesdetail', compact('salesdetails'));

In my view I loop through the line item detail with a @forech which works the way I would expect. The question is how do I post header information now that the tables are joined? I know that the @foreach should not be used in this case as it would create header info equal to the line item multiple.

Since the tables are joined I know I can access the data but not sure what method to use.

Thanks in advance

30 Jul
1 year ago

ThinkingMan left a reply on Read Only/External Database

Thanks Igor. I read that in the docs and it looked easy enough but see the 2nd part of question.

I was editing the second part of the discussion and it posted early so the whole problem may not be clear. Please read the way that I have to connect and let me know how that affects this join.

ThinkingMan started a new conversation Read Only/External Database

I am reading through Join & Relationship articles https://laravel.com/docs/5.2/eloquent-relationships#one-to-many here to pin down a way to access data from a secondary external database. I am trying to understand how to make a simple JOIN using eloquent but it is hard to follow since Eloquent is automatically finding the related fields. A traditional query would look like

SELECT * FROM DB.Table1 JOIN DB.Table2 ON Table1.FieldA = Table2.FieldA WHERE FieldA = 'XYZ';

This is further complicated by the way I have to setup the MVC. I am able to make and return non-Joined calls using the following

Model

09 Jul
1 year ago

ThinkingMan left a reply on API - GET Request With An Email As Parameter

Thanks both of you. I had to modify things a bit but it looks like by removing the variable after showContact in the function I was able to get the json response. Why would that be?

public function showContact()
{
    //
    $contact = Model::where('MyEmailField', '[email protected]')->firstOrFail();
    return response()->json($contact);

}

ThinkingMan left a reply on API - GET Request With An Email As Parameter

Thanks Robstar. cx_email_addr_lookup_key is the field where the email is stored. I guess my confusion first comes as in the terminology of $id; does it literally mean table ID?

ThinkingMan started a new conversation API - GET Request With An Email As Parameter

I am just starting out in development and using Laravel and have successfully created an API to get all contacts in my database for the public function index and now want to have an individual contact available in a json response where the parameter will be an email. I am trying to use this but thinking the method is wrong:

public function showContact($cx_email_addr_lookup_key)
{
    //
    $contacts = EagleModel::findOrFail($cx_email_addr_lookup_key);
    return response()->json($contacts);

}
04 Jul
1 year ago

ThinkingMan left a reply on Two Databases - Eloquent Or Direct SQL

Looks like that did it Borisu; thanks!!!

ThinkingMan started a new conversation Two Databases - Eloquent Or Direct SQL

I have an application which is using Laravel database setting recommendations for configuring two connections as described in this article (https://laracasts.com/discuss/channels/eloquent/laravel-5-multiple-database-connection).

The application has it's own database (which I will call LocalDB) and access to a second read only, remote database (aptly named RemoteDB).

Following the article mentioned above I am trying to add a set of API's and am able to use the direct query method inside the index portion of my API controller which is great. That code looks like:

public function index()
{
 //
        $contacts = DB::connection('mysql2')->select('SELECT * FROM RemoteDB.TBL WHERE cx_customer = 000150');
    return response()->json($contacts);

}

But when I try to use a query for the show method to pull a single item I get an error:

FatalErrorException in ContactsApiController.php line 61:

Class name must be a valid object or a string

That code looks like the following:

public function show($id){ // $eModel = DB::connection('mysql2')->select('SELECT * FROM EAGLEDW.CX WHERE cx_customer = 000150');

$contacts = $eModel::find($id);

return response()->json($contacts);

}

Now I have tried to use the Laravel 2 database article to setup a model but it just never seems to work. This is the error I get when I try to set the show function to that model.

Error 1

PDOException in Connection.php line 333: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'RemoteDB.eagle_models' doesn't exist

Error 2

SQLSTATE[42S02]: Base table or view not found: 1146 Table 'RemoteDB.eagle_models' doesn't exist (SQL: select * from eagle_models where eagle_models.id = 1 limit 1)

Now, in reading the errors it looks like it is getting to the database but not able to connect to the appropriate table. I have zero control over the RemoteDB which is why I went the direct query method.

I am sure it is preferable to use the Laravel Eloquent model method but it seems trickier to solve. So my thought is it is that it is ok to use the direct query method for the second RemoteDB but I need to get past the direct query error. Not turning up much useful info with web searches.

Thank you in advance to and and all who read this!

PS - Looking at the field value details in the response using the index function there doesn't seem to be an ID value. Therefore, my next problem will be to pass in a different parameter in the API. Since it is a contact I was thinking phone or email. Thanks again!