Snapey

Member Since 4 Years Ago

Mansfield

at Novate / Microlise

Experience Points 1,197,205
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 1044
Lessons
Completed
Best Reply Awards 1705
Best Reply
Awards
  • Start Your Engines Achievement

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • First Thousand Achievement

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • One Year Member Achievement

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • Two Year Member Achievement

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • Three Year Member Achievement

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • Four Year Member Achievement

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • Five Year Member Achievement

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • School In Session Achievement

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • Welcome To The Community Achievement

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • Full Time Learner Achievement

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • Pay It Forward Achievement

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • Subscriber Achievement

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • Lifer Achievement

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • Laracasts Evangelist Achievement

    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 Achievement

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • Laracasts Veteran Achievement

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • Ten Thousand Strong Achievement

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • Laracasts Master Achievement

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • Laracasts Tutor Achievement

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • Laracasts Sensei Achievement

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • Top 50 Achievement

    Top 50

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

21 Mar
15 hours ago

Snapey left a reply on Php Version Problem When Deploying Laravel Project

If these were genuinely different projects then you would have a cpanel for each project and can set the PHP version individually on each project.

This is not going to work if you just put all the 'projects' on the same web server instance.

Snapey left a reply on Php Version Problem When Deploying Laravel Project

when i am developing the project in local i used php 5.6.4 version

"require": {
        "php": ">=5.6.4",

no you didn't. You told composer that php must be greater or equal to 5.6.4 - which 7.2 is !

Snapey left a reply on Php Version Problem When Deploying Laravel Project

You should not consider doing anything with 5.x.x - certainly not adding any new sites.

Even php 7.0 is end of life

Put your application on a new server with php 7.2

Start projects to move or take down all 5.x sites as they are no longer considered secure and definately not supported

Snapey left a reply on Sortable, Variable Loses Value After "stop"

my javascript skills are not that good, so i use a library like dragula.js

at the end of the reorder it issues a callback event with the new sequence

https://github.com/bevacqua/dragula

Snapey left a reply on Laravel Ajax - Put Request 500 Internal Server Error

have you looked in the laravel log file?

20 Mar
1 day ago

Snapey left a reply on Eloquant Relationship Not Working Returning Some Weird $hit

and watch your question titles. I notice that they all show a negative / angry attitude. This is not Reddit.

Snapey left a reply on What Is This Bug In Laracasts? Ironic

It only says 11h for you, it says 5h for me for Jeff it probably says one minute ago.

Not sure why its not been fixed, but its been a known problem for many years, reported multiple times.

Snapey left a reply on Eloquant Relationship Not Working Returning Some Weird $hit

Remember to use get() if you want to execute the query

$members = \App\Course::find($id)->members()->get();

Otherwise you will have a query builder instance

19 Mar
2 days ago

Snapey left a reply on Auth Middleware On A Button

Sorry, I have no idea how a modal is involved. Do you mean modal or model?

Snapey left a reply on Auth Middleware On A Button

you cannot add middleware to a button. You can call a route from the button, then apply the middleware to the route.

If you are using standard Auth then when you hit a route protected by auth and the user is not logged in, then they will be redirected to login

After login, they will be redirected to the page they were trying to reach (the intended() route)

So, if setup correctly, point 2 can happen automatically

Snapey left a reply on Can Store File But Can't Destroy It

you are following the wrong strategy

What does your route look like?

Snapey left a reply on Call To A Member Function SetCookie() On Null On Laravel Middleware

2 things

if (Auth::check()){
 
    etc

then at the end, return redirect. At present you are trying to return a view from the middle of the middleware stack

Snapey left a reply on Can Store File But Can't Destroy It

You are getting a new event in the delete method because route model binding failed.

This could be because you did not pass it in the route, or the placeholder in the route is something other than {event}

Snapey left a reply on Check If Config Item Exists

mark it solved?

Snapey left a reply on AJAX Doesn't Pass Data Even If Status Is 200

nothings going to get past that return false ?

Snapey left a reply on Create:925 Uncaught ReferenceError: Axios Is Not Defined

check your scripts imports in the layout file for the defer attribute

eg

    <!-- Scripts -->
    <script src="{{ asset('js/app.js') }}" defer></script>

You might need to wrap your javascript in window.load()

Snapey left a reply on Can Store File But Can't Destroy It

Are you passing valid eventID in the delete route?

dd($event) at the start of the controller.

Snapey left a reply on Fullcalendar Populate Event

@dhanamanjuri please start a new question with your problem

Snapey left a reply on Can't Unserialize My Address

As you are in a loop, you ,might be trying to unserialize null

Is this any better

        foreach($orders as $order)
        {
            if(($order->address) {
                $address = unserialize($order->address);
            } else {
                $address=[];
        }

Snapey left a reply on Convert From Collective

I would change it to

<input type="checkbox" name="permissions[{{$permission->id}}]"" value="{{$permission->id}}">

So that each checkbox has the id of the permission in the returned data.

Snapey left a reply on Query Returning Wrong Results

Your question is confusing. You say you want courses where the id is not the current user, but then you query for courses where the user IS the current user.

You want the user's courses then it should be just

$courses = Auth::user()->courses()->get();

If you want the user's courses with the number of modules on each course;

$courses = Auth::user()->courses()->withCount('modules')->get();
18 Mar
3 days ago

Snapey left a reply on Convert From Collective

still a problem?

Snapey left a reply on Come On Laravel There Has To Be A Way To Do This The Right Way...

Do you have relationships setup between all of the models?

17 Mar
4 days ago

Snapey left a reply on Registration Create Methode Undefined Index

try null coalesce operator

protected function create(array $data) 
{ 
    return User::create([ 
        'Type_compte' => $data['Type_compte'],
        'district' => $data['district'] ?? null;
        'email' => $data['email'],
        'password' => Hash::make($data['password']),
         ]); 
}

Snapey left a reply on Blade - Map Database Values And Show In View

https://laravel.com/docs/5.7/eloquent-mutators#accessors-and-mutators

You probably have the right solution, but another option is

in your model;

public function getFieldStringAttribute()
{
    switch ($this->field) {
        case 'FromName':
            return 'From Name';
        case 'ToName':
            return 'To Name';
        case..... etc

}

Then in the view {{ $rules->fieldString }}

but nikos probably gives best advicein this case

Snapey left a reply on Blade - Map Database Values And Show In View

Or use model accessors?

Snapey left a reply on Variable Accessible In All Views

Lesson to all, dont get into a heated discussion with your partner in the middle of posting some response

Snapey left a reply on Variable Accessible In All Views

with the view share wrapped in an auth check, then if the user is a guest then the variable will not be set and you get the error you see.

Either set an empty variable in your view composer or take care of it in your view.

But tbh, i would just make this an accessor on the User model so that anywhere you can just do Auth::user()->member_since

This is a lot clearer to anyone looking at your code where this variable is generated

16 Mar
5 days ago

Snapey left a reply on Logging Generally And Changes From 5.6 To 5.7

You can add a permissions property to the daily section of the logging.php config file

        'daily' => [
            'driver' => 'daily',
            'path' => storage_path('logs/laravel.log'),
            'level' => 'debug',
            'days' => 14,
            'permission' => 0664,
        ],

or you can just switch back to single.

Snapey left a reply on Auth::attempt Method Always Bind With Users Table?

config file auth.php has a section where the User model is defined as being responsible for the user provider

Snapey left a reply on Laravel And Permissions On Centos

its not just about the permissions, its also about who owns the files and folders

I use the following to set ownership and permissions

chgrp -R www-data $DEPLOYMENT_DIRECTORY/storage $DEPLOYMENT_DIRECTORY/bootstrap/cache
chmod -R ug+rwx $DEPLOYMENT_DIRECTORY/storage $DEPLOYMENT_DIRECTORY/bootstrap/cache

replace $DEPLOYMENT_DIRECTORY with the path to your deployment or remove it.

Snapey left a reply on Error When Trying To Update User E-mail

please mark it solved

Snapey left a reply on Error When Trying To Update User E-mail

Because your resource is 'Setting'

If you run php artisan route:list you will see that the resource route is expecting a route parameter of {setting}

PUT|PATCH | settings/{setting}      | settings.update 

You are trying to inject User model, but Laravel has no way to know that what you pass in the route has anything to do with users

If you want to use resource route then change controller;

public function update(Request $request, $setting)
    {
        $request->validate([
            'newEmail' => 'required|email|max:25'
        ]);

        $user = User::find($setting);
        $user->email = request('newEmail');
        $user->save();

        return redirect()->route('settings.index')->with('status','Profile updated');
    }

Snapey left a reply on Expected Remember_me Functionality

Just correcting myself, when you logout, the remember_web_* cookie is cleared from the browser

Snapey left a reply on Remember_me Token Not Being Set

When you login, do you have anything that could be stopping the request cycle?

The cookie is queued, but then sent in the terminable middleware. if you dd() somewhere then the cookie is not delivered.

I see a cookie set called remember_web_ + random sequence

Snapey left a reply on Error When Trying To Update User E-mail

Well thats not passing the id at all. You are just using the current logged in user.

This will only change the id of the current user.

Infact you are doing it twice. Get the user, get his id, find the user that you already have using the id.

Snapey left a reply on Error When Trying To Update User E-mail

Something wrong with the URL, you are not passing the user.

As requested,

What does your route look like?

Snapey left a reply on Error When Trying To Update User E-mail

What does your route look like?

Snapey left a reply on Error When Trying To Update User E-mail

Actually, I think the problem is that you are not passing in the correct user to thr route, so route model binding fails and $user ends up being a new user instance.

You will see on your sql that it is doing an insert rather than update...where etc

Snapey left a reply on Error When Trying To Update User E-mail

Your user does not have a name and you have not set the name field as nullable in the database.

Not sure how you managed to create the user in the firstplace?

15 Mar
6 days ago

Snapey left a reply on Converting Array Of Address Parts To A String

sprintf would work fine (as per my example above), but if missing parts is an issue, I would write some functions in the model to handle the concat


private function f_address()
{
    return $this->address1 . '  ' . $this->address2 . ', ';
}

private function f_city()
{
    return $this->city ? $this->city . ', ':'';
}

private function f_statePostal()
{
    return $this->state . ' ' . $this->postal_code;
{

public function get_address_attribute()
{
    return $this->f_address . $this->f_city . $this->f_statePostal;
}

Snapey left a reply on Converting Array Of Address Parts To A String

probably use sprintf, but what if some parts are empty?

Snapey left a reply on How To Restrict/limit Resource Edit Without An Login System?

so only the creator can edit the resource?

How could you do that when every request is anonymous

Snapey left a reply on Expected Remember_me Functionality

Thats the same as my understanding. The only thing to add is that if you logout the servers copy of the rememberMe token is deleted so that next time you connect you are forced to login.

Snapey left a reply on Throw New MethodNotAllowedHttpException($others)

You might be getting an error because of the route that loaded this form.

When you get a validation error, it will do a GET of the previous URL. If the previous URL was as a result of a POST then you can break the request because the framework does a GET of the previous URL

I don't know what came before, but if you return a view as a result of a POST then this could be the issue. Always finish a POST request with a redirect and never return a view.

Snapey left a reply on Throw New MethodNotAllowedHttpException($others)

what field are you talking about that might be empty?

Snapey left a reply on Accessing Token Based API Route Via Vue/Axios

Vue runs in the browser. All is visible in the html / javascript.

Snapey left a reply on Run A Method Or Command When A Row Is Expired.

With cronjob yes, you fire the scheduler every minute, it decides no, its not 00:00 yet so do nothing.

You then create a job that checks publication dates and only runs 'daily'

The better alternative is to create a scope that only allows documents to be indexed or shown if their expiry date is greater than today.

Snapey left a reply on Trying To Get Property Of Non-object

'Nothing work' .. what, do you even have electricity? have you switched the computer on? Are there any characters on the screen?