jerschmidt14

jerschmidt14

Member Since 1 Year Ago

Experience Points 2,610
Experience Level 1

2,390 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 21
Lessons
Completed
Best Reply Awards 0
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.

25 May
23 hours ago

jerschmidt14 left a reply on Security In Controller

I think i have it. Change the controller to

$this->middleware('auth'); $this->middleware('role:widgets');

then in the role middleware change the handle to

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

Now i can access the "widgets" value from the $role variable.

Jeremy

jerschmidt14 left a reply on Security In Controller

Hi,

I added another middleware (rolecheck) call in the contructor.

e.g. $this->middleware('auth'); $this->middleware('rolecheck');

with this in the rolecheck middleware i can access the auth()->id())

now, is there a way i can pass in a parameter to the rollcheck?

Ideally for the widgets controller, i would like to pass a string parameter of "widgets" to it. Seems i can access the $request in the middleware. Can i assign something to the request, or directly pass in a string variable? My code is in public function handle($reuqest, Closure $next)

jerschmidt14 left a reply on Security In Controller

I took a look, but what i would like to do is to call a check in the constructor of each controller. It would do a check to see if the roll is available for the user. I have created the function, however, i don't have access to the user session to grab the id (auth()->id() returns null) in the construct of the controller. Is there another function that i can use in the controller that runs after the middleware runs? Ideally, I don't want to do this check in every function that i have in the controller that is called by a route.

24 May
1 day ago

jerschmidt14 started a new conversation Security In Controller

I have noticed that each controller has a construct method. I have separated my code functionality into individual controllers (e.g. run admin functionality, run query functionality). i would like to restrict access to the controllers for each role of the user. i can easily check to see if the user is part of the roll via a db call. can i do the check in the construct of the controller, or is there a better place to do this?

23 Mar
2 months ago

jerschmidt14 left a reply on Modal Form Bootstrap

Thanks Cronix! Will give a try. BTW, for anyone looking, i have found an example. https://www.codovel.com/complete-laravel-5-crud-ajax-popup-modal-form.html

jerschmidt14 left a reply on Modal Form Bootstrap

Hi Cronix. Thanks for the response! I was thinking of this as well, but the problem is that the table list is on a stateless page. You can't be sure when the last time it was refreshed (could be hours). if another user comes in and edits, it will be an issue. i want to load the values at the time the person clicks the edit button. I think i will try doing an ajax call to the rest controller, send all the values back using json, and then load them at the time. was hoping for an example, but i will try it out. as well, i would like the table to be dynamically refreshed on the page without an ugly Postback (page refresh). I will try this using a div around the table and refreshing the html inside.

Jeremy

22 Mar
2 months ago

jerschmidt14 started a new conversation Modal Form Bootstrap

Hi,

I have a table on the screen that shows some of the fields on the record, but not all. I want to click a button and just pass the Id back hopefully to a controller (that way you get a fresh set of data from the database as well in case of concurrency issues). I was hoping to store the form for the modal in a blade housing a bootstrap form and use an include in the section for the modal form. Normally for a simple page, i would call a controller (passing the id) that returns the view, but this is a little different. is there any example on passing a variable number of fields to the blade? or do i write PHP database code in the blade? All the examples i have seen just pass up the data that is in the table on the screen, which isn't what i need.

e.g.

Field1 Field2 Field3 abc def 123 Edit Delete

Opens up a model form with

Field1

Field 2 < def >

field 3 <123 >

field 4

field 5

field 6

SAVE, close

Thank-you,

Jeremy

14 Feb
3 months ago

jerschmidt14 left a reply on Base URL

Hi Singnar and Snapey,

Thank-you for your solutions! I got the one from Signar to work. My issue was that i didn't have to URL rewrite installed. Works like charm! Thanks again.

 I don't have control of DNS where i work, so my choice was to use virtual directories.  

Cheers,

Jeremy

13 Feb
3 months ago

jerschmidt14 started a new conversation Base URL

Hi, so I want to host my app in iis. I have many apps running and each has its own virtual directory. I have Laravel working on it. Well almost. To get to my app you go http://server/appname. I noticed that my routes don’t work route(‘/test’). And I put all links in as {{ url(‘/route’) }} in the blades. Is there anyway to override the route and URL functions so that they would return /app name/route without me making a mess and hard Coding? I tried putting in the app.php but doesn’t seem to work. I did notice people overriding some methods but being as I am a noob, I need to know specific files to put code in. I am using Laravel 5.7. Thanks in advance!

30 Jun
10 months ago

jerschmidt14 left a reply on Return Array From Stored Procedure

Hi,

Thanks to everyone who replied!

I ended using pluck and writing a wrapper function for it.

private function ArrayToKevValue($arrayIn,$keyColumn,$valueColumn) {

return (Arr::pluck($ArrayIn,$valueColumn,$keyColumn));

}

BTW, ensure to include his library:

use Illuminate\Support\Arr;

However, this does seem like such as waste (doing a foreach to load it after it is already loaded). Loading into a format I don't want, and then converting it back.

Good news though. I did find another article that you can get the connection, and use that to loop through a pdo array, which seems to be more my liking. I am interested in speed of load. In case you are interested, check out:

https://stackoverflow.com/questions/24683730/how-to-get-database-resource-instead-of-array-from-laravel-query-builder

at the bottom a poster called cokercake showed an example. I will try this out in future.

Being an old C++ coder, I just hate wasting cycles AND I want fast web pages.

Jeremy

28 Jun
10 months ago

jerschmidt14 started a new conversation Return Array From Stored Procedure

Hi, I want the results from a stored proc into an array with key and value. In laravel from a select i can do:

\DB::connection('testdb')->table('test')->pluck('keyid','valuecolumn')

i get an array like

[0] = 'jeremy' [1] = 'test'

however, when i do

\DB::connection('testdb')->select("call up_test('1');");

i get an array like

0 => {#1313 ▼ +"keyid": "0" +"valuecolumn": "test" }

which i don't want. I would like in a standard array like the pluck does.

Cheers,

Jeremy

17 Apr
1 year ago

jerschmidt14 left a reply on Unique Indexes On A Composite Key

Thank you! I will give this a try.

15 Apr
1 year ago

jerschmidt14 started a new conversation Unique Indexes On A Composite Key

I have a table that has a unique composite key (car,city). I also have a unique id on the table for Laravel. I would like to make sure that nobody inserts the same car, city when one already exists. So i defined a unique key in mysql on my table. I would like to trap this error, and display a friendly on back to the user. Is it best to put this error trapping in the controller, or should i do something in the model instead? What is the best way?

06 Apr
1 year ago

jerschmidt14 left a reply on Default Values On Save

I think i am getting closer. I have put this in the BaseModel class which extends model. I use this class for all of my models. I only want to update "TestValue" if i have the attribute on the model. Still doesn't seem to be setting, although the code is called. I put in a sample value of 2, however in the real world, i will be setting to the value returned from a function.

jerschmidt14 left a reply on Default Values On Save

Hi jlrdw. I don't want to use the controller to do this as i have many referencing the model. I would like to default the value inside the model everytime someone saves (insert or update).

jerschmidt14 started a new conversation Default Values On Save

Hi, i would like to override field value(s) when i do a save. I would like to put this in the model, so that every time a save is called, it will default the value. That way i don't have to create custom save routines for each model. I have tried putting in a dd, but it seems it is never being called.

public function __save ($name_equals = null, array $options = array()) { $this->attributes['Testfield'] = 55; //dd('I am here'); // Do great things...

        parent::save($options); // Calls Default Save
    }

I have also tried doing without success public $attributes = ['TestField' => 55'];

As well above doesn't allow me to call a function to set the field (which i would also like to do).

28 Mar
1 year ago

jerschmidt14 left a reply on Laravel Recommended Host

Ok. Thanks Everyone!

jerschmidt14 started a new conversation Laravel Recommended Host

Hi, We are looking at hosting our Laravel app. All the development seems to point to using Apache. We would like to use IIS because it allows us to us windows authentication. Are there any drawbacks of using Laravel on IIS? I did a POC, and it seems to work fine.

Cheers,

Jeremy

jerschmidt14 left a reply on Authentication

Thanks Snapey! I found the issue. I have put the code in a middleware component instead and referenced in the kernel.php. This allows it to run every time the page loads. I think it wasn't remembering I was logged in between postbacks. I execute the routing as one of the last middleware calls. Works well.

27 Mar
1 year ago

jerschmidt14 started a new conversation Authentication

I am trying to auto-login a user. I have put the following code in a controller. I access the control from a route post.

    if (Auth::guest())
    {
        print_r("You are currently a guest.<br />");
        
        if ($result) {                        
            $user = User::find(611);               //hardcoded user id in database
            Auth::login($user,true);               
            print_r("Guest Flag \n");
            if (Auth::guest()) {
                print_r("Guest");
            }
            else
            {
                print_r("User Logged in");
                print_r(Auth::User());
            }
            return redirect("/");           
        }  

Every time i call the page, it shows User Logged in, along with the details of userid 611 which is correct. However, when i redirect to the same page, it does a login again. As well, the rest of my app shows Auth::guest() = true. It seems it is only logged in for the one page?

Cheers,

Jeremy