Snapey

Member Since 5 Years Ago

Mansfield

at Novate / Microlise

Experience Points 1,435,335
Experience Level 50

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 1134
Lessons
Completed
Best Reply Awards 2038
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.

14 Sep
1 day ago

Snapey left a reply on A Bug In Gate Facade Functionality Or I'm Getting Things Wrong?

your gate uses isSuperAdmin but then you add an is_admin method to your model

Snapey left a reply on Which Pagination Approach Is More Performant?

In addition, you have no way of holding all the records in memory from one request to the next, so, whilst you may only send the first 20 of 200 to the client, come page 2, you will have to do it all again.

if the records are below 1000 (say 100kb) then you can get away with sending all to the client and letting it paginate locally. Datatables does this by default.

Snapey left a reply on Why /forum Do I Redirect To Public/forum?

your root of laravel project should not need .htaccess, because your document root for your webserver should be your public folder.

any other setup is just a fudge and will have issues as well as leaving .env exposed

Snapey left a reply on Sending Data From Inputs To Mail

in the mailable, accept the data

    public $validatedData

    /**
     * Create a new message instance.
     *
     * @return void
     */
    public function __construct($validatedData)
    {
        $this->validatedData = $validatedData;
    }

Now, in your view, you will have access to the $validatedData

Snapey left a reply on Unique Slug Duplicate Entry

Sorry, the subject needs to come from the request. $news has not been created yet

$previous = News::where('slug',Str::slug($request->subject))->count();

Snapey left a reply on Making Sense Of Password Reset

That route points to the ForgotPasswordController

Look in your app\Http\Controllers\Auth\ForgotPasswordController.

At the top of that file you will see use SendsPasswordResetEmails;

/vendor/laravel/framework/src/Illuminate/Foundation/Auth/SendsPasswordResetEmails.php contains the code to render the view

Snapey left a reply on Making Sense Of Password Reset

if you look just inside the controller class, there is a use statement.

This is importing a bunch of methods into the controller. Traits are a way of importing code into multiple classes. The thing about traits is that you can replace them in your own controller code

Laravel uses this to provide boilerplate code that you can override

Snapey left a reply on How Can I Get Only Team Permissions

you say 'team' but then query User model?

Snapey left a reply on Unique Slug Duplicate Entry

public function store(Request $request)
    {
        //validate

        $this->validate($request,[
            'subject'=>'required|min:10',
            'tags' => 'required',
            'body' => 'required|min:20'

        ]);
        
        //store

        $previous = News::where('slug',Str::slug($news->subject))->count();

        $news=auth()->user()->news()->create($request->all());

        if($previous) {
            $news->slug = Str::slug($news->subject);
        } else {
            $news->slug = Str::slug($news->subject).'-'.$news->id;
        }

        $news->save();

        $news->tags()->attach($request->tags);
      
        //redirect
        return redirect()->route('news.index');
    }

adjust if your model is not called News

Snapey left a reply on Notification With Markdown Not Work

please mark best reply if your problem is solved, and please remember to format your code blocks or we end up with a mess like your last reply

Snapey left a reply on Unique Slug Duplicate Entry

The problem is that you don't know its the initial post. The only way you would know is to query the database.

Its possible of course, but I would probably do it in the controller. If no post exists with that slug, populate the slug in the create() method then in this observer, check if slug is already set. If not, add the ID.

Or just do it all in the controller.

Snapey left a reply on Notification With Markdown Not Work

or...

remove the indent, it will put spaces before your markdown

    {{ $line }}

Snapey left a reply on Notification With Markdown Not Work

Can you please format your code by putting 3 backticks ``` on a line before and after each code block where you are describing what you get?

My thoughts are that you need blank line before the table.

Snapey left a reply on Unique Slug Duplicate Entry

created instead of creating

 protected static function boot() {
    parent::boot();

    static::created(function($news){
        $news->slug = Str::slug($news->subject).'-'.$news->id;
    $news->save();
    });
    }

Snapey left a reply on Check The Dates Before Planning

ok, so you are not trying to contact the dead?

And what is a former?

Snapey left a reply on E-commerce Checkout Process

You need to hold 'state' on the back-end as you go through the process.

This can be held in session or in the database. The only issue with doing it in the database is that you will have some abandoned carts and records littering your database that are in various stages of completion.

Still probably the best way to go, you can always clean up later. It also gives you the opportunity to review how much abandoned carts there are and at what stage in the process.

Its a lot of work, but writing ecommerce always is. This is why people use things like shopify, even when they are capable of writing it themselves.

Snapey left a reply on Check The Dates Before Planning

Thats not what I mean...... Are these the real things in your application or have you changed them to hide the real nature of your application?

I mean, someone booking a seance on a motorbike?

Snapey left a reply on Changing From Date To Datetime

Please mark it resolved so that others don't keep looking at it.

Snapey left a reply on Refactoring My Store() Method

You can't get away from your image code (although it contains mistakes)

You could use create like

$post = Post::create(
        $request->only(['title', 'description', 'prize', 'location']) + 
        ['image'=>$fileNameToStore]
    );

Snapey left a reply on Check The Dates Before Planning

is all this in secret code?

seance?

revision?

motorbike?

Snapey left a reply on Unique Slug Duplicate Entry

You cannot do it in creating because the model ID still has not been created by the database.

Move it to created and add save();

It does mean that you will have two database writes for every post

Snapey left a reply on URL::temporarySignedRoute To Delete User Account

Temporary signed routes are signed with a very long apparently random signature. If the URL is tampered with in any way then the signature will not match and the update will be rejected.

They are VERY secure.

(as long as you keep your app key private)

Snapey left a reply on Refactoring My Store() Method

Whats wrong with what you showed?

Snapey left a reply on $schedule->job Alway Goes To OnFailure

ok 'thanks for your time'

Snapey left a reply on Unique Slug Duplicate Entry

Thats because it makes no sense.

try

$news->slug = Str::slug($news->subject) . '-' .  $news->id;

But remember you can only do this once you have already created the model (and got its id), so you will need to set slug as nullable in your migration for the model

Snapey left a reply on Invalid Argument Supplied For Foreach() (View:

So, from your other question. Remark belongs to seance. Seance belongs to candidate, candidate belongs to user.

You cannot ask for user remarks unless you also make remark belong to user and add a relationship

Snapey left a reply on Class 'Intervention\Image\ImageServiceProvider' Not Found

If you just add the folder then it is not indexed by composer and will not appear in its class autoloader. Therefore php cannot resolve the class.

Snapey left a reply on Invalid Argument Supplied For Foreach() (View:

So, how do you have a model for Candidate if they are just users with Candidate role?

Snapey left a reply on My Architecture Is Correct?

Sorry, I must be being thick. I don't understand your cardinalities.

Seance only has one remark ?

Snapey left a reply on Invalid Argument Supplied For Foreach() (View:

I don't know? I don't know how you differentiate between User and Candidate and Administrator

Snapey left a reply on Class 'Intervention\Image\ImageServiceProvider' Not Found

You mean in config/app.php Providers array?

Have you run composer dump as suggested?

Snapey left a reply on Invalid Argument Supplied For Foreach() (View:

You don't have remark in your Candidate model?

Snapey left a reply on My Architecture Is Correct?

Anything that is belongsTo needs a key on its table, pointing to the other table, unless it is a belongsToMany where the pivot table has the keys

Just write it out as pairs of statements. For instance

Seance has many remarks, remark belongs to Seance

Candidate..something.. Seance, Seance..something.. Candidate

I can't work it out for you since you don't describe the relationships sufficiently. Also you say you have Administrators and Candidates but then talk about users

Snapey left a reply on Class 'Intervention\Image\ImageServiceProvider' Not Found

WHERE and WHEN are you getting this error

Snapey left a reply on Class 'Intervention\Image\ImageServiceProvider' Not Found

I don't think I did this at all

Injected ImageManager via the constructor

use Intervention\Image\ImageManager;

class MemberController extends Controller
{

    public $imageManager;

    public function __construct(ImageManager $imageManager)
    {
        $this->imageManager = $imageManager;
    }

then used it in a method



        $slim = json_decode($request->photo);

        $img = $this->imageManager->make($slim->output->image);
        $img->save(storage_path() . '/app/public/cropped/photo-' . $member->legacyid . '.jpg');

        $img->resize(150,200)
                ->resizeCanvas(170,220,'center')
                ->resizeCanvas(0,5,'top',true)
                ->text($member->fullname,10,220, function ($font) {
                    $font->file(2);
                    $font->size(16);
                })
                ->save(storage_path() . '/app/public/bordered/photo-' . $member->legacyid . '.jpg');

Snapey left a reply on Class 'Intervention\Image\ImageServiceProvider' Not Found

WHERE and WHEN are you getting this error

Snapey left a reply on Invalid Argument Supplied For Foreach() (View:

You have three different ways of obtaining the remarks. Give us a clue which one you are testing?

Perhaps the current user does not have any remarks?

Snapey left a reply on In A Job, Auth::user() Doesn't Work, But Request()->ip() Does! Why?

I don't know then. That does not make any sense. There won't even be a request object.

Snapey left a reply on Store Options In Database

You could simplify by having

one input box as 'question'

one input box as 'correct'

and then additional input boxes for alternative1, alternative2, alternative3

Then you can save these without testing each to see if it is marked as correct, and can get rid of the checkbox.

When listing the answers you can show them in random order so that although you enter answers as correct plus alternatives, they are displayed with the correct answer in a random position

Snapey left a reply on Read HTML Tag From Database To Blade (Within Owl-carousel)

Sorry, it is not possible to understand your question.

Snapey left a reply on Store Options In Database

Yep. What's your question?

Snapey left a reply on $schedule->job Alway Goes To OnFailure

Did you resolve this?

Snapey left a reply on In A Job, Auth::user() Doesn't Work, But Request()->ip() Does! Why?

It does not matter how the job is stored, its about when the job is serviced.

Are you queuing the jobs and then running them with php artisan queue:work? If not, then everything is being done under the web request.

Snapey left a reply on Store Options In Database

So you now have the questions and answers, you need to store the responses, or at least for each question, if the person gave the correct answer?

Not sure what you are asking for help with?

Snapey left a reply on Auth: LoginusingID Keeping Old User Session Data

Laravel automatically regenerates the session ID during authentication if you are using the built-in LoginController; however, if you need to manually regenerate the session ID, you may use the regenerate method.

https://laravel.com/docs/6.x/session#regenerating-the-session-id

Snapey left a reply on In A Job, Auth::user() Doesn't Work, But Request()->ip() Does! Why?

if you are executing your jobs sync then they are still executed in the same request cycle and the global request helper is still working with the same request

Snapey left a reply on Laravel 6 Which Is The Best Alternate Method Of Laravel Pluck??

the array helper is deprecated, not the eloquent collection method