Snapey

Snapey

at Novate / Microlise

Mansfield

Hire Me

Member Since 4 Years Ago

Experience Points 1,077,755
Experience
Level
Lessons Completed 974
Lessons
Completed
Best Reply Awards 1546
Best Answer
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.

13 Nov
15 hours ago

Snapey left a reply on Foreign Key Data Retrieve Showing Error In Laravel

I don't follow.

You are listing the details of the current user only

Why would you want to put a where condition?

Sorry, I know language is not making this easy. Just to be clear, your query is for one user or for ALL users?

Snapey left a reply on Manually Authenticating Users And Ban Function Not Working

Direct from the Docs

Specifying Additional Conditions

If you wish, you may also add extra conditions to the authentication query in addition to the user's e-mail and password. For example, we may verify that user is marked as "active":

if (Auth::attempt(['email' => $email, 'password' => $password, 'active' => 1])) {
    // The user is active, not suspended, and exists.
}

which is exactly what you are doing?

I would check the SQL query being performed at login check and see if it is even using your code.

Laravel Debugbar may help in this regard.

12 Nov
1 day ago

Snapey left a reply on Manually Authenticating Users And Ban Function Not Working

is your status column an integer or string? in your tinker response, the status value is quoted, "1"

If you quote the parameter in the attempt call it will probably work, but if I were you I would go back to calling it active and change it to a boolean column and then you can just use true or false

Snapey left a reply on Laravel 5.7 Email Verification

yes, it seems wrong more often than not, but there's nothing to stop you doing it your own way

Snapey left a reply on All Problems With The New Laracasts Design

@jeffreyway any chance of getting the Updated flag back again?

Really useful on the 'My Participation' page as people often don't tag us in the reply.

Snapey left a reply on Manually Authenticating Users And Ban Function Not Working

Please, do as suggested;

open tinker and check this

>>> User::find(1)->active

replace record number with a user that has active set and repeat for a user with it unset

Snapey left a reply on Foreign Key Data Retrieve Showing Error In Laravel

Put your model back as seeker_id if you like.. that is not the issue

Put in controller

 $user = Auth::user();     

        $user->load(['edu','language', 'certification']);  

        return view('Job-seeker.account-info')->withUser($user);


then in view, now you only have one user model with relations loaded, so

    @foreach($user->edu as $edu)
         <h4>{{ $edu->education }} - {{ $edu->course_or_board }} - {{$edu->specialization_or_medium }} @ {{ $edu->institute }}</h4>   
    @endforeach

so get rid of the outer loop. No need for it now you only have one user (the logged in one)

11 Nov
2 days ago

Snapey left a reply on Why Did Not Delete Data Table Records In Laravel 5.6

Please change your delete into a form. You should NEVER delete anything with GET request.

http://novate.co.uk/restful-delete-with-laravel/

Snapey left a reply on Why Did Not Delete Data Table Records In Laravel 5.6

@munazzil

how is this

DB::table('vehicles')->where('id', $id)->delete();

any different to what you posted?

\DB::table('vehicles')->where('id', $id)->delete();

Apart from the \ before DB which is not required if the class is imported, and would show an error if it were not correct?

Snapey left a reply on How To Prevent Multiple Database Queries

Why would you just not do

$active_customers = Customer::active();

Snapey left a reply on Why Did Not Delete Data Table Records In Laravel 5.6

And what happens when Google crawls your site?

Never delete records using GET

10 Nov
3 days ago

Snapey left a reply on Blade In Vue

Is the vue code in a .vue file or in a blade.php file?

Snapey left a reply on If IsActive Middleware Return False I Can't Login With Different User Until Delete Cookies

You registered 'is.active' as middleware

Where do you use it?

Snapey left a reply on If IsActive Middleware Return False I Can't Login With Different User Until Delete Cookies

So that worked as expected then...

Try to see which path it is taking in your middleware

    public function handle($request, Closure $next)
    {
        if (Auth::check()) {

dump('authenticated');

            if (!Auth::user()->isActive()) {

dd('notActive');

                return redirect('/')->with('nonActive', 'Налог није активан');
            }
        }

dd('Thinks they are active');

        return $next($request);
    }

Snapey left a reply on Need A Little Help Understanding The Generated Controllers With Resource

You can set getRouteKeyName on the model if you want to use a field other than id to resolve models.

https://laravel.com/docs/5.7/routing#implicit-binding

Snapey left a reply on Name Attribute Exhausting PHP Memory

Well

a) running a query inside an accessor is a bit of a code smell

b) returning html from your model positively stinks.

You might want to install Laravel Debugbar and check how many database queries you are running.

Snapey left a reply on Foreign Key Data Retrieve Showing Error In Laravel

Then you cannot do this;

 <h4>{{ $user1->edu->education }} - {{ $user1->edu->course_or_board }} - {{$user1->edu->specialization_or_medium }} @ {{ $user1->edu->institute }}</h4>   

because as you have said, edu will be a collection, so you need another foreach loop

@foreach($user as $user1)
    @foreach($user1->edu as $edu)
         <h4>{{ $edu->education }} - {{ $edu->course_or_board }} - {{$edu->specialization_or_medium }} @ {{ $edu->institute }}</h4>   
    @endforeach
@endforeach 

but, sort your query out for the user and you won't have a collection of user and won't need the outer foreach loop

Snapey left a reply on Why Did Not Display Latest Updated Record From The Table In Laravel 5.6

No, more like

public function scopeadvertise($query)
{
     return $query->where('adtype',1);
}

and then you only have this bit of code in one place

Snapey left a reply on All Problems With The New Laracasts Design

I edited my post. Affects touchscreen.

Snapey left a reply on Foreign Key Data Retrieve Showing Error In Laravel

Surely user hasOne edu? Not hasMany

Snapey left a reply on Can't Seem To Get My Eloquent Model Working

Your subjects table has a level_id column?

Snapey left a reply on Can't Seem To Get My Eloquent Model Working

Sorry, not woken up yet. It should be ->get() when using the query builder

Snapey left a reply on Get Content Of Textarea In A Txt File

Well this site has LOADS of lessons to help. Many free. I see you have not completed any so far.

By the way, you are ALWAYS using php, just with the help of Laravel classes and helpers.

Snapey left a reply on Can't Seem To Get My Eloquent Model Working

Eager load your Levels in the controller

        $subjects = Subject::with('levels')->all();
        return view('subjects.index', ['subjects' => $subjects]);

Snapey left a reply on Get Content Of Textarea In A Txt File

Yes there are laravel tools to allow you to abstract your code from the storage medium, especially if you might decide to not store on local public drive but instead, in the cloud.

There is a section https://laravel.com/docs/5.7/filesystem#storing-files

Snapey left a reply on Can't Seem To Get My Eloquent Model Working

OK so that looks alright. The problem is probably that you have a Subject that is not assigned to a Level.

You should code for this possibility with the null coalesce operator anywhere you have more than one arrow

    <td>{{ $subject->level->title ?? ' - '}}</td>

Snapey left a reply on Foreign Key Data Retrieve Showing Error In Laravel

Also, if you have the user already, you can use load to pull in relations

$user = Auth::user();

$user->load(['edu','language', 'certification']);
 

Snapey left a reply on Foreign Key Data Retrieve Showing Error In Laravel

Not sure what this is doing

$users= User::orderBy('created_at','desc')->where('id', '=', auth()->id())->get();

You appear to want users (many of them) but then you are limiting it to the current user only?

Snapey left a reply on Can't Seem To Get My Eloquent Model Working

You get the data in a controller. We need to see what is there please.

Snapey left a reply on Can't Seem To Get My Eloquent Model Working

so you are not actually retrieving a subject. You dont show that code.

Snapey left a reply on Foreign Key Data Retrieve Showing Error In Laravel

if you want to use magic with methods, you need to uppercase ther first letter of the variable

->withUsers($users);

Snapey left a reply on How To Use Progress Bar Based On The Filled Form In Laravel Project?

check the browser source and see what is actually being rendered

Snapey left a reply on Can't Seem To Get My Eloquent Model Working

{{ $subject->level->title }}

Snapey left a reply on Why Did Not Display Latest Updated Record From The Table In Laravel 5.6

you cannot have a route for just part of a page unless you load it with ajax

If you want to see a slider of other vehicles whilst showing vehicle 23 then you need to add your slider data to the show method or use a view composer

View Composer: https://laravel.com/docs/5.7/views#view-composers

Scopes: https://laravel.com/docs/5.7/eloquent#query-scopes

Snapey left a reply on Can't Seem To Get My Eloquent Model Working

public function level() {

        return $this->belongsTo('App\Level');
        
    }

Snapey left a reply on All Problems With The New Laracasts Design

Im thinking the modal for replies is more trouble than its worth. When open, its not possible to select any text from the thread. Cancelling loses all typed so far. Could do with a way to close the modal but retain the content, then open it again and carry on

Snapey left a reply on Why Did Not Display Latest Updated Record From The Table In Laravel 5.6

If you want the adtype==1 then you need a where statement

$vehicles = Vehicle::with('uploads')
            ->where('adtype','=',1)
            ->latest('updated_at');

ideally you would not have magic numbers like this scattered through your code, you would create a scope on your model

$vehicles = Vehicle::with('uploads')
            ->paidAdverts()
            ->latest('updated_at');

or similar depending on what '1' actually represents

Snapey left a reply on How To Use Progress Bar Based On The Filled Form In Laravel Project?

its just an attribute?

$user->progress_value += 14;
$user->save();

Snapey left a reply on Verify Email After User Updated It - Laravel 5.7

clear the verification date on the user model, then call

$user->sendEmailVerificationNotification();

Snapey left a reply on Get Content Of Textarea In A Txt File

file_put_contents()

(php)

Snapey left a reply on How To Using Mysqli Num Rows In Laravel

please mark the best answer

Snapey left a reply on Name Attribute Exhausting PHP Memory

always be very careful using with in your models. It is more trouble than its worth in my view since it leads to recursively loading children until you run out of memory

09 Nov
4 days ago

Snapey left a reply on Name Attribute Exhausting PHP Memory

Using with() in one of the models?

Snapey left a reply on Column Not Found: 1054 Unknown Column '0' In 'field List' (SQL: Insert Into `product_order` (`0`, `order_id`, `product_id`) Values (172, 21, Price))

Not quite sure what you are trying to do there.. Attach is to join one model to another but you appear to be trying to do it with an array?

Snapey left a reply on Laravel - Making A HasManyThrough Relationship Provide A Unique Collection

Why bad? It requires a model to do a where on.

Ordinarily you would do the where on the caller not in the relationship?

as in

$delivery = Delivery->with('deliveryContainers')->find(1);

//or 

$containers = $delivery->deliveryContainers()->get();

//rather than

$delivery = Delivery->with('stockMovements.deliveryContainers')->find(1);

//or 

$containers = $delivery->stockMovements()->deliveryContainers()->get();

Snapey left a reply on Observer Column Update IsDirty Or WasChanged

My understanding is that a dirty model needs saving but a changed model has been saved with new values.

Snapey left a reply on In Regards To Uploading File In Laravel

two of my suggestions were correct then? ;-)

Snapey left a reply on Laravel - Making A HasManyThrough Relationship Provide A Unique Collection

Your relationship should not have the ->where statement