vincej

vincej

Member Since 4 Years Ago

Calgary, Canada

Experience Points 41,380
Experience Level 9

3,620 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 178
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.

12 Mar
6 days ago

vincej left a reply on How Best To Translate A Website ?

Good point. I think that I can also go off to some foreign language sites and see how they are labeled and then build a file from there. That works ok, for the European languages ( I speak Dutch, German and French), but it's a huge amount of work though. I had hoped someone just knew of ready made language files which you could download. When it comes to something crazy like Chinese, a person is screwed.

I remember some years ago, when google forst came out with their translation api, and a guy entered "the spirit is willing bu the flesh is weak" into Google translate and it came back: "The whiskey is good but the flesh is rotten". :o)

cheers !

vincej left a reply on How Best To Translate A Website ?

yeah, thanks for that - that actually concerns the issue of how to deal with imported packages and their own language files.

vincej started a new conversation How Best To Translate A Website ?

Ok, I have built all the infrastructure and my application will select and present sample language files inside Laravel resources / lang. I can dynamically alter the language files through a view - it all works.

However, the obvious question now arises - where in the heck do I get the various language files from, or do I really have to google every word I want in every language ? Does anyone know of downloadable language files which are at least accurate and reliable?

Then I chanced across Google's language translation API for PHP, which appears to make the whole Laravel approach redundant.

So - what is the best way to translate a website ? Where can I get language files? Should I use Google instead? What's quickest and easiest since I now have the Laravel infrastructure built?

Many Thanks !

06 Mar
1 week ago

vincej left a reply on How To Sum Two Different Arrays

@CRONIX - Fair comment. About ten years ago I did learn raw PHP through Lynda.com and did some stuff with it in Wordpress and Virtuemart POS system. However, I quickly realised there was a better way with Codeigniter, and so left PHP behind. That is when I first came across you, in Codeigniter. You were a a master there too.

I still reference the PHP manual and the W3schools site regularly to find things not in Laravel, however, yes, I use it only tactically. There is just too much to learn, and time is my single most scarce resource. I spent 26 years working in ERP as a consultant for major international software corps. I have to accept that my application is functionally very rich but not as well crafted as what you or Taylor would deliver.

vincej left a reply on How To Sum Two Different Arrays

Isn't that code in the various if blocks there being executing twice?

Yes, correct. I made that point in my last post. "I assume the others are wrong as well." I will have to change them as well.

This is a brilliant idea! :

public function save_quote_edited(Request $request)
{
    // get the quote type as a variable
    $quoteType = $request->quote_type;
  
    // is there a method in this class that has the same name as $quoteType?
    if (method_exists($this, $quoteType)) {
        // yes! execute it as a dynamic method name and return it
        return $this->$quoteType($request);
    }
}

I was not aware of method exists. I will freely admit that I am not as good as I should be at refactoring my code. Especially all those validations I have that gone on for 100 lines. Jeffrey does not have much in the way of refactoring. In fact, I probably still use Laravel like it was Codeigniter. I love to write code like Taylor Otwell, with really skinny controllers.

You are a rock star, thank you.

05 Mar
1 week ago

vincej left a reply on How To Sum Two Different Arrays

I found the problem. In order to understand the problem, I have to first share with you a small image from my view: (https://drive.google.com/open?id=10VrG79gZODAHTtsP2OeXCkPEuPEwcv4w)

As I was using convertquote it was going to the 3rd option. Where the redirect was wrong. I assume the others are wrong as well. When I changed the redirect to open_quotes, all was well.

**THIS CODE IS USED TO CHECK WHAT THE USER HAS CLICKED **

    public function save_quote_edited(Request $request)  //,$id
    {

        if($request->quote_type =='new_quote') {
            $this->newquote($request);
            return $this->newquote($request);
        }

       if($request->quote_type =='correctquote') {

         $this->correctquote($request);
          return $this->correctquote($request);
        }

        if($request->quote_type == 'convertquote') {
            $this->convertquote($request);
            return $this->convertquote($request);  //THIS SHOULD HAVE BEEN: redirect ('open_quotes');
        }

I am indebted to you. Not only did you solved the addition problem but the looping problem as well.

Thank you is not enough. All the best Vince

vincej left a reply on How To Sum Two Different Arrays

Thanks again - Yes, I fixed the Request $request. F*CK!!, There are two convertQuote hits.. This going to be interesting trying to trace this. But being positive, you helped me ID the likely problem. I'll keep you posted :o)

vincej left a reply on How To Sum Two Different Arrays

back again: so to recap, I have two "loops" being presented with dump() and No, the browser console shows only 1 request being sent.

04 Mar
2 weeks ago

vincej left a reply on How To Sum Two Different Arrays

Ok, when I do a var dump and disable the redirect, I can see 2 loops reported in the browser, even though I have 3 products on the form.

Not sure what you mean by browser consoles server tab. There is no JS.

I've gotta go - it's 6.23 pm in Calgary and my wife is yapping at me - can we pick this up again tomorrow??

I'm indebted to you. Many, Many thanks !!

vincej left a reply on How To Sum Two Different Arrays

I have discovered something. However, first to answer your questions: The code gets to the server by way of a straight forward form::open() and form::submit()

I made the assumption that the whole controller did not loop multiple times, only that portion of code from $orders[]. I tested that assumption by placing a debug point on the $customer line, and damn it, yes the whole controller is looping. But why ???

public function convertquote($request)
    {
        $customer = $request->only('lastname1'); // debug here. 

vincej left a reply on How To Sum Two Different Arrays

My following comment placed in the code was incorrect:

    // NB: the code never gets to the the foreach below until it has finished looping.  Just to repeat myself for clarity, it will loop the same number of times as there are values in the $orders array. 


vincej left a reply on How To Sum Two Different Arrays

Sorry for the delay, I had to walk the dog :o),

The controller is very long, so a) I have abbreviated it, and b) yes, it needs refactoring. However, here it is:

// THIS TAKES A QUOTATION AND CONVERTS IT TO AN ORDER.  IT ALSO UPDATES THE INVENTORY DB. 

    public function convertquote($request)
    {
        $customer = $request->only('lastname1');
        $ref = $request->input('reference');
        $id = $request->get('product_id');  // GRAB PRODUCT DATA FROM POST ARRAY
        $qty = $request->get('quantity');       // GRAB QUANTITY DATA FROM POST ARRAY
        $line_cost = $request->get('line_cost_hidden');
        $discount_value_raw = $request->get('discountvalue_hidden');
        $discount_value = round($discount_value_raw, 2);
        $count_ids = count($id);


        for ($i = 0; $i < $count_ids; $i++) {
            if (empty($id[$i])) continue;
            $newOrder = new Order();
            $newOrder->reference = $ref;
            // Loads of values go here. 
        // etc etc etc
            $newOrder->save();
        }


        $get_allocation = $this->inventory->allocation($ref);  // This returns an array of "items" each of which is an object containing two values, "inv_product_id" and "allocated".

        $orders = [];
        $orders = array_combine($id,$qty);

        foreach ($get_allocation as $object) {
             if ((!empty($orders[$object->inv_product_id]) )) {
             $orders[$object->inv_product_id] += $object->allocated;
            }
        }


    // NB: the code never gets to the the foreach below until it has finished looping.  Just to repeat myself for clarity, it will loop the same number of times as there are values in the $orders array. 


        //This updates the allocation column in the inventory table with the new order
        foreach($orders as $key=>$value){
            DB::table('inventory')->where('inv_product_id', '=',$key)->update(['allocated' => $value]);
        }


    // This updates the quotations table
     DB::table('quotations')->where('reference', '=',$ref)->update(['status' => 'order']);

        return redirect('open_quotes');

    }

vincej left a reply on How To Sum Two Different Arrays

I know it is looping multiple times because I use phpstorm and I place a whole collection of debug points into the code such that I can follow the order of execution. if I only have a single value in the orders array it executes the first time correctly updates the database and then it returns back to orders and executes the second time.bIf for example I have five values in the orders array it will execute five times.

I'm not sure the empty row in the array is of any real importance as if you hard-code values in the array it loops regardless.

vincej left a reply on How To Sum Two Different Arrays

Good point. My form includes and empty row. I gave you the raw output of the dd($orders), however, in my testing over the weekend, I anticipated that this empty row could be a problem, and so have tried I commenting the $request out, and just hard coded the values into $orders as below, and sure enough it still wants to loop over twice:

 $orders = [123=>"131",789=>"12"];
 //$orders = array_combine($id,$qty);

As for array_filter I tried that as well, and for what ever reason, I could not for the life of me make that work either.

I am now thinking if the foreach can not be made to work, perhaps I could create a DB query which sums $orders and $get_allocation, as both values can be pulled from the DB.

vincej left a reply on How To Sum Two Different Arrays

Thanks for coming back. The orders array is the product of a $request:

 $id = $request->get('product_id');  // GRAB PRODUCT DATA FROM POST ARRAY
 $qty = $request->get('quantity');       // GRAB QUANTITY DATA FROM POST ARRAY

The only the thing that changed from last week was that I had different products and quantities on my form. I have inputed the same products and same quantities and did the dd() as requested:

array:3 [▼
  123 => "131"
  789 => "12"
  "" => null
]

vincej left a reply on How To Sum Two Different Arrays

@cronix I'm having a little problem with that foreach you gave me last week. I have played with this a hundred times which way, I have no idea why it is doing what it is doing. Can you tell me why the foreach is jumping back to the $orders array and looping over it a second time? The result is that it is saving the values into the DB twice. Here is the full set of code so hopefully there is little guess work:

    $orders = [];
        $orders = array_combine($id,$qty);
        
        foreach ($get_allocation as $object) {
             if ((!empty($orders[$object->inv_product_id]) )) {
             $orders[$object->inv_product_id] += $object->allocated;
            }
        }

        //This updates the DB with the new order
        foreach($orders as $key=>$value){
            DB::table('inventory')->where('inv_product_id', '=',$key)->update(['allocated' => $value]);
        }


        return redirect('open_quotes');

The Contents of $Orders looks like this:

$orders = {array} [2]
 123 = "2"
  = null

$get_allocation looks like this:

$get_allocation = {array} [1]
 0 = {stdClass} [2]
  inv_product_id = "123"
  allocated = "2"

Many Thanks !!!! :o)

28 Feb
2 weeks ago

vincej left a reply on How To Sum Two Different Arrays

@jlrdw Thanks for that. I actually saw that on SO, however, it produced an array of arrays. For me this still created the challenge of of figuring out how to get rid of the key => value, inv_product_id =123 and allocated = 4 when I needed the resulting array to be 123 => 4

Anyway, as you predicted came to the rescue with a beautifully elegant solution. Which I understand now.

If it wasn't for people like you and @cronix and @snapey I would given up years ago. Cheers !

vincej left a reply on How To Sum Two Different Arrays

@cronix Thanks for the explanation. Man I was banging my head against a brick wall with Array_push.

I am very familiar with the += syntax. However, what surprised me is that using this approach, you did not need to create a new array. You did not need to stipulate what would be the keys, nor the values. What also surprised me is that += creates a whole new set of values in the $object array at all. I mean, the preceding values are not overwritten by the last value. I have never used += in this form to achieve this result.

vincej left a reply on How To Sum Two Different Arrays

@harendrasingh Thank you. I do not understand how this works. So I will Google "array of allocations" and that will explain it all ??

27 Feb
2 weeks ago

vincej left a reply on How To Sum Two Different Arrays

Wow ! That is amazing! Thank you very much. I have to admit that I do not thoroughly understand what is happening here. I have not seen this kind of expression before, where you both sum allocated and inv_product_id, then simultaneously create a new array with just the use of +=

Thank you !

vincej left a reply on How To Sum Two Different Arrays

ok, thanks regular query with subquery it will be.

vincej left a reply on How To Sum Two Different Arrays

I have almost got my query right, but not quite. I need to be able to sum orders and allocated as Total. Any ideas ? Maybe a subquery?? How in the heck do you do one of those on QB ? Many thanks.

 public function customer_order($id) {
        return DB::table('orders')
            ->join('inventory', 'inv_product_id', '=', 'orders.product_id')
            ->select( 'orders.product_id', 'orders.quantity as orders',  DB::raw('SUM(inventory.allocated) as allocated'))
            ->where('orders.reference',   '=', $id)
            ->groupBy('orders.product_id')
            ->get();

vincej left a reply on How To Sum Two Different Arrays

Thanks for that. That makes me smile. How many people in today's world would understand your query. :o)

vincej left a reply on How To Sum Two Different Arrays

Ok, I see it now, "You may also use the count, sum, max, and other aggregate methods provided by the query builder. These methods return the appropriate scalar value instead of a full model instance:"

I guess I use QB because I am old school. :o)

vincej left a reply on How To Sum Two Different Arrays

I don't know either. I have to use QB in order to create the SUM in the query. It doesn't exist in Eloquent. I would post an image from PHPStorm, but I don't know how to post images in mark down.

I am trying a different approach, trying to create a whole new query which will sum the records from the two different tables. No success yet.

vincej left a reply on How To Sum Two Different Arrays

Yes, You suggested that as given above. I tried it and the result is still an array of objects, as given above.

Query:

public function allocation($ref){
       return DB::table('inventory')
            ->join('quotations','product_id','=','inventory.inv_product_id')
            ->select('inv_product_id',DB::raw('SUM(allocated) as allocated' ))
            ->where('quotations.reference','=',$ref)
            ->groupBy('inv_product_id')
            ->get()
            ->toArray();
    }

Controller code:

 $inventory = new Inventory();
  $allocation = $inventory->allocation($ref);

vincej left a reply on How To Sum Two Different Arrays

No, I am not working in JS. The allocation array is returned by a query. The orders array is returned by using the following:

 $id = $request->get('product_id');  // GRAB DATA FROM POST ARRAY
 $qty = $request->get('quantity');

$orders = [];
$orders = array_combine($id,$qty);

vincej left a reply on How To Sum Two Different Arrays

Tried your suggestion and it still produces an array of objects like above. Thanks though.

26 Feb
2 weeks ago

vincej left a reply on How To Sum Two Different Arrays

Thanks for that. Ok, I will give it a go. I had not thought of that. The collection that comes in from my query is not shown, however it was converted toArray, albeit inside Laravel.

vincej started a new conversation How To Sum Two Different Arrays

I have two different arrays, no big deal, except that one is an array of objects the other a straight array.

So here is one:

$allocation = {array} [4]
 0 = {stdClass} [2]
  inv_product_id = 123
  allocated = "4"
 1 = {stdClass} [2]
  inv_product_id = 789
  allocated = "8"

etc etc

Here is the other:

$orders = {array} [6]
 123 = "131"
 789 = "12"

etc etc

So, the objective is sum $allocation values ie allocated together with the $orders value. So, in this example, for product code 123, the sum total would be 135.

I have been trying to convert $allocation into the same format as $orders without success. My belief has been that once they are in the same format, then summing them should not be too bad. But I have not gotten that far yet. Most of my efforts have revolved around using foreach loops or for loops and array_push

I have looked carefully at the Laravel helpers but nothing has worked for me yet.

Any ideas would be really welcome, as I have been beating my head over this.

Many thanks !

14 Feb
1 month ago

vincej left a reply on Where Is The Location Of The 419 Session Expired Blade File ?

Brilliant ! Thank you ! Now I understand. :o)

vincej left a reply on Where Is The Location Of The 419 Session Expired Blade File ?

Don't quite follow. I want to change the message and the link to 'home'. When in the future I upgrade to say, Laravel 5.8, you seem to suggest that this will not over write the changes I make ?

vincej left a reply on Where Is The Location Of The 419 Session Expired Blade File ?

Is there some way of applying a modification without changing the core file, such that when I upgrade Laravel, I do not loose my changes ??

vincej started a new conversation Where Is The Location Of The 419 Session Expired Blade File ?

I need to modify it and I can't find it anywhere, and Php Storm can't find it either. Thanks !

vincej left a reply on Is DigitalOcean's LEMP One Click App Ready To Serve A Laravel Application?

I would like to know as well. Perhaps a query post to Digital Ocean is the best way forward ?

13 Feb
1 month ago

vincej left a reply on Redirect With Not Working

@ADO666 - Spent the whole day trying to fix this problem I found your post - And yes indeed it helped me ! Thanks !

12 Feb
1 month ago

vincej left a reply on How To Save A Table Without Making Lots Of DB Queries?

@TYKUS - Thank you for this - I will have to study how this works.

vincej left a reply on How To Save A Table Without Making Lots Of DB Queries?

@SNAPEY - Debug reports that to execute 4 queries it takes 238ms, so you are right about the 50ms.

In the interests of brevity, what I did not mentioned is that "submit" first executes an ajax call, whereupon the form data is serialized. It calls the route with the form data, then controller which then runs the loop. Is this Ajax call slowing me down?

Thinking about your opinion, the Ajax success function redirects to a new page, which loads. This could be the major overhead.

vincej started a new conversation How To Save A Table Without Making Lots Of DB Queries?

I have a table in my view containing lots of rows. Submit sends these into my controller where they need to be saved to the DB. These are all fresh new DB inserts, so updates. My current solution works fine, but is very slow. My test table with only 5 rows takes around 3 seconds to complete. Using PHPStorm, I can see that the save() method is making a separate DB call for each row. In the future, my users might have 20 rows or more. Obviously this is far from ideal. How can I redo this, so that is it much faster ? Many thanks!

This is how it is being done now:

for($i = 0; $i < $count_ids; $i++){
            if (empty($id[$i])) continue;
            $newOrder = new Order();
            $newOrder->reference = $ref;
            $newOrder->quote_name =  $request->get('quote_name');
            $newOrder->product_id = $id[$i];
            $newOrder->quantity = $qty[$i];
            $newOrder->line_cost = $line_cost[$i];
            $newOrder->subtotal = $request->get('subtotal_hidden');
            $newOrder->discount = $request->get('discount');
            $newOrder->discount_value = round($request->get('discountvalue_hidden',2)); // I USE A HIDDEN FIELD FOR THE DB SAVE AS THE DISPLAYED FIELD HAS A COMMA IN IT WON'T SAVE.
            $newOrder->netofdiscount = $request->get('netofdiscount_hidden');
            $newOrder->gst = $request->get('gst_hidden');
            $newOrder->total =  round($request->get('final_total_hidden',2));  // I USE A HIDDEN FIELD FOR THE DB SAVE AS THE DISPLAYED FIELD HAS A COMMA IN IT WON'T SAVE.
            $newOrder->comment =  $request->get('edit_comment');
            $newOrder->save();
        }

31 Oct
4 months ago

vincej left a reply on Is It Safe To Disable VerifyCsrfToken Middleware On Login And Logout Pages ?

Ok, great. what does everybody else do for this page? Do they just leave it as is, or does everyone else produce a nice friendly page? If so, ,where is it ?

vincej left a reply on Is It Safe To Disable VerifyCsrfToken Middleware On Login And Logout Pages ?

Thank you everyone for helping out!

Ok, following @cronix suggestion, I have removed the POST login form from the VerifyCSRFtoken middleware "except" and for some miraculous reason I am not getting the "expired" error message now.

Following @snapey suggestion, I have now got a log out page which does not include the login form.

vincej left a reply on Is It Safe To Disable VerifyCsrfToken Middleware On Login And Logout Pages ?

Furthermore, if I must include them with the VerifyCsrfToken middleware, then what do I do about clearing the error message, This page has expired due to inactivity, Please Refresh an d Try Again ?

Thanks

vincej left a reply on Is It Safe To Disable VerifyCsrfToken Middleware On Login And Logout Pages ?

@Snapey Thanks for that.

@Cronix Thanks for that too, however, I do not understand your point. All my views are protected by a csrf token and also the auth middleware. If I am logged out, then how can someone login after me? They have no token, and the don't know my password, so how can they be authenticated? Can you please explain in kindergarten terms? :o)

vincej started a new conversation Is It Safe To Disable VerifyCsrfToken Middleware On Login And Logout Pages ?

I ask this question since if I do not disable it I get an error message:

`This page has expired due to inactivity, Please Refresh an d Try Again'.

Refreshing does nothing. However excepting these pages from the VerifyCsrfToken middleware allows the pages to be presented.

My intuition is that as I am not logged in then these pages can not possibly be checked, even if I have a CSRF token in them.

Correct, or incorrect ?

Many thanks !

30 Oct
4 months ago

vincej left a reply on Error: Method Not Allowed When Submitting An Empty POST Array

@Snapey Great job, perfect! Another lesson learned for me. Thank you !

Why have the Language:destroy(0)?? Because I am saving the result in the DB. I only want 1 language / Industry value which will apply to all users. If I do not destroy the previous entry, then the DB creates a new row.

Why save the values in the DB? Because my next step is to create some middleware which will check those values when a user logs in, and apply the language to App::setlocale() in a session. Similarly the industry. Ultimately, the goal is so a single company can have french and english (or whatever) users. Furthermore, the goal is that a company can use my application to run multiple industries across multiple languages.

vincej started a new conversation Error: Method Not Allowed When Submitting An Empty POST Array

I have a small form made up of 2 different sets of 3 radio buttons. It works fine so long as one value is selected from each set. I have put validation into the controller in the event that the user forgets to select a radio button. If you forget one of the required radio buttons I get an error Method not allowed. If you hit backspace a few times you can see the form again with the correct validation messages.

All my other forms in my project work fine. I can't see why this one won't work. Any ideas?

Many Thanks!

Route

Route::post('update_language', '[email protected]');

Form

 @if ($errors->any())
        <div class="alert alert-danger">
            <ul>
                @foreach ($errors->all() as $error)
                    <li>{{ $error }}</li>
                @endforeach
            </ul>
        </div>
    @endif


 {{ Form::open( ['url' => 'update_language']) }}

<div class="row">
    <div class="col-sm-2 col-md-2 "><h4><strong>Language</strong> </h4></div>
    <div class="col-sm-2 col-md-2 col-md-offset-2"><h4><strong>Industry </strong></h4></div>
</div>


<div class="row">
    <div class="col-sm-2 col-md-2"><h5>English: </h5></div>
    <div class="col-sm-2 col-md-2">{{Form::radio('language','English', false)}}</div>
    <div class="col-sm-2 col-md-2"><h5>Default: </h5></div>
    <div class="col-sm-2 col-md-2">{{Form::radio('industry','Default', false)}}</div>
</div>

<div class="row">
    <div class="col-sm-2 col-md-2"><h5>French: </h5></div>
    <div class="col-sm-2 col-md-2">{{Form::radio('language','French', false)}}</div>
    <div class="col-sm-2 col-md-2"><h5>Roofing: </h5></div>
    <div class="col-sm-2 col-md-2">{{Form::radio('industry','Roofing', false)}}</div>
</div>

<div class="row">
    <div class="col-sm-2 col-md-2"><h5>Spanish: </h5></div>
    <div class="col-sm-2 col-md-2">{{Form::radio('language','Spanish', false)}}</div>
    <div class="col-sm-2 col-md-2"><h5>Automotive: </h5></div>
    <div class="col-sm-2 col-md-2">{{Form::radio('industry','Automotive', false)}}</div>
</div>

</div>


<div style="margin-top:2em;" class="col-sm-4 col-md-4">
    {{ Form::submit('Update', ['class'=>'btn btn-primary']) }}
</div>


{{ Form::close() }}


Controller

public function updateLanguage(Request $request){
     
   $this->validate($request,[
             'language'=>'required',
             'industry'=>'required',
             ]);

         Language::destroy(0);  // eliminates the existing language / industry from DB

         Language::updateOrCreate(
            ['language' => $request->language, 'industry' => $request->industry]
        );
        $language = Language::all();

        return view('settings.language',compact('language'));
    }
24 Oct
4 months ago

vincej left a reply on Localization For Standard Auth Screens

@Snapey HI There !!

Funny, I could make the array version work but not the json version.

I don't want to set local on every request, I want to set the language globally.

02 Oct
5 months ago

vincej left a reply on AJAX: Can Not Get Data Into Controller

I can not thank you enough.

21 Sep
5 months ago

vincej left a reply on AJAX: Can Not Get Data Into Controller

The call is made by the browser using AJAX / POST. My theory is that I need to include the session key in order to get past the web / admin authentication.

Request URL: http://192.168.1.92/save_edit/jac180818-95

Route::post('/save_edit/{id}','[email protected]_quote_edited');

//Full constructor has been omitted for brevity
 $this->middleware('auth:admin', ['except' => ['customer_quote']]);



 public function save_quote_edited(Request $request){

        dd('line 204');

        }

vincej left a reply on AJAX: Can Not Get Data Into Controller

How do I share with you privately?