zachleigh

Hire Me

Experience

183,390

236 Best Reply Awards

  • Member Since 2 Years Ago
  • 731 Lessons Completed
  • 5 Favorites

23rd June, 2017

zachleigh left a reply on Searchbar Like Laracasts Website • 1 day ago

I believe he's using Algolia search for the live search suggestions.

18th June, 2017

zachleigh left a reply on FatalThrowableError • 6 days ago

Did you restart apache after installing the php extensions?

zachleigh left a reply on Object Oriented Design Technique Tips And Tricks • 6 days ago

Use the simplest design possible and adapt to changing architecture needs when necessary.

zachleigh left a reply on PhpWhois Installation Problem • 6 days ago

Couldnt get it to work here either. I think that package is dead. Maybe try this one: https://github.com/regru/php-whois

zachleigh left a reply on PhpWhois Installation Problem • 1 week ago

So you can use the class in your project then.

use phpWhois\Whois;

$whois = new Whois();
$query = 'example.com';
$result = $whois->lookup($query,false);
echo "<pre>";
print_r($result);
echo "</pre>";

zachleigh left a reply on PhpWhois Installation Problem • 1 week ago

Did you actually install it with composer or just add it to the file?

zachleigh left a reply on Moving From Procedural Structure To Object Oriented (use Of Global Variables) • 1 week ago

Well, you kind of have the right idea but simply throwing all your config values in new files isnt really going to solve any problems and wont make your code any less procedural. If youre moving from procedural code, youre probably looking at a full rewrite.

The global object you might be looking for is the service container: https://laravel.com/docs/master/container Ideally you would divide your project into different services/classes/packages that provide reusable, maintainable, easy to understand code. Each of these would have a clear responsibility within your project. These would then be loaded in your project as needed, or by using service providers. Each service/class/package would have its own config file in the /config directory and then its business logic somewhere else.

16th June, 2017

zachleigh started a new conversation Test Datatables File Download? • 1 week ago

Anybody know how to do acceptance tests for datatables CSV file downloads? We're using phpunit/Codeception and can't find a way to get the file to download. Any help?

14th June, 2017

zachleigh left a reply on How Can We Share Data Among Controllers "NOT VIEWS" • 1 week ago

Something simple like Auth::user()? Assign $user to the object in a base controller. That is by far the easiest solution.

9th June, 2017

zachleigh left a reply on Which Illuminate Packages Should Be Imported Into A Package? • 2 weeks ago

I would just require-dev the Laravel project. Then you have everything you need.

8th June, 2017

zachleigh left a reply on Set Auto Increment Values Before Running Tests? • 2 weeks ago

What does the test look like?

zachleigh left a reply on Set Auto Increment Values Before Running Tests? • 2 weeks ago

Ah, I think I misunderstood your problem a little. If youre worried about that happening again, test that you have the right kind of record as well:

$this->assertInstanceOf(User::class, $user);

zachleigh left a reply on Set Auto Increment Values Before Running Tests? • 2 weeks ago

Clear/reset your tables before each test and you won't have to worry about this.

6th June, 2017

zachleigh left a reply on Php Artisan Migrate • 2 weeks ago

What type of database are you using? What PHP version?

zachleigh left a reply on Run Method In Model On Boot • 2 weeks ago

Maybe use the model's boot or created method: https://laravel.com/docs/master/eloquent#observers

zachleigh left a reply on Copy Data From A Table Based On Another Table's Data • 2 weeks ago

Why not just migrate the whole Oracle database to Mysql?

zachleigh left a reply on Text Analysis • 2 weeks ago

Why do you want to extract the keywords?

9th May, 2017

zachleigh left a reply on Again About Admins • 1 month ago

I would make a site owner page that only you can view. On that page you could add a new administrator.

I think what you want is a roles and permissions system. So you would have the role of 'owner' and would have every permission. 'admin' and 'user' roles would also be assigned permissions.

zachleigh left a reply on Email Verification • 1 month ago

Whats on FileViewFinder.php line 137?

zachleigh left a reply on FatalThrowableError • 1 month ago

Does it tell you which file the error is in?

8th May, 2017

zachleigh left a reply on Undefined Variable • 1 month ago

What view does this show:

return redirect(route('busquedaBoxeadoresPost'))->withErrors($validator);

zachleigh left a reply on Undefined Variable • 1 month ago

Which file?

zachleigh left a reply on Undefined Variable • 1 month ago

Does it tell you the name of the undefined variable?

25th April, 2017

zachleigh left a reply on Foreach Paginate • 2 months ago

You need to add the links in your view:

{{ $comments->links() }}

Docs: https://laravel.com/docs/master/pagination#displaying-pagination-results

zachleigh left a reply on Foreach Paginate • 2 months ago

In your model, you need to capitalize Comment:

public function comments() {

    return $this->hasMany(Comment::class);

}

And in your controller, you arent taking advantage of the relationship and you arent paginating your comments.

public function show($id)
{
    $post= Post::find($id);

    $comments = $post->comments()->paginate(5);
    
    $data = [ 'id'=>$id, 'post'=>$post, 'comments'=> $comments ];

    return view('blog.view_post', $data);
}

zachleigh left a reply on How To Organize My Sass Files • 2 months ago

I break it up into modules that follow the same structure and naming as my blade and js files/modules. I then require it all into a main file and build it with webpack or similar.

24th April, 2017

zachleigh left a reply on Execute A Function Based On String • 2 months ago

$image->$variable();

zachleigh left a reply on Approving And Disapproving An Application In Laravel • 2 months ago

@Mega It took me over a year to get good at Laravel.

zachleigh left a reply on Foreach Paginate • 2 months ago

Do you have a comments method on your Post model? Are you getting an error? In what way doesn't it work? Please be specific.

zachleigh left a reply on Foreach Paginate • 2 months ago

In your show method, you are not paginating the comments. I don't even see how you are getting the comments from the database.

zachleigh left a reply on Foreach Paginate • 2 months ago

I still dont see where or how you are getting the comments. Is this the entire method?

public function show($post)
{
    return view('blog.view_post')->with('comments', $comments);
}

zachleigh left a reply on Foreach Paginate • 2 months ago

You have to actually retrieve the comments associated with the post. Are you getting an error message?

zachleigh left a reply on Foreach Paginate • 2 months ago

So this is you controller method?

public function show($post)
{
    return view('blog.view_post')->with('comments', $comments);
}

Where are you getting $comments from?

zachleigh left a reply on Foreach Paginate • 2 months ago

You are calling paginate() on the view. You need to call it on the comments.

$comments = DB::table('comments')->paginate(5);

return view('myView')->with('comments', $comments);

zachleigh left a reply on Approving And Disapproving An Application In Laravel • 2 months ago

An acronym field?? So youre making a bus reservation system? Just keep track of available buses. If a user applies for a bus, mark the bus as pending and if the reservation is confirmed, mark it as reserved or something.

zachleigh left a reply on Approving And Disapproving An Application In Laravel • 2 months ago

Make the column nullable so that default is nothing.

zachleigh left a reply on Foreach Paginate • 2 months ago

Use Laravel's pagination: https://laravel.com/docs/master/pagination

zachleigh left a reply on Approving And Disapproving An Application In Laravel • 2 months ago

Simply make an approved database column on your application table. Make a form where an admin can check a box or click a button. Accept the form in your php and insert the form data into your database. Its very basic stuff....

zachleigh left a reply on How To Go About Replacing Testing Classes With Real Ones In Production While Using Version Control • 2 months ago

So every time you want to test/deploy, you have to change all your controllers, and not only the method signature, but the method body too because in the code you are calling it $fakeMessageService. Thats a massive, massive pain in the ass.

I normally don't test controller methods because a) all my controllers do is call service classes/models which all individually unit tested and b) my acceptance tests hit all the controller methods. So to me, writing unit tests for controllers is a waste of time. I'm sure people disagree with me, but thats fine.

However, if you want to test your controllers, you need to make use of interfaces. Probably something like this (I don't test controllers, so I'm not 100% certain this will work, but I feel like it should...):

public function sendOneTimePassword(MessageServiceInterface $messageService)

Then both your real message service and your fake message service can implement the MessageServiceInterface. You will need to bind the real MessageService class to the interface in a service provider. In your real code, Laravel will inject the real MessageService class for you. When you test the controller method, however, you can create a new instance of the controller and a new instance of the fake service class. Call the controller method and pass it your fake service class.

zachleigh left a reply on How To Go About Replacing Testing Classes With Real Ones In Production While Using Version Control • 2 months ago

If you're using fakes, you should be using them in your tests, not in your actual code.

zachleigh left a reply on Approving And Disapproving An Application In Laravel • 2 months ago

This is very basic web stuff. You could either have a checkbox, like @jlrdw suggested, or just a couple buttons that send a request.

zachleigh left a reply on Sqlite In-memory Db Gets "could Not Find Driver" Error • 2 months ago

You need to install the php sqlite extension.

zachleigh left a reply on Seperating Html File And Laravel Framework • 2 months ago

@davy_yg Is the site on a shared host?

zachleigh left a reply on Database Builder • 2 months ago

@davy_yg The XP points come from watching videos, posting in the forums, and having your answer selected as the best answer.

zachleigh left a reply on Blade Templates • 2 months ago

@davy_yg Based on your posts, I don't think $5 an hour will help you. You seem to be dealing with a very poorly written legacy app that most people won't want to have anything to do with at really any price.

23rd April, 2017

zachleigh left a reply on How Can I Call A Function I Have In My Controller From A View? • 2 months ago

You could also reverse it and put it on the user model. Maybe call it 'likesArticle'.

zachleigh left a reply on Database Builder • 2 months ago

zachleigh left a reply on How Can I Call A Function I Have In My Controller From A View? • 2 months ago

I would move that function to the user model. Then you could simply do this:

$user->isLikedByMe();

zachleigh left a reply on Laravel Migration Default Value Error • 2 months ago

Probably something to do with this:

$table->unsignedInteger('level')->default()

You need to have a default value:

default($value)
Edit Your Profile
Update

Want to change your profile photo? We pull from gravatar.com.