shez1983

shez1983

Member Since 3 Years Ago

London

Experience Points 96,435
Experience Level 20

3,565 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 226
Lessons
Completed
Best Reply Awards 95
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.

10 Jul
1 week ago

shez1983 left a reply on Laravel 5.8 Memory Leak

if you need to process that many records:

  1. use chunking
  2. use RAW SQL (do the joins yourself to get relationships).
25 Jun
4 weeks ago

shez1983 left a reply on Laravel Cashier Prevent Multiple Same Subscriptions.

you can disable the button until you get a response back from first call.

24 Jun
4 weeks ago

shez1983 left a reply on Maximum Function Nesting Level

code? a recursion/loop gone wrong..

19 Jun
1 month ago

shez1983 left a reply on Architecture - Process Queue On Trigger

for your example it would need to be saved in the database. for example have a button that says 'i want access to secure file' - this needs to be translated into a database table somehow.. with a status of pending.. you log in as admin and if you approve this.. you then create a job (queueable) which triggers the download which gets sent to the user..

shez1983 left a reply on How To Create A Pin Like Passsword?

instead of creating another auth system ie pin.. for some action you can simply ask the user to INPUT his password again..

shez1983 left a reply on How To Change Password?

your code works - all you need to do is issue a save command...

also you are doing an unecessary user::find... you already have auth user... :/

shez1983 left a reply on Data Model Property In API Resource, How?

instead of doing all this why not just name the field from data to something else? or change the name of the wrapper from data to something else..

15 Jun
1 month ago

shez1983 left a reply on How To Update Field Without Primary Key In Cakephp2?

usually an update only returns true or false.. :/

shez1983 left a reply on Multi Relation Foreign Keys

surely this should work? what you have already i mean. if someone deletes user, it will delete conversation & then messages...

in some case you could use events/observers too..

07 Jun
1 month ago

shez1983 left a reply on How To Protect API Route From Flood

is it really an api or just a normal form? if api - you can have a throttle middleware. if normal form then you can check the ip and store it the first time user enteres an email - and then block him from doing so again.. you could also verify emails are real using an external service.

23 May
2 months ago

shez1983 left a reply on Using FormRequest Safely

if you are adding request data to a model. then use its fillable property to define data you want - there should be no case where someone can add a random data that you would NEED it..

if you wanted to do that create an after validation hook and match the request with a model/db column and return an error if anything extra was added

shez1983 left a reply on Laravel 5.9 Wish List

@ROBSTAR - automatic caching... ie what some packages out there do it automatically so you dont have to write

cache::remember()... and the nhave to cache::forget()....

shez1983 left a reply on Create If Not Exist

@bedds thanks for bringing up a really old post ....

What would be the best way to add if only new record, and if already exists, redirect and add message "Already in the system"?

this is what he said.. with firstOrCreate he wouldnt have got an error... a redirect etc.. it would have just returned the existing record...

shez1983 left a reply on Single Code Base - Multiple Projects

split your code up in packages - then use them in each smaller project as needed. that way updating will be nice and easy.. your deployment would need some work though.

If there isnt too much differences between sites then i would say multi-tennancy but i dont know much about your project etc.

We had this same dilemma we were going to create 5-6 similar looking sites. we chose to use package system purely because it would give us the ability to keep db design/code relatively simple.. with multi tennancy because of the unknown the code might have become too complex..

14 May
2 months ago

shez1983 left a reply on Using FormRequest Safely

with form request it validates things according to rules specified by you - so you may need to add/create some more.. because if you see bad data in your controller than means your validation rules need modifying - basically until all validation rule pass laravel will not go to the controller function..

NOTE form request DOESNT filter spam or check whether a value is some sort of hacking attempt etc..

12 May
2 months ago

shez1983 left a reply on Cannot Apply Css To Blades

what you can do is look at the view source in your browser & see what path gets rendered and then work it out..

11 May
2 months ago

shez1983 left a reply on Where Should This Code Go??

you could create HELPER function (in a helper file), you could also create a static method on ROLE model, you could also create a global function..

shez1983 left a reply on Where Can I Modify The Email Verification?

come on man - you open that file and theres a TRAIT that class uses.. open it up. you will have to override its functions if this is something you are wanting to do

shez1983 left a reply on Change ID-->Name In URL

usually people will have slugs instead of name as they look more URL friendly..

you can do route model binding and then define the route binding key to be slug. all info is in documentation

shez1983 left a reply on Cannot Apply Css To Blades

usually you compile your css to public/css and then link it using {{ asset('file.css') }} - if you are not compiling then put your CSS in public/folder..

09 May
2 months ago

shez1983 left a reply on Modify Data After Query Before Sending To Front-end

@movepixels i already gave you two options to do it on the laravel side... i m not sure what more you are expecting?

08 May
2 months ago

shez1983 left a reply on How To Improve The Speed Of A Laravel Page That That Queries For A Large Amount Of Data

without seeing the said code/query hard to suggest but

  1. FK/Indexes
  2. De-normalising sometimes help
  3. using RAW SQL ie DB::Select() instead of Eloquent usually helps
  4. caching also helps..
  5. if the job doesnt need to run straight away queues/jobs will work too

shez1983 left a reply on Modify Data After Query Before Sending To Front-end

basically you can do some calculations using MYSQL so i can do select 1+1 and it will give me 2. silly example but you get the idea -

You can google for MySQL func that you can use to get an extra COLUMN called age or whatever..

Another way (although MYSQL is preferred) is:

  1. create an accessor in the model public function getAgeAttribute() { // return blah; } and in blade you can do $model->age

  2. i was going to say you can append a value (but only if when model is being JSONed) you do that by adding an append property to model public $appends = ['age']; and pretty much do 1 above..

as for hiding it instead of doing select *, choose columns you want but be aware if you use one of the solutions above instead of MySQL. you MUST select the dob column as well otherwise value will be null and the logic will not work

shez1983 left a reply on BCC In Mailable Not Working?

aah yeah i sort of realised what the issue was after doing some debugging.. damn that is a silly thing..

shez1983 started a new conversation BCC In Mailable Not Working?

So i had a mailable which was already working - my client asked to be BCC into all emails. now after adding

 return $this->subject($mail['subject'])
            ->bcc(\App\Setting::get(\App\Setting::EMAIL))
            ->view($mail['view']);

the BCC isnt working? i cant seem to see an email going out? in the Mailable Parent class i have logged emails being added and the BCC email IS being added.. :/

 protected function buildRecipients($message)
    {
        foreach (['to', 'cc', 'bcc', 'replyTo'] as $type) {
            foreach ($this->{$type} as $recipient) {
                $message->{$type}($recipient['address'], $recipient['name']);

                info($recipient['address'] . ':' . $recipient['name']); /// HERE 
            } 
        }

        return $this;
}
07 May
2 months ago

shez1983 left a reply on Is It A Good Idea To Start Learning OOP With Laravel ?

i am not sure learning laravel with Jefferey way tutorials will necessary teach you OOP - its a shame really, he does have specific OOP oriented lessons but in laravel tutorials those arent acted on afaik.

06 May
2 months ago

shez1983 left a reply on Create BookItem

whats a barcode? are you saying all different book copies have different barcodes? i would just add a qty to the book to signify how many copies you have..

03 May
2 months ago

shez1983 left a reply on Do I Need Cron To Use Schedulers On Homestead?

ssh into your server and do crontab -l to check whether cron is working as expected

shez1983 left a reply on How To Use The $loop Variable In A Controller?

i dont think you can.. if you want a counter just create a variable outside of foreach e.g $counter=0; and then increment it inside the foreach alternatively you may use for($i=0...) loop instead

27 Apr
2 months ago

shez1983 left a reply on Test Database With Multiple Databases

i think you just need to add

DB_SRV_CONNECTION=sqlsrv
DB_SRV_DATABASE=***

to your testing env like u have the first one

24 Apr
2 months ago

shez1983 left a reply on Laravel 5.9 Wish List

i would love inbuilt caching in models so we dont have to use packages which rarely offer caching with relationships..

shez1983 left a reply on Laravel 5.8 $this->resource Not Found

you still need to use Route::resource() inside there..

shez1983 left a reply on Should /tests Be In .gitignore?

one other thing is if you have tests in your gitignore, you risk LOSING them if something happens to your PC and b) your other devs wont be able to run them - i know you have your answer but just something that popped into my mind

shez1983 left a reply on How Do You Handle A User When Their Session Timesout In Laravel 5

generally when i visit a site i know i will be logged OUT unless during log in i click on 'remember me' (laravel also has this option) this way users will stay logged in..

I think from the common standard set - its ok for people to be logged out, unless they are doing FORMS (and if they are taking 120 mins, then thats their fault) it shouldnt be a big problem.

One thing that popped into my mind is to have some kind of event broadcasting where you open a connection which interacts with the BE to determine if user is logged in or not - and you then pop up a message.

In the same vain, you COULD have an ajax call (set timeout every 1 hour) that makes a dummy call and then you can see if you are still logged in or not and again pop up a message or an error message...

17 Apr
3 months ago

shez1983 left a reply on Laravel's Polymorphic Relationships Performance Vs Normal Relationships

well for one you wont be able to use db fk but you can add indexes i believe using both en_id, en_type.. so i am not sure where that leaves you..

14 Apr
3 months ago

shez1983 left a reply on User Data Within Controller

@polecalex the only thing is if your author isnt in th e fillables array on POST model

shez1983 left a reply on How To OrderBy And Paginate Posts With Its Comments List

instead of get use paginate() at the end - come on man.. read the docs for basic questions... :/

13 Apr
3 months ago

shez1983 left a reply on How To Return Redirect To Pervious Form Post In Controller?

usually you have two diff controller actions. one for showing form data (a simple get route) which posts to a post route.. where you CAN do back()->...

shez1983 left a reply on Applying Authorization Policies On Model Query...

actually for this kind of stuff you might want to have different controllers - one for admin, which just list all projects for example. one for the UserProjects where you specifically check if user owns a project.

but your last code.. it seems it should either be in a scope, relationship (which can be dynamic, you can check USERs etc) or a policy..

shez1983 left a reply on Best Practice For Secure Route Access From External Website

i know what a 3rd party does.. it doesnt send you a get request- YOU do a get request.. i specifically asked for a name... so i could read docs! but without knowing what kind of security it has in place i cant say anything

12 Apr
3 months ago

shez1983 left a reply on Adding Custom Rule To After Validation Hook In Custom Request Class

what are you wanting to do? where is CorrectCompetitorCount() coming from.. what validation are you trying to do?

shez1983 left a reply on 8, 9, To 12 Queries Per Index Page, Is It Acceptable?

depends - can you refactor to reduce the queries? are they doing too much or are they small queries? can you cache them?

shez1983 left a reply on How Do I Read Source Code That Eventually Leads Back To An Interface?

why dont you in the first instance test some non-americanised words and see what it returns?

shez1983 left a reply on SQL Query With ANDs ORs

wheres your code?

shez1983 left a reply on JSON Array Get Property

you first need to convert into an object.. json_decode. then you can do that.. but remember you will get an array of objects..

shez1983 left a reply on [5.8] Can't Resolve Instance From Service Container

can you try the

use App\Helpers\Globals; // top of file

// then:

dd(resolve(Globals::class)->brows_browser);

are these helper namespaced? ie in App\Helpers\Globals the first line is a namespace...

shez1983 left a reply on Applying Authorization Policies On Model Query...

normally the relationships are a kind of 'gate' themselves e.g.

users (id, ...)
projects(id, user_id...)

User {

hasMany Projects() {
   ....
}

in your case i would create a helper scope on user or projects etc that says ok load all project if their status is live or whatever.. if you can give us more info about how you want to limit maybe i can give concrete example

shez1983 left a reply on User Data Within Controller

try this :

$post = new Post();
$post->author = \Auth::id();
$post->fill($data) // make sure you comment/remove this line: $data['author'] = $request->user()->id;
$post->save();