shez1983

Experience

74,645

70 Best Reply Awards

  • Member Since 2 Years Ago
  • 205 Lessons Completed
  • 1 Favorite

21st August, 2018

shez1983 left a reply on Different User Types? How To 'code'? • 8 hours ago

@martinbean so you are saying i have a policy that dictates what people can do? how do i extend it to say this user cannot see this page...

20th August, 2018

shez1983 started a new conversation Different User Types? How To 'code'? • 23 hours ago

so if i have diff type of users (client, students, teacher) with some same fields some not - how should i approach this? how would login work? should i do user model and then just have a type? or do i actually have three entities and then do a one-one with user?

shez1983 left a reply on Duplicate Failed Due To A Cut Column Name • 23 hours ago

you should copy the object rather than do it like that.. as objects are copied by reference so $newUser still refers to $oldUser (or something like that)

http://php.net/manual/en/language.oop5.cloning.php gives you a bit more info

15th August, 2018

shez1983 left a reply on FirstOrNew Adds Unwanted Attributes • 5 days ago

i agree just add slug to the database - saves some php/laravel execution time..

shez1983 left a reply on Fully Rely On API? • 5 days ago

there is two reasons for wanting to change it into API -

  1. for learning purposes (think microservices)
  2. if you want to ever extend and create apps/expose your internals via APIs

APIs might create overhead thats true, but when you add varnish, laravel cache etc it wont be that much

shez1983 left a reply on Laravel Api Return Null • 6 days ago

really? you just need to add what i said to that query i commented/posted on my last post.. before get().. if you dont know the basics, please take time to go through a beginner's course

shez1983 left a reply on Any Chance On Updating React Series? • 6 days ago

i think he has moved on to VueJS.. :p

shez1983 left a reply on Laravel Api Return Null • 6 days ago

you just need to update your query:

$images = Image::orderBy('order','ASC')->select('id','path','order','visible')->get();

to say whereNotNull('visible') and then you wont need that if statement..

shez1983 left a reply on Organising Controllers And Models For Creating Records That Can Be Related To Two Other Models • 6 days ago

no you will have a create function in each controller and pass in school id which you can use eloquent to get the model and then save the contacts details..

shez1983 left a reply on How Can I Convert Many Statement Mysql To Laravel Eloquent? • 6 days ago

if you can give some exmple output of that query or what you are trying to do then that would help. but i read you said you dont know (did you copy this sql from google search?)

shez1983 left a reply on Question About Chaining Eloquent Relations • 6 days ago

notice has many through will only work if your db tables are setup like the example, otherwise you will have to either:

  1. create a view in MySQL which uses two tables to create one VIEW which you treat as a table in laravel.

  2. create a custom function to do this in your USER Model

shez1983 left a reply on WithInput() Vs Compact() Vs View('view','data') • 6 days ago

it depends on you - i too personally like 1 as its less code to write (even with the help of IDEs.. lazy i know) but also easier to read and therefore understand.

go with one you like and just be consistent

14th August, 2018

shez1983 left a reply on Laravel Api Return Null • 6 days ago

can you post the whole functuon/code.. your code doesnt show where data: attr is being set..

shez1983 left a reply on Organising Controllers And Models For Creating Records That Can Be Related To Two Other Models • 6 days ago

Or a SchoolContactsController and StudentContactsController? is what i would opt for..in which case yur functions in those file will be simply index() create().. etc instead of

something complicated if you decide to go for ContactsController..

shez1983 left a reply on Forge On Ubuntu 16.04 • 6 days ago

it should - u can always try

shez1983 left a reply on Percentage Complete • 6 days ago

so you probably need one relationship to get alll chapters of a book, and another one which are completed, this uses the pivot table snapey mentioned so you only get chapters of the book that are completed by the auth user.. something like:

return $this->belongsToMany(User::class, 'pivot_table')->whereUserId(\Auth::id())

shez1983 left a reply on How To Change School_id To A Int For Save In Database? • 6 days ago

@irankhosravi you are making people angry @Cronix has been kind enough to leave comments on how to implement what you need and asked you repeatedly if you have followed the comment and you keep ignoring instead you give him more code so he can read and give you the correct version

if you want someone to help you with your project go to a freelancer site and HIRE someone.. or LEARN THE BASICS of vue/laravel/php/programming...

shez1983 left a reply on Percentage Complete • 6 days ago

i would go with what cronix has said.. dont worry about pages.. etc

also i think the complete()/uncomplete() should not go in the book model.. maybe repository/service.. it seems messy as its dependent on AUTH user..

just create another function called percentage, and do what cronix has said

shez1983 left a reply on How To Use Package From Vendor Directory • 6 days ago

i think you need to use the components yourself :s https://adminlte.io/docs/2.4/main-header...

shez1983 left a reply on Explain On How Asset() Helper Work • 6 days ago

you can drill down to the 2nd asset function..

12th August, 2018

shez1983 left a reply on Laravel 5.4 Get Insert Id From Eloquent Model • 1 week ago

Cronix already did.. from your code $activity->id is the id from table.. if it isnt working then it could be the model is not being saved in which case go to this url using POSTMAN (or inspect element from your browser to see what is happening) or logs..

shez1983 left a reply on Cannot Display Image File To Index Page, Using The Edit/update Method • 1 week ago

what does every other input shows, except the image file mean? what happens when you do a dd($request->all());

if the file isnt showing then there could be a problem with image/ uploading file etc

shez1983 left a reply on Is Laracast Becoming Unreliable • 1 week ago

maybe because they cant - no one is committed to do anything they dont want to, people help because thye want to not because they HAVE TO.. you just need to be patient.. theres always slack channel or StackOverflow you can try

shez1983 left a reply on Cashier: NewSubscription Doesn't Create Stripe User • 1 week ago

i think when the JS code sends users details to stripe THAT creates a new token. this code just creates a new subscription for that user.

You can always dig down and see exactly what newSubscription() does.

shez1983 left a reply on How To Disable E_DEPRECATED • 1 week ago

its not laravel, its PHP afaik..

also try adding error_reporting = off.

but googling around your error_reporting thing should have worked (is that in php.ini or anywhere else?)

shez1983 left a reply on Load Test Failing For 500 Concurrent Users? • 1 week ago

@timersys did you find a solution? sorry didnt see this thread until now...

@cps unfortunately no.. what we did was we added more servers/upped them to max etc when we needed to.. laravel really is slow :(

you can try microservices, caching (varnish) so it can serve the user without even hitting laravel, php7's opcache...

shez1983 left a reply on Request Is Taking Forever After Upgrade To Laravel V 5.6 • 1 week ago

is your appliction actually www.example.com:? and what do laravel storage/logs say?

shez1983 left a reply on Cashier: NewSubscription Doesn't Create Stripe User • 1 week ago

this should be:

$user->newSubscription('main', 'my_plan_name')->create($request->token);

shez1983 left a reply on Redirect Certain User • 1 week ago

just below the call to ::all();

can you do dd($users[0]->email) and see what gets printed to the page.. there MUST be something wrong there..

and also just for testing purposes add return '/posts'; right after the function start to see what happens.

shez1983 left a reply on Detect When A Model Is Queried For Resulst • 1 week ago

two things

  1. long winded but use getNameAttribute for each field & add appendsToJson() for more info: https://laravel.com/docs/5.6/eloquent-serialization#appending-values-to-json

  2. or try attributesToJson() if that exists..

shez1983 left a reply on Laravel App Usages More Than 90% CPU Usages For Only 100 Concurrent Users With High Server Configuration • 1 week ago

laravel does use a lot and is also the slowest one - i think you need varnish outside of laravel not some package.

11th August, 2018

shez1983 left a reply on Cashier: NewSubscription Doesn't Create Stripe User • 1 week ago

code? but you are correct, users fill in form, request gets sent to stripe using js, they send back the token which you use.

shez1983 left a reply on Request Is Taking Forever After Upgrade To Laravel V 5.6 • 1 week ago

have you checked logs (laravel & apache/nginx)..

shez1983 left a reply on How To Pass Manual Parameters To Resource Response Array? • 1 week ago

i dont think your 2nd code has any errors...

you can also add to the $request in your controller using request->merge(['key' => '890]) & access it inside the resource

7th August, 2018

shez1983 left a reply on Query That Has A Where Clause And With Clause. • 1 week ago

$courses = \App\Course::where('SemesterID', $id)::with('Instructor')->get();

only the first :: works from then on you have to use ->

shez1983 left a reply on Parse Error: Laraverl • 1 week ago

how does this error Parse error: syntax error, unexpected 'class' (T_CLASS), expecting identifier (T_STRING) or variable (T_VARIABLE) or '{' or '$' in /home/spanibox/laravel/config/auth.php on line 31mean the site has been hacked?

5th August, 2018

shez1983 left a reply on Trying To Get User Details... Should Be Simple • 2 weeks ago

the clue is here +exists: false it doesnt seem to exist.. what does your model/database look like.

try doing this instead: dump(User::first()) just to see what happens

24th July, 2018

shez1983 left a reply on Create A Pivot Table • 3 weeks ago

you would create it as you would any table.. :s

23rd July, 2018

shez1983 left a reply on How To Pass Header Values Between Functions • 4 weeks ago

@jwillz21 you asked how we store this token in the frontend? i am not sure how you would persist them with vue/angular etc but at a guess you would have to use cookie so that this token does not get lost when user refreshes the page

shez1983 left a reply on Laravel RAW Query With IGNORE Doesn't Work As Expected • 4 weeks ago

can you post your column info (Ie how you are storing this in your db, ie show create statemnt)

shez1983 left a reply on How To Pass Header Values Between Functions • 4 weeks ago

normally you only have JWT tokens when you use AJAX/API routes..

so what happens in those cases is:

  1. i make a call to your login route
  2. i get back an auth token
  3. I store this on client side and then send it myself in subsequent request adding it to the header section..

if you are not using API i dont know why you are doing what you are doing? because if you set that header in each request, you will need to know who the user is.. and for non api normal login flow should work BUT one workaround (and this is a hack, dont do this as it makes NO SENSE) is:

  1. you login..
  2. you get an authTOKEN.. store this in your session as $_SESSION['token'] 3a. add a middleware that runs before which checks the session and adds the necessary header BUT 3b) instead of doing 3a) you could just de-code that token to see if user is logged in or not (ie first check if session exists, if it does then de-code it to get user info)

shez1983 left a reply on How To Pass Header Values Between Functions • 4 weeks ago

where is the code where you try to access it? if its in the headers section it should be accessible via $request-> or $_SERVER['']

shez1983 left a reply on Custom Artisan Command Not Found • 4 weeks ago

what package is this? maybe the package is packaged up wrong? because if artisann list works then it should be able to run them..

maybe also do a -vvv to see a trail of exception.

shez1983 left a reply on Trailing Slashes In Query Strings A Good Idea? • 4 weeks ago

the first one is confusing as well.. 2nd one reads better

shez1983 left a reply on Any “famous” Sites Built With Laravel? • 4 weeks ago

@jlrdw you only have experience of one language Java with a bit of php/.net (Sorry didnt want to read your big post, just skim read it)..

my last post wasnt a question it was directly aimed at your first post saying php cant be used for entreprise..

and your you cannot have that large revenue/whatever without a monolithic

are you insane? yes you can - microservices isnt just an inferior thing that wont be handle 1000s transactions - in fact thats the reason why people build microservices so they want to be able to handle 1000 transactions..

22nd July, 2018

shez1983 left a reply on Relationship Advice (hasMany, HasManyThrough?) • 4 weeks ago

for hasManyThrough you would put the logic in user model.. assuming that the keys are in correct place (use the example on laravel docs for this) - sometimes the keys are not as expected so hasManyThrough doesnt work as exactly..

if that doesnt work you can also create a view which combines tables and then you can create a relationship that way

finally you could also create a custom function in user model to get what you want (or repository if you use that)

shez1983 left a reply on Any “famous” Sites Built With Laravel? • 4 weeks ago

why isnt PHP good for entreprise systems?

shez1983 left a reply on Laravel RAW Query With IGNORE Doesn't Work As Expected • 4 weeks ago

no worries.. what happens if you actually hard code the date instead of using the ? syntax.

shez1983 left a reply on How To Add Headers In Laravel Request • 4 weeks ago

then they could be added via nginx/apache directives..

21st July, 2018

shez1983 left a reply on Set Laravel Cookie To Have A Random String As Value Until Deleted • 1 month ago

what do you mean by change? of course if you are hitting that controller it will change its value because str_random(10); will make it change... if you only want to change it if it doesnt exist wrap the code in an if statement to test whether the cookie exist or not..

Edit Your Profile
Update

Want to change your profile photo? We pull from gravatar.com.