shez1983

shez1983

Member Since 3 Years Ago

London

Experience Points 95,695
Experience Level 20

4,305 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 94
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.

14 May
5 days 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
1 week 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
1 week 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
1 week 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
1 week 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
1 week 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
1 week 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 weeks 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
3 weeks 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
3 weeks 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
1 month 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
1 month 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
1 month 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
1 month 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();
10 Apr
1 month ago

shez1983 left a reply on Laravel On Chrome Vs Firefox

its a browser issue - maybe you have plugins.. or caching disabled (which u can do if you have inspect element opened)

09 Apr
1 month ago

shez1983 left a reply on Laravel 5.8 - Route Not Working { HTTPS }

do they work on normal http? also the app url in .env is https:// finally what error do u get? can u post a screenshot

shez1983 left a reply on Multiple Relationships And Use With Paginate

i think because you are doing find() - it actually does the QUERY so anything after this is not really a query.. try changing to

User::whereId($id)->students()->posts()->paginate(50);

but i dont really get what u want to paginate? u want to paginate by relationship?

08 Apr
1 month ago

shez1983 left a reply on Applying Design Patterns In Laravel

i am not sure about @papa example - you dont want to create wrapper classes which make no sense but bloat your code.

try to apply SOLID Principles to your classes (do some research on what this is, laracasts have videos but you can get free vidoes on Youtube/google)

try to create wrapper func to create complicated classes for example: if when u create a product, u need to create variants, prices, images etc.. then wrap it up into one service class (Product) with method called create ().. (this is factory pattern).

try to use interfaces/and polymorphism instead of doing something like:

if type == 'this'
     do this
else if .. 
     do that.
...

do this:

$class = getType($type);
$class->doStuff

Again google it - one result thatcame up is: https://refactoring.guru/replace-conditional-with-polymorphism


Finally if your project/codebase is small.. then try not to go down into these patterns just for the sakes of it unless you want to learn in which case small code base is perfect.

shez1983 left a reply on What Controller Should Be Responsible For Static Pages?

i do the same as @snapey but just prefix the url with pages/ or something...

04 Apr
1 month ago

shez1983 left a reply on Getting Value From Another Table Through Id

clearly there is a need to check the docs.. if you have a relationship between students_attendance & students_classes - then you use the with() to eager load the other table and simply do $students_attendance->students_classes->class_name.. unless there is a middle table somewhere? or maybe i am not getting it - post your relevant tables/code you have so far

shez1983 left a reply on Anyone With Experience In Implementing Amazon Pixels Out There?

yes but putting tag in your image wont work as far as i know because image tag is where are you going to put pixel tag? u didnt mention images for your pixel.. these should work the same way as i described above but instead of redirecting you spit out the image using PHP

shez1983 left a reply on Correct Way Of Calling Eloquent Methods

@munazzil why are you just repeating what he said - he asked for the correct way... :/

@garet go with whatever feels right but be consistent with all models.. one could argue using a repository pattern...

shez1983 left a reply on Getting Value From Another Table Through Id

read up the docs on relationships - this should answer your question and then post if you get into difficulty

shez1983 left a reply on Best Laravel Video Player That Works With Amazone S3?

what do you mean by video player? laravel doesnt have a video player - laravel is php... theres only standard video player in hTML.. or you might be able to embedd one from external services youtube, vimeo etc..

03 Apr
1 month ago

shez1983 left a reply on Anyone With Experience In Implementing Amazon Pixels Out There?

what i have done in the past is have a middle page.. something like: domain.com/redirect?url=dddd&trackingCode=2222

embed this in your emails and on that page do a get via ajax/cur/guzzle to http://trackingcode and then redirect user to the URL.

Mailgun can also do this and you can get stats in their platform ie how many clicks etc. i am sure others will chip in with other suggestions

shez1983 left a reply on Comparing Factory To Eloquent Model

in that case you might need to do pass in two sets of array

$s = $settings->toArray();

assertEquals($expectedArray,  array_only($s,  [$fields to check])

if assert Equals dont work then assertJSON should and u have to wrap each array with json_encode..

shez1983 left a reply on Laravel Import Large Csv File ?

aside from what snapey mentioned - to import a large file - i would save it as text and create a command to do it on CLI - as it doesnt have as much restrictions that the web version have - mainly the timeout issues

shez1983 left a reply on Using 'model' In A Form

what i typically do is have the edit version of the form...

 <label for="subject">Subject</label>
                                <input type="text" name="subject" value="{{ old('subject', $subject->name) }}">```

and use it for both create and update - for create pass it a new instance.. that way it works for both (then use $subject->id etc to add hidden fields (method = put) for update etc) 

alternative would be to have two blade  create, update.. set up the <form with relevant hidden fields and then include a comp form.. again doing what i did above..