Snapey

at Novate / Microlise

Member Since 5 Years Ago

Mansfield

Experience Points
1,526,665
Total
Experience

0 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
1188
Lessons
Completed
Best Reply Awards
2159
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 50
1,526,665 XP
Dec
09
2 hours ago
Activity icon

Replied to UnexpectedValueException: Invalid Route Action

Please format your code by putting 3 backticks ``` on a line before and after each code block

Activity icon

Replied to UnexpectedValueException: Invalid Route Action

"invalid route action"

For that, you would need to show the routes...

Dec
08
1 day ago
Activity icon

Replied to How To Add Another Field Like Email Verified To User

you can add additional checks to the Auth::attempt method

https://laravel.com/docs/6.x/authentication#authenticating-users

look down to Additional Conditions

Add the additional condition to the login process.

Activity icon

Replied to Carbon Dates Parsing Wrong On Import

When you use parse you are basically asking carbon to try and make something from a date input. There is not really a wrong answer.

Better to be more prescriptive and use createFromFormat and pass it the expected format. Carbon will then throw an exception if the date does not work

Test it with Tinker so that you know how it behaves

Activity icon

Replied to Carbon Dates Parsing Wrong On Import

Thats not the behavior I see in tinker;

>>> Carbon\Carbon::parse('01/01/0019')
=> Carbon\Carbon @-61567603200 {#3110
     date: 0019-01-01 00:00:00.0 UTC (+00:00),
   }
>>> 

There may be some other fault

By the way;

The problem is that, if I give some false value (e.g. 01/01/0019), Carbon parsing does not throw an error

01/01/0019 is a perfectly valid date. Why should it throw an error?

Activity icon

Awarded Best Reply on Admin Middleware To Protect Routes

It would help if "not working as expected" was explained better!

Letting everyone in, or letting noone in?

You have this route which is not protected at all

Route::get('/admin', '[email protected]')->name('admin');
Activity icon

Replied to Two Laravel Project Access Same Images Assets Publicly

See the asset helper docs https://laravel.com/docs/6.x/helpers#method-asset

You can configure the asset URL host by setting the ASSET_URL variable in your .env file. This can be useful if you host your assets on an external service like Amazon S3:

// ASSET_URL=http://example.com/assets

$url = asset('img/photo.jpg'); // http://example.com/assets/img/photo.jpg
Activity icon

Replied to Admin Middleware To Protect Routes

It would help if "not working as expected" was explained better!

Letting everyone in, or letting noone in?

You have this route which is not protected at all

Route::get('/admin', '[email protected]')->name('admin');
Activity icon

Replied to Two Laravel Project Access Same Images Assets Publicly

Nope. Don't think so. Not if it needs to be http access to the image

You have not said what 'access' means. Depending on how you access the files now, you will probably have to change every view anyway

Activity icon

Replied to Two Laravel Project Access Same Images Assets Publicly

Assuming by "access" you mean display it on a web page?

Construct the image tag to point to the other domain.

eg

<img src="http://otheradmindomain.com/product/image.jpg"

suggest you create a config item that can store the protocol and domain of the other site. Then in blade;

<img src="{{ config('admin_domain') }}{{ $product->image }}" />

that way, you have one central place to hold the domain of the other site and you don't need to go hunting through loads of templates if it changes.

Activity icon

Awarded Best Reply on Failed To Delete Image From Public Folder In Laravel.

Deleting an asset requires the file system path not the URL

and Storage uses specific folders. instead, unlink the file (regular php)

    public function destroy(Brightstudent $brightstudent)
    {
        $image_path = public_path('images/' . $brightstudent->bright_student_photo);

        if (unlink($image_path)){
            return "file deleted";
        }else{
            return "not deleted";
        }

    }

or create a Storage disk that uses public/images

Activity icon

Replied to Laravel Works With Artisan Serve But Not With Vhost

open the network tab in your browser and check if you are getting 301 or 302 redirects

Activity icon

Replied to How To Properly Fetch A Relationship Model?

This is not your problem, but beware using joins where you have identical column names in different tables. There can only be one winner. Not sure why you are using joins when you have eloquent relationships setup?

Activity icon

Replied to Failed To Delete Image From Public Folder In Laravel.

Deleting an asset requires the file system path not the URL

and Storage uses specific folders. instead, unlink the file (regular php)

    public function destroy(Brightstudent $brightstudent)
    {
        $image_path = public_path('images/' . $brightstudent->bright_student_photo);

        if (unlink($image_path)){
            return "file deleted";
        }else{
            return "not deleted";
        }

    }

or create a Storage disk that uses public/images

Dec
07
2 days ago
Activity icon

Replied to Request $request Vs. Request()

helpers like request() are super useful but not liked by some as it couples your code too closely to the Laravel framework. They prefer to inject all dependencies into the class.

Activity icon

Replied to Eloquent User Provider Causing Duplicate Query

its your with statement rather than the append that causes the extra query every time you load any user

Activity icon

Replied to Cannot Install Tailwindcss On A Fresh Laravel Project

If you are starting a new project, I can recommend pulling in

https://github.com/laravel-frontend-presets/tailwindcss

as all the auth scaffolding has been converted from Bootstrap

Activity icon

Replied to Hit Controller Manually And Send Data To It

If you need the same functionality in two controllers, consider using a trait.

Activity icon

Replied to Task Scheduling - No Scheduled Commands Are Ready To Run.

development mode should not matter. Your code runs every time in my project, except when down

Activity icon

Replied to Task Scheduling - No Scheduled Commands Are Ready To Run.

Your app is not 'down' is it?

Activity icon

Replied to I Am Hosting My Website On Cpanel And I Cant Run Composer Update

ok?

best you can hope for with shared hosting is to prepare all the files locally and then just upload them (complete with vendor folder) onto the remote server.

Activity icon

Replied to Mb_strpos() Expects Parameter 1 To Be String, Object Given

What?

clearly, no name on the premis table. So why is it in your query?

Then you say you want the type name what does that mean?

Activity icon

Replied to Laravel 6+ Change Default Cookies' Behavior

The cookies are only necessary for tracking session and authorising forms. You may not need either?

Activity icon

Replied to Mb_strpos() Expects Parameter 1 To Be String, Object Given

It has to be asked...

Do you have column name in the premis table ?

Dec
06
3 days ago
Activity icon

Replied to App URL Not Working Properly?

Your public folder should be the document root so that you don't see lsapp/public in your urls

This is done by setting the document root in Apache for the website

Activity icon

Replied to Calculating Retirement Date

I gave you the business logic earlier. You have had 2 days to think about it. Lets see your progress?

BTW, your retirement would have been one day ago if on my team.

Activity icon

Replied to Eloquent Find Hashed

You cannot use a hash to search the database as you would need to check() every row individually.

MD5 is pretty insecure so this does not seem a good option.

Activity icon

Replied to Generate Pages Dynamically

Store the form layout also in the database then render it inside your show.blade.php file.

Activity icon

Replied to App URL Not Working Properly?

The slash means that the URL is relative to the root directory. Without it, it means it is in the same folder as the current page. Removal of the backslash will cause problems as the routes get longer, like /post/3/edit since your browser will think the assets are in the /3/ folder

You should try and use the route() and asset() helpers wherever possible, or make sure that your web server is pointing to the public folder (as it should be)

Any other structure is just being lazy

Activity icon

Replied to How To Make A Pagination Where The Link Options Are The Number Of Items You Want To Show

no, since this is a Get request, all parameters must be in the url

Activity icon

Replied to It Is Possible Route A Url To Different Function?

How does the router know where name ends and ID starts?

you need a placeholder in the route, eg

Route::get("{name}-{id}", '[email protected]')->name('product');

Now you can pass as abc-123

Activity icon

Replied to Method Illuminate\Database\Eloquent\Collection::paginate Does Not Exist.

but the second parameter isnt the query parameter.

Anyway, thats not your issue. You are not chaining onto a query builder object.

Activity icon

Replied to Combo Box

¯\_(ツ)_/¯

I should know better by now.

Activity icon

Replied to Method Illuminate\Database\Eloquent\Collection::paginate Does Not Exist.

You cannot paginate a collection, you need to paginate a query.

What does teachersRepository contain?

ps. Also, you have two parameters into the paginator?

https://laravel.com/api/6.x/Illuminate/Database/Eloquent/Builder.html#method_paginate

Activity icon

Replied to Update/Recalculate Pagination After Dropping Some Items From Collection

Adjust your query so that the items are not retrieved from the database in the first place rather than dropping them from the collection.

Activity icon

Replied to Slow Response After Clicking Add Button In Laravel

You need to understand where that time is being spent. Try using Laravel Debugbar.

Activity icon

Replied to Set Email_verified_at To Null

or just write to the column and save it

public function unverify() 
{
    $this->email_verified_at = null;

    $this->save();
}
Activity icon

Replied to Combo Box

You also need the options inside a form select element !

Activity icon

Replied to Combo Box

Give your data a proper name. Swap the order of the pluck.

    public function create()
    {
        $categories = Category::pluck('ctg_name', 'id');

        return view('admin.blog.add_blog')->with('categories', $categories);
    }

Adjust the view

<tr>
          <td>Category</td>
          <td>
              <select>
              @foreach($categories as $key => $value)
                 <option value="{{ $key }}">{{ $value }}</option>
              @endforeach
              </select> 
          </td>
      </tr>
Dec
05
4 days ago
Activity icon

Replied to WhereHas Performance Issue In A Big Database

Yes, you should not have that get() statement in a scope (and thats got nothing to do with pagination)

Activity icon

Replied to WhereHas Performance Issue In A Big Database

You need to review indexes.

In your posts table make sure user_id and tag are indexed.

Activity icon

Replied to Return View Or Redirect From Private Method

redirect is better. You should always avoid returning a view in response to a post/put/patch request

Also look at the abortif helper, hoŵever what you need to do is better handled in an authorisation policy

Activity icon

Replied to Belongsto, Hasmany Noob

In your user model, this should be called group

public function users() {

    return $this->belongsTo('App\Group', 'user_id');
}
Activity icon

Awarded Best Reply on How To Upload Multiple File

use spatie media library. its so easy to use and automatically creates each image with a relationship back to the model

Activity icon

Awarded Best Reply on Using Custom Fonts

The first font that the user has available to them will be used (the first match in the statement)

https://www.lifewire.com/font-stack-definition-3467414