learn-by-flying

learn-by-flying

Member Since 10 Months Ago

Experience Points
2,640
Total
Experience

2,360 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
20
Lessons
Completed
Best Reply Awards
0
Best Reply
Awards
  • start-engines Created with Sketch.

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • first-thousand Created with Sketch.

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • 1-year Created with Sketch.

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • 2-years Created with Sketch.

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • 3-years Created with Sketch.

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • 4-years Created with Sketch.

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • 5-years Created with Sketch.

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • school-session Created with Sketch.

    School In Session

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

  • welcome-newcomer Created with Sketch.

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • full-time-student Created with Sketch.

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • pay-it-forward Created with Sketch.

    Pay It Forward

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

  • subscriber-token Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer-token Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • lara-evanghelist Created with Sketch.

    Laracasts Evangelist

    Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.

  • chatty-cathy Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

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

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

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

Level 1
2,640 XP
Oct
02
4 months ago
Activity icon

Started a new Conversation Code Block

Hello All,

I have a question regarding the use of the same 9 lines of code throughout many controller functions and the best practice for this with regards to Laravel.

We are building out an internal tool which interacts with Microsoft Navision and to consume some of its data through ODATA I use the same 9 lines of code repeatedly with only preset variables which change.

        $login = $this->odataLogin;
                $password = $this->odataPass;
                $url = $this->odataBaseURL."Customer_List?$format=json&$filter=No%20eq%20'$nav_cNumber'";
                $ch = curl_init();
                curl_setopt($ch, CURLOPT_URL,$url);
                curl_setopt($ch, CURLOPT_FRESH_CONNECT,$url);
                curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
                curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
                curl_setopt($ch, CURLOPT_USERPWD, "$login:$password");
                $result = curl_exec($ch);
                curl_close($ch);  

                $obj = new \stdClass();

                $obj = json_decode($result, true);

Is there a way to call this into multiple controllers and functions more effectively?

Thanks,

Aug
30
5 months ago
Activity icon

Replied to Mail Notifications

@janosk Thanks so much, not sure how I missed that.

Aug
29
5 months ago
Activity icon

Started a new Conversation Mail Notifications

I am trying to grasp notifications and have then sending out correctly however I am pulling my hair hair out trying to pass data.

The goal is to send out a notification to all staff when a new post is created.

For now I am calling this off of my StaffDashboardController controller on the index so that I can just refresh the index.

public function index()
    {
       $staff = Staff::all();
       $post = Post::find(1);

    //$staff->notify(new NewAdminNewsPosted($post));
    Notification::send($staff, new NewAdminNewsPosted($post));

        //Step 1. Get all the pertinent information on the admin homepage.
            $posts = Post::all();

        return view('back-views.dashboard-staff.dashboard')->with('posts', $posts);
    }

And I have the following function within my NewAdminNewsPosted file within App/Notifications

use Queueable;

    public function __construct()
    {
        //
    }

    public function via($notifiable)
    {
        return ['mail'];
    }


    public function toMail($notifiable)
    {
        return (new MailMessage)
            ->from('[email protected]', 'Buehler - ESD Alerts')
            ->subject('ESD: News Posting')
            ->line('A new news item has been posted, we thought you may want to check it out. ')
            ->action($notifiable->post, url('/'))
            ->line('Thank you for using our application!');
    }

For the life of me, I however cannot manage to get the $post->id to populate or the $post->post_title, I have read the documentation on this and watched a few youtube tutorials but cannot figure this one out.

Any help or points in the right direction would be greatly appreciated.

Thanks,

Tom

Aug
23
6 months ago
Activity icon

Replied to Return $next($request) With Parameter

To update the thread, I was able to flash the message, I am using the following:

//Let all admin's through
        if($staff->isAdmin == 1)
        {
            session()->flash('warning', 'You are being granted access by your Admin status and not based on your role.');

            return $next($request);
        }

        return redirect()->back()->with('error', "Access error, you do not have access to \"$friendly_name\".");
Activity icon

Replied to Return $next($request) With Parameter

Yes, but the opposite, in your example Bob as an admin would have access through his admin flag and not his user role.

After digging in the documentation I should be able to add to the session data.

Activity icon

Replied to Impossible To Disable Register In Laravel 5.8!

It might be a better question as to why you are turning off register instead of possibly hiding it, you will need the functionality to add users unless you have another controller/function working with the users model.

To just disable the route @nakov answer is correct.

I would leave open, but redirect it with an error explaining why the route is turned off instead of causing a 404 error.

Activity icon

Replied to Is There Any Series Or Episode On Multiauth ?

@babarkhan if you are looking to create two user sets there is this set of videos on YouTube by DevMarketer.

Very well done and what I used to get started.

https://www.youtube.com/watch?v=iKRLrJXNN4M

Activity icon

Replied to User Model Best Practices

I echo what @jlrdw says, also keep in mind that a lot of the functionality in deeper parts of the auth are not directly relayed to you when creating the authentication scheme for the first time using the make::auth command.

An example of this is customizing the password reset logic and so forth.

Before I would ever start customizing (which I have), run through a hello world app with what you are trying to customize before placing the customization's into a development app.

Also, you can always pull in information from other models and especially with the hasOneThrough() or hasManyThrough().

Activity icon

Replied to Return $next($request) With Parameter

Thanks for the reply @jlrdw

Within the system each staff member has a role with a certain set of permissions, this allows/blocks access through middleware to certain parts of the system.

Staff members can also be tagged as an admin which gives them access into the admin portion of the interface to control items such as deep permissions management but also gives them access into the entire system as even if Staff John Smith is a technician, and the page he is on requires technician II access, because John is an admin he can access.

The goal here as requested is to visually alert admins that they are accessing parts of the system which are outside of their role however due to their admin access they can proceed. This also then kicks off audit logging to understand why an admin may have overridden something.

Within the system I have two guards functioning protecting the users on the front end and then staff on the back side of the app. User's have their own permission roles which are assignable based on status coming from our ERP but limited in functionality scope to only user functionality such as changing organizational names, updating tax certificates etc.

I am not receiving any errors with the:

return redirect()->back()->with('error', "Access error, you do not have access to \"$friendly_name\".");

but if I comment out the ->with() as in:

if($staff->isAdmin == 1)
        {
            return $next($request)/*->with('warning', 'Access is being granted on admin status, your role is not granting.')*/;
        }

I receive a Method Illuminate\HTTP\Response::with does not exist.

Thanks,

Activity icon

Started a new Conversation Return $next($request) With Parameter

Hello All,

I have searched and searched, however I cannot find anything.

Background: I have a role based access system implemented through middleware however I also let admin's override their roles access but want to do so with a warning so fare I have my middleware all working except with the ->with statement after the $next($request).

Any ideas on how to properly implement this?

//Let all admin's through

        if($staff->isAdmin == 1)
        {
            return $next($request)/*->with('warning', 'Access is being granted on admin status, your role is not granting.')*/;
        }

        return redirect()->back()->with('error', "Access error, you do not have access to \"$friendly_name\".");