cservices

Member Since 4 Years Ago

Experience Points
41,260
Total
Experience

3,740 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
386
Lessons
Completed
Best Reply Awards
1
Best Reply
Awards
  • start your 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-in-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 Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • evangelist 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.

  • Community Pillar

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

Level 9
41,260 XP
Feb
16
2 weeks ago
Activity icon

Started a new Conversation Storage Just Doesn't Seem To Work For Me

In my blade I have

<img src="{{ asset('projects/'.$p->id.'/'.$p->document) }}"/>

The file is being stored at /storage/app/projects/316/foobar.jpg When I look at the source the path seems right, but image is broken. I have tried different versions of the path

<img src="{{ asset('app/projects/'.$p->id.'/'.$p->document) }}"/>

and

<img src="{{ asset('/storage/app/projects/'.$p->id.'/'.$p->document) }}"/>

If I do Storage::exists('/projects/'.$p->id.'/'.$p->document); it says it finds it.

I have not changed anything in the /config/filesystem.php. I'm lost.

Jan
27
1 month ago
Activity icon

Replied to Trouble With A Relationship

User error. I made a change on my JS earlier and it affected another area. All is good. WOW, I knew it had to be working.

Activity icon

Replied to Trouble With A Relationship

Still having trouble.

Here is the controller method that calls the page:

public function project_view($project_id)
    {
// Query id this user has an alternate view assigned for this project
        $override_view = ProjectViewAssignment::where([
                ['project_id', $project_id],
                ['user_id', Auth::user()->id]
            ])
            ->first();

 // If $override_view, then get the view assigned to the user for this project
        if ($override_view != ''){
            $data['view'] = ProjectView::where('id', $override_view->project_view_id)->first();
        } else { // Else use the 'default' view assigned to the user in the User admin
            $data['view'] = ProjectView::where('id', Auth::user()->view_id)->first();
        }

        // Collect the data belonging to this project
        $data['project'] = Project::where('id', $project_id)
            ->with('directive')
            ->with('classification')
            ->with('triage')
            ->with('rows.dates')
            ->with('rows.digitalType')
            ->with('rows.printType')
            ->with('rows.channel')
            ->with('rows.channelMgr')
            ->first();

        // Get available views to allow admins to change the view or present in presentation mode
        $data['views'] = ProjectView::orderBy('view_name')->get();

        return view("project-view", ['data' => $data]);
    }

Inside of the view named "project-view" I have an include

<div class="project-table-container">
        @include('partials.project-view-table', ['data' => $data])
    </div>

And inside that view I have a foreach to go over the rows

@foreach($data['project']->rows as $row)

This builds the page just fine.

Within that page I have a place where I can reload the page with different classes (that is what $data['view'] is all about)

I do this with an AJAX call that has the server rebuild the table and return the rendered view. Here's the server-side code that returns that view.

public static function get_new_view($project_id, $view_id)
    {
        $data['view'] = ProjectView::where('id', $view_id)->first();

        $data['project'] = Project::where('id', $project_id)
            ->with('rows.dates')
            ->with('rows.digitalType')
            ->with('rows.printType')
            ->with('rows.channel')
            ->with('rows.channelMgr')
            ->first();
        return view("partials/project-view-table", ['data' => $data])->render();
    }

But when I get to @foreach($data['project']->rows as $row) I get an error Trying to get property 'rows' of non-object

I'm so confused. What is happening that it works one way, but not the other, and what's the best fix?

Jan
26
1 month ago
Activity icon

Replied to Trouble With A Relationship

Thank you for the input. I finally figured out what I was and was not doing. Your examples also help me see that I can do this several ways.

Jan
25
1 month ago
Activity icon

Started a new Conversation Trouble With A Relationship

I have this in my controller

$data['project'] = Project::where('id', $project_id)
            ->with('rows.digitalType')
            ->first();

When I do a dd() like this dd($data['project']->rows); I can see the rows relationship and the 'digitalType' relationship in it. But when I do this dd($data['project']->rows->digitalType); I get an error Property [digitalType] does not exist on this collection instance.

Inside my Project model have this

public function rows()
    {
        return $this->hasMany('App\Models\Row')->orderBy('place');
    }

Inside my Row model I have

public function digitalType()
    {
        return $this->hasOne('App\Models\DigitalType', 'id', 'digital_id');
    }

Why can I not access 'DigitalType'? No matter what I do it says it is not part of the collection, or does not know the index.

I've done something like this before long ago. I don't recall it being this difficult.

Any help would be appreciated.

Jan
13
1 month ago
Activity icon

Replied to Views And Messy Isset()

Since there is no $data to send when viewing the form that is ready for input, I created a empty array named $data and sent it to the view. That fixed the problem. So far.

Activity icon

Replied to Views And Messy Isset()

Should tried before I replied. I got an error when rendering just the form and no data.

$data is undefined
Make the variable optional in the blade template. Replace {{ $data }} with {{ $data ?? '' }}
Activity icon

Replied to Views And Messy Isset()

Awesome! Thank you so much.

Activity icon

Started a new Conversation Views And Messy Isset()

I have a view that relies on a lot of conditions. In this case, the form is being rendered based on retrieving a record from the DB. Is there another way to write this that is cleaner and less clutter?

It's the whole part of "isset()" for checking or not checking a checkbox that just seems to make it messy. Any advice would help.

<input type="checkbox" name="compliance" data-field="compliance" value="{{ $data->compliance ?? 'compliance_show' }}" {{ isset($data->compliance) && $data->compliance == 'compliance_show' ? "checked" : '' }}>
Dec
11
2 months ago
Activity icon

Awarded Best Reply on Custom Login With AD And Using Laravel Auth/Guard/Gate Features

I found the solution, and it was so easy I laughed out loud.

Once I verify the user is in the DB, I then attempt a login to the AD. If the 'bind' comes back true, then they are authenticated and I use the ID found when verifying the user in the DB.

Auth::loginUsingId(1);

Boom, I'm logged in via Laravel's authentication system, and access to Auth methods.

Activity icon

Replied to Custom Login With AD And Using Laravel Auth/Guard/Gate Features

I found the solution, and it was so easy I laughed out loud.

Once I verify the user is in the DB, I then attempt a login to the AD. If the 'bind' comes back true, then they are authenticated and I use the ID found when verifying the user in the DB.

Auth::loginUsingId(1);

Boom, I'm logged in via Laravel's authentication system, and access to Auth methods.

Dec
10
2 months ago
Activity icon

Replied to Custom Login With AD And Using Laravel Auth/Guard/Gate Features

Not certain that will work for me. Could not find anything about Active Directory. Seems like a lot to do for such a small login need.

Activity icon

Started a new Conversation Custom Login With AD And Using Laravel Auth/Guard/Gate Features

I want to use Laravel's authentication, but not with the password. Also, I DO NOT want to use Breeze or Jetstream. I want to write my own HTML.

What I am wanting to do:

  1. The user logs in with username/password

  2. The system only checks if the username is in the database. If so, then they are an allowed user.

  3. Because they are an allowed I want to use the credentials to log into the Active Directory. *** If they were not allowed, this step would be skipped and the user is informed that they cannot have access.

  4. If the user passes the Active Directory login, they progress into the application and data from the database is saved to Auth.

How can I do this and be still be able to use Auth and and Guards/Gates I create?

Thanks in advance. This is my first time using version 8, and this approach to login.

Oct
14
4 months ago
Activity icon

Replied to Custom Login Using Jetstream/livewire - Or Not

Thanks for that. The links were helpful. But overall, I think I found my answer in the documentation for authentication. Am still looking it over.

Maybe I wasn't clear with what I was looking for. I was looking more for how I would write the authentication and still be able to make use of what Laravel has already done for me code-wise.

Still looking for answers, but reading the authentication section for the second or third time opened my eyes to how I might be able to override some methods in favor of my needs. We'll see.

Thanks again for the info.

Oct
13
4 months ago
Activity icon

Started a new Conversation Custom Login Using Jetstream/livewire - Or Not

I'm far from an aficionado on Laravel and its login system, so please bare with me and if possible instruct me with this task. I do good with the internals of app building, but login/security are not my strong points.

I build apps that are used internally only. I'm finding I have to rebuild the login system for some of these apps.

At present I have a fresh install of Laravel 8, with jeststream/livewire installed.

In the apps, the superadmin can add users by looking them up in the company's active directory. The user's information is saved to the app's users table. Mostly name, email and login ID (first.last). Password is not stored in users table. There are other things for permissions, but not used at login.

Once this is saved in the table the login works like so:

User logs in via company Active Directory credentials. This mainly is a success or fail method. If the creds match, then the user is bound and returns true.

Next, if the AD bind was a success, the system then checks to see if the user's login/email match a record in the users table. If that is true, then the user is allowed and can continue.

I had used a package for this before, but it kept changing and did far more than I really needed, so I created my own LDAP class.

I want to make sure I am doing things as securely as possible. Else MIS will be on me.

Using Larvel 8 / Fortify/livewire how can I pull this off? Or do I have to write something and just change the routes to my custom classes. Also, if I have to write it myself, how do I compare user's input password with the AD password securely, and not with a readable string?

Thanks so much in advance for your help!

Cy

Oct
08
5 months ago
Activity icon

Started a new Conversation Upgrading From 5.4 To 7 Or 8

Is there any instructions out there for upgrading an older version of Laravel to either 7 or 8?

I found incremental upgrades, but our servers have been stuck on PHP5 for a long time. We're about to update, but that means a lot of my apps will break since I was stuck on creating them in Laravel 5.4.

Need some direction, please.

Thanks.