shez1983

shez1983

London

Member Since 3 Years Ago

Experience Points 89,605
Experience
Level
Lessons Completed 226
Lessons
Completed
Best Reply Awards 86
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.

17 Jan
22 hours ago

shez1983 left a reply on Getting Common Methods Outside Controller

move it to a general helper class. then autoload it using composer

 "autoload": {
        "files": [
            "app/Helpers/helpers.php"
        ]
    },

or you can use namespace and use it normally...

the best way would be to create a trait or extend your models where you do something like

 /**
     * The "booting" method of the model.
     *
     * @return void
     */
    protected static function boot()
    {
        parent::boot();

        static::saving(function ($entity) {
          $entity->slug = Str::lower( Str::slug($title, '-') );
        });
    }
16 Jan
1 day ago

shez1983 left a reply on Flox - Self Hosted Movies, Series And Animes Watch List

@sirudkalra is this your attempt at posting spam/illegal sites?

15 Jan
2 days ago

shez1983 left a reply on Laravel Ajax POST Is Not Working Properly

so what do you get in console.log?

14 Jan
3 days ago

shez1983 left a reply on Can't Use WhereBetween On A Collection (method Not Found)

it might be moaning at the second whereBetween if it is indeed a collection you are working on..

it is far easier to do this manipulation/search on DB side then after getting your results...

shez1983 left a reply on Laravel API Resources Extremely Slow

Hey level 1 - 870 records.. doesnt sound a lot - and pagination doesnt HIDE The problem it is the solution.- unless you are doing something unique - no one would take a look at all 870 records in your table - so you are wasting precious CPU time.

in any case if you could post some code (your controller & blade & db migration)

shez1983 left a reply on Problem In Uploading Laravel Application.


    netwroksoluiton is the largest and the best web hosting at the world .

really? where are the stats for this? and as for being best but not supporting latest tech - i would question their definition of best!

have you contacted this best web hosting? as a best web hosting i am sure they would cater to your request..

shez1983 left a reply on Paid Laracast Tutorials?

@KUNS25 - maybe - but i only said it as a joke.. as its laracast forum..

shez1983 left a reply on Models Vs Services Vs Repositories

its all well and good giving/using examples such as dbRepo / fileRepo - but how many times in reality will anyone switch from DB to using file?

For me - i generally use repository pattern unless an entity 'modifies' other entities - in which case SERVICES come into play.

shez1983 left a reply on Laravel API Resources Extremely Slow

is your table indexed properly? how many records do you have currently?

also for an index() people generally use the paginate() instead of all() as it makes more sense.. and as you haev found is slow -

also all these issets() instead of that look into the default() relationship OR you can just do

optional($this->user)->fullname..

shez1983 left a reply on Paid Laracast Tutorials?

meh - codecourse is better ;)

11 Jan
6 days ago

shez1983 started a new conversation Caching And Repository Pattern Libraries/packages?

Does anyone have a good package they use for caching and for repository pattern?

For repository pattern i find it confusing to use a package which just have find() all() etc etc but i still need to create my own convulated function like getAllLessonsWithXYZ().. which i think it makes the files look ugly :/

shez1983 left a reply on Can't Access Protected Property

are you sure there ARE individual goals for the campaign?

shez1983 left a reply on How Could I Turn This Array Into A Collection To Be Able To Use Collection Functions?

those are basic functions - check the docs - your thread title is misleading..

09 Jan
1 week ago

shez1983 left a reply on Migration Of Laravel Data

it all depends on the db of this other app - you will have to write a script that gets triggered..

shez1983 left a reply on How To Create Auto Sequential Number With Prefix

how many 0s do you want? what happens when the number gets to 10000 do u now want an extra 0 in front?

and just why??

btw if its an int - your db will NEVER store the 0 in front.. as it doesnt make sense.. you COULD however create an accessor in Laravel that appends 0...

shez1983 left a reply on Undefined Variable: ProductsAll

just a note saying $products will suffice - you dont need to add ALL to it.. it has no meaning,..

also you can just do view('index', compact('products'));

shez1983 left a reply on Gift A Subscription

yeah and if you want to gift me a subscription let me know.. ;)

08 Jan
1 week ago

shez1983 left a reply on Migration Of Laravel Data

laravel instance? you mean another laravel app? if the structure is the same you can just export database and import it in the new place.

06 Jan
1 week ago

shez1983 left a reply on Apply Middleware Based On Route Parameters

/videos?myvideos=1 isnt a filter - search params are different and are indeed filters - dont treat this as a filter.. most people have two routes

videos/?cat=1&lang=en...

and user/id/videos...

however you can have a middleware on that one route which checks what get query is being performed ie if it has myvideos and then check if user is authenticated or not.. the other thing is if you have myvideos=1 surely in your controller you would have something like :\ Auth::id() or \Auth::user()->id.. so you could do an if check there to see if there is a logged in user..

05 Jan
1 week ago

shez1983 left a reply on Best Approach To Sanitising API Requests?

yeah pretty much - as long as you dont do soemthing like:

DB::insert('insert into xxxxxx. $request->name') then you should be ok..

shez1983 left a reply on Apply Middleware Based On Route Parameters

/videos?myvideos=1. should be renamed as users/me/videos. or users/{id}/videos

shez1983 left a reply on Dd(Auth::user()->id); Is Not Giving Logged In User Id

in your base controller's construct (if you want this to be available to all controllers otherwise in that controller) do something like this:


    /**
     * ClientController constructor.
     */
    public function __construct()
    {
        $this->middleware(function ($request, $next) {
            $this->client = Client::find(\Auth::id());
            return $next($request);
        });
    }

shez1983 left a reply on Error In Migrate

i think it might be the fact that default name it creates for the index is too big translations_table_name_column_name_foreign_key_locale_unique

so what you can do is pass a 2nd arguement to the unique() and give it a custom name..

shez1983 left a reply on Best Approach To Sanitising API Requests?

form requests dont SANITIZE input they just validate -

Laravel by default sanitizes data if you use the DB:: or ELoquent to insert/update into database.

if you want to do it manually - i would create a middleware that sanitizes the request (check out laravel's middleware for triming white space from Request input ) to see how they manipulate the form requests.

shez1983 left a reply on Object Of Class App\DeliveryAddress Could Not Be Converted To Int

@helpmyworld you did ignore him - he specifically said not to use count but you ignored him.. you mighty still be learning but no one who is learning ignore tips.

shez1983 left a reply on Created_at But No Updated_at Column

sure - mine is quicker though and more eloquent but whatever...

04 Jan
1 week ago

shez1983 left a reply on Catching Errors With Stripe?

this seems fine but you may want to have multiple catch to catch different exceptions that can be thrown..

shez1983 left a reply on Created_at But No Updated_at Column

i already gave you the answer i think - but in your model you can have use protected $casts = [ 'created_at' => 'datetime:Y-m-d', ]; to tell it what each column is

shez1983 left a reply on Feature Test Always Gets 'session Expired' Message

i have never needed to do Session::start().. which makes me think you might need to add the session middleware in the web array in app/http/kernal

 protected $middlewareGroups = [
        'web' => [
            EncryptCookies::class,
            AddQueuedCookiesToResponse::class,
            StartSession::class,  //// <<< this one i think 
            // \Illuminate\Session\Middleware\AuthenticateSession::class,
            ShareErrorsFromSession::class,
            VerifyCsrfToken::class,
            SubstituteBindings::class,
            SetDefaultUserTypeForUrls::class,
            SetLocale::class,
            CheckUserHasOnBoarded::class,
        ],

        'api' => [
            'throttle:60,1',
            'bindings',
        ],
    ];

but i see that it is already there by default - so i am not really sure why you need to add that but it does look like your session isnt starting,.

shez1983 left a reply on Object Of Class App\DeliveryAddress Could Not Be Converted To Int

@helpmyworld snapey already gave you some tip - and yet you ignored him..

you need to learn about Laravel i see - just putting all procedural code in a controller isnt the right way.. i just hope you arent doing this for work..

  1. your variables names use different syntax cameCase vs snake_case..
  2. old school validation - you havent heard of requests?
  3. unuseful/meaningless variable names..
  4. repeated code that can be Dried up

shez1983 left a reply on RAM Memory Is Constantly Growing On The Server.

i mentioned your local or staging servers? did you test on there

shez1983 left a reply on "may" HasOne Relation

you usually still just do this->hasOne()

but then you can add ->withDefault() if you want to so in your blade $user->referrer->name will work..

else you just have to do if/elses..

shez1983 left a reply on Feature Test Always Gets 'session Expired' Message

what i meant was open up your verifyCSRF middleware and theres an except property.. add in '/login' and then see what happens..

shez1983 left a reply on Feature Test Always Gets 'session Expired' Message

can u add login to middleware and see if that helps? ideally you shouldnt but i just want to see where the error is...

shez1983 left a reply on Slug Route

@x-mac yeah - what you need to do is when you save the model make sure the slug column has both the id & artcle name saved as the-article-123

you will probably need to use https://laravel.com/docs/5.7/eloquent#events in your models boot method to keep it in sync..

shez1983 left a reply on Cart

what you need to remember is that when you post question you need to help us help you i.e. give more info than a one sentence - we do not know what codebase you are using - i thought it might have been wordpress/magento etc.. we also are not going around looking at all your threads to make sense of what you are doing..

03 Jan
2 weeks ago

shez1983 left a reply on Feature Test Always Gets 'session Expired' Message

that makes sense but then i dont see why YOU get a session expired... what is your phpunit.xml look like? & for fun if you add in login to verifyCSRF middleware does it work?

shez1983 left a reply on Filter Many To Many Relationship

set up the relatoionships (belongs to many)

then use whereHas() on the relationship with a closure that checks what tags post is associated with...

shez1983 left a reply on Slug Route

then you cant use the slug to find an article ;) -

02 Jan
2 weeks ago

shez1983 left a reply on 403 When Using Resource Controller

maybe its @method('PATCH') instead of put?

shez1983 left a reply on Email Not Sent Using Laravel Queues

so surely you have found your answer - that pdf doesnt exist.. so you are creating it wrongly or referencing it wrongly

shez1983 left a reply on Laravel Dusk LoginAs Not Working / Using Sqlite DB

i think when you RUN dusk watch your root folder where .env is and you will see dusk creating a new .env.dusk (or something) for the duration of test - i think you just need to make one yourself and laravel will use that - check docs for dusk

shez1983 left a reply on Group Records By 30 Minutes + Start It From 08:00 Til 07:00 ( 24 Hours )

well you are using HOUR to group by - you need to use MINUTE? i think there's a SQL function for minutes

shez1983 left a reply on Render PDF From Storage In View Asynchronously

try it? it should work -

shez1983 left a reply on Feature Test Always Gets 'session Expired' Message

laravel has a test to check that its inbuilt login functionality works - if you go to github -> tests and see how it does it.

I know why you are getting this because normally to post you need a CSRF token which you dont have.. actually i have looked at my test

$user = factory(User::class)
            ->states('client')
            ->create();

        $this->post('/login', ['email' => $user->email, 'password' => 'secret'])
            ->assertLocation('/clients/dashboard');

and i dont have anything about CSRF even in the verifyCSRF middleware :/

shez1983 left a reply on Route Model Binding Returns Empty Model

do you have a soft deleted trait? thats the only thing i can think of - also install debugbar or 'listen' to the queries (check the doc) - to see what query laravel is doing and do that in your DB directly

01 Jan
2 weeks ago

shez1983 left a reply on Email Not Sent Using Laravel Queues

whats in your .env file with regards to email?

have you looked into your Database faile_jobs table to see if you get an error?

also to debug i would comment the implements ShouldQueue in Job Application and in .env set it to sync to see it working on demand ie as soon as you hit the controller and once working queue it after..

the other thing is you can just as easily send the EMAIL from controller instead of creating a job which triggers the email - i think thats just extra headache.. also the $data you create in controller should be part of Mail - you should pass in relevent data ie JobApplication($vacancies, $recipient...).

shez1983 left a reply on Installation Fail

whats the error you are getting?

you can manually create an .env file on your server and then run composer install manually

shez1983 left a reply on Error: “Object Of Class Closure Could Not Be Converted To String” While Using A Factory In Laravel

you are supposed to return an ARRAY in that closure not an object -

the way you are doing this is wrong you need to move all this code to a SEEDER file (db/seeders/anything.php) and then do php artisan db:seed --class=className

(now i am not sure if class name suffices so you might have to put in NameSpaced Path of seeder file)

check seeding/factory docs on laravel

shez1983 left a reply on RAM Memory Is Constantly Growing On The Server.

are you saying if you take this script off then the memory doesnt increase?

JS unless 'talking' to your server shouldnt affect it and from that script i dont think it does unless i am missing something..

does the same happen in your local env or staging?