BryceSharp

BryceSharp

Member Since 3 Years Ago

Experience Points 27,810
Experience Level 6

2,190 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 271
Lessons
Completed
Best Reply Awards 1
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.

24 Nov
1 year ago

BryceSharp left a reply on Help Submitting Form

Instead of trying to use the modal button to trigger the submit of the form, I would suggest that you put the form on the modal that way the modal button is the submit for the form.

BryceSharp left a reply on Route Group For Admin

In the getHome() method you can return a view and pass data to it like so:

public function getHome(){
    $data = "some data";
    $info = "some info";
    return view('welcome', compact(['data','info']);
}

Tip: Use GitHub-flavored markdown to make your questions more readable. https://help.github.com/articles/github-flavored-markdown

22 Nov
1 year ago

BryceSharp left a reply on Retrieve Great Grandchild

Your Measurement model needs to have the relationship for Material defined as a function like so:

function material(){
  return $this->hasOne('App\Material');
}

You should read about eager loading in the Laravel docs for a better understanding. https://laravel.com/docs/5.5/eloquent-relationships#eager-loading

21 Nov
1 year ago

BryceSharp left a reply on Why Use WithCount() Over Just With()?

withCount() is performing with() + counting foreach of the results, thus I'd expect it to produce a slower query. The reason you would use withCount() over with() is that withCount() will give you a single number (250), while with() will give you all of the data for the 250 rows.

with() might be 550ms faster, but it leaves you with all that data. If you still need the count you will have have to spend the time to count it yourself in your code versus letting your database do it in the 550ms. Also if you're passing it to a client, you will greatly increase the size of the data you are sending.

BryceSharp left a reply on What Does Mean?

This means that your server's user who is executing the code $request->file->move(public_path('images/profile'),$getimageName); does not have the permission to write to the /home/aung/solve/public/images/profile directory. The command chmod that @rob897 provided will change the permissions.

Solution:

chmod -R 755 /home/aung/solve/public/images/

You can read more about chmod here https://www.computerhope.com/unix/uchmod.htm

BryceSharp left a reply on Create, Use And Modify A Variable In Blade

I agree it is much better to place your logic in the controller or model versus in the view. Here's how that looks with a controller.

web.php:

Route::get('/', '[email protected]');

TestController.php

class TestController extends Controller
{
    function test(){
        $test = 'test';
        return view('welcome', compact('test'));
    }
}

welcome.blade.php:

{{  $test }}

BryceSharp left a reply on Create, Use And Modify A Variable In Blade

What you want is the @php Blade directive.

@php
    $variables = [(object)['letter' => 'a'],(object)['letter' => 'b'],(object)['letter' => 'b'],(object)['letter' => 'c']];
    $lastLetter = '';
@endphp
            
@foreach($variables as $variable)
    @if($lastLetter != $variable->letter)
            @php
                    $lastLetter = $variable->letter;
                @endphp
                {{ $lastLetter }}
    @endif
@endforeach

Docs: https://laravel.com/docs/5.5/blade#php

BryceSharp left a reply on Videos Not Loading On Chrome.

Laracasts.com is working fine for me, so this is most likely isolated to your set up. I would check ad blockers and how it works in incognito window. If none of that works, test it on a phone with cellular data vs wifi. Good luck.

BryceSharp left a reply on Use Timestamp As Primary Key

I agree with @thomaskim you should not use a time stamp as the id. If you remove public $timestamps = false; then you should be able to simply use:

$new_chat = new Chat();
  $new_chat->user_id = 1;
  $new_chat->message = $request->message;
  $new_chat->save();

dd($new_chat->created_at);

Id's are meant to be an unique identifier within the scope of a table and are often used to optimize queries. Time stamps are not guaranteed unique, and are going to be worse for your behind the scenes (inside the database) query optimization. If making this change is creating other errors, I would recommend trying to resolve those versus continuing to use a time stamp for your id.

BryceSharp left a reply on Laravel 5.5 - Create Seperate Admin Panel Login Page

What you are looking for is Middleware. You will need to either implement your own or include one of the many open source solutions, and then you can set up your routes like this:

Route::group(['middleware'=>['role:role2']],function(){
    Route::get('/adminpanel', '[email protected]');
});
Route::get('/adminpanel', function(){
    return redirect('/login');
});

Laracasts.com is the best site to learn about Middleware.

BryceSharp left a reply on With() Does Not Work If I Use Where() In Relations

You are assuming that the instance of Activity calling fillData() has the scope of the eager loaded lead. It does not. The below code should fix your errors.

public function fillData($template)
    {
    $lead = $this->lead();
        if (strpos($template, '{price}') !== false) {
            $replaceData['price'] = empty($lead->price) ? '0' : $lead->price;
        }
        if (strpos($template, '{url}') !== false) {
            $replaceData['url'] = empty($lead->url) ? '[no url]' : $lead->url;
        }
        if (strpos($template, '{name}') !== false) {
            $replaceData['name'] = empty($lead->name) ? '[no name]' : $lead->name;
    }
20 Nov
1 year ago

BryceSharp left a reply on With() Does Not Work If I Use Where() In Relations

Can you include the ->where(/*clause*/) that is causing you problems?

15 Nov
1 year ago

BryceSharp left a reply on "You Cannot Serialize Or Unserialize PDO Instances" When Running A Cron Job

You should include the relevant code if you want to enable people to help you effectively.

If I had to guess I would say you are not extracting the data from the PDO before attempting to serialize it and instead are trying to serialize the entire PDO object.

BryceSharp left a reply on Sending Php Data Through Html Form To Jquery

Change your id= to class=. You'll probably have to change your selector statements in css and js (# to .)

BryceSharp left a reply on Php

They are very different.

if ($item->id != $ignoreSet)

Here you read the value of $item->id, read the value of $ignoreSet, and compare if they equal then negate the result.

if (!$item->id == $ignoreSet)

Here you read the value of $item->id and negate it, read the value of $ignoreSet and then compare the negation of $item->id to the value of $ignoreSet.

Furthermore these are the same:

if ($item->id != $ignoreSet)

if (!($item->id == $ignoreSet))
05 Sep
1 year ago

BryceSharp left a reply on Inverse One-to-Many Relationship NULL

From the docs: https://laravel.com/docs/5.4/eloquent-relationships#one-to-many

return $this->hasMany('App\Comment', 'foreign_key');

however in your code above you have:

Model B:

public function As()
{
       return $this->hasMany('A', 'foreign_key_pointing_to_id_in_table_B');
}

This would mean that the foreign_key_pointing_to_id_in_table_B should be foreign_key_pointing_to_id_in_table_A in order to find the related data in A.