Cronix

Experience

484,120

612 Best Reply Awards

  • Member Since 4 Years Ago
  • 694 Lessons Completed
  • 3 Favorites

24th June, 2018

Cronix left a reply on MethodNotAllowedHttpException Only Production • 8 hours ago

Need to see the relevant route, controller, and view for that. Can't tell by the info provided.

Cronix left a reply on How To Pass Value Bindings To B::raw() In Order To Avoid Injection Attacks? • 8 hours ago

Just put the whole thing in a selectRaw, and use the bindings in the 2nd parameter: https://laravel.com/docs/5.6/queries#raw-expressions

Cronix left a reply on Count All Participants Of Each Registration Type • 15 hours ago

Seems pretty straightforward. It just involves a single model. What have you tried?

Cronix left a reply on Passing Parameters To Controllers • 17 hours ago

Have you actually read the docs I linked to? It's meant to specifically prevent what you keep asking about.

Cronix left a reply on Passing Parameters To Controllers • 17 hours ago

but change the ID here to the other topic, the reply will instead be associated with that one as if I've just replied to it on it's own page.

Not if you write a policy for it it won't. You could write the policy to check whether the user is authorized to reply to that topic. It won't matter if they change the id bc the policy would check whether they are authorized to change THAT id.

How are you defining who is allowed to do what?

Cronix left a reply on Update Check Box • 18 hours ago

@sami2500 The same was as normal, except it will be an array instead of a single value

$names = $request->name;

$names is now an array of the checked item values.

23rd June, 2018

Cronix left a reply on How To Fix This Error؟ • 1 day ago

You're messing up the insert by assigning the data to the wrong columns.

You're saying to insert this:

msg=23-06-2018 (should be a message, not a date)
created_at=آزادی از جمله تجملاتی است که هرکسی توان کسب آن را ندارد. (should be a datetime)

See the problem?

Cronix left a reply on Async In Php • 1 day ago

I haven't used either of those 2 packages/libraries.

Cronix left a reply on Showing Additional Information From Related Model Instances. • 1 day ago

In the Book model, you'd have

public function user(){
    return $this->belongsTo (User::class);

And then you could use something like

// Get the book by the book name, along with the user associated with the book
$book = Book::with('user')->where('name', 'Some Book Name')->first();

// Get username from the retrieved book
$user = $book->user->name;

Cronix left a reply on Async In Php • 1 day ago

You'd want to use queues for that. Queues are async if you don't use the file driver and use redis or the database. It just sends jobs to the queue and lets the queue process it in the background and not waiting for a response. It just continues on with regular flow.

Cronix left a reply on How To Correctly Receive Ajax's Post Data? • 1 day ago

$.upload = function(file) {

How are you passing file to this function? Show that code, along with your html for the form or file input.

Cronix left a reply on Attach Many Related Models • 1 day ago

There's attach(), detach(), sync(), toggle(), etc. It depends on the type of relationship that you're updating on.

Cronix left a reply on Ajax Send Data In Localhost But Send Null In Server • 1 day ago

Ok, well what does it look like in your dev tools for that ajax request like I asked? Does it show sending the correct parameters and values?

What is this supposed to do? If you're wanting to increase a like or something, you should be using a post or put request, not get. Get should be used only for retrieving data, not saving or updating it.

It would help to also show the controller, and the route used for this.

Cronix left a reply on Ajax Send Data In Localhost But Send Null In Server • 1 day ago

What does it look like in dev tools in your browser for that ajax request? Is it successful? Are the correct parameters/values being sent?

Need to figure out if it's the ajax/javascript messing up, or the controller receiving the data.

Cronix left a reply on Security Issue No1 Suggestion: Masking By Default The Information That Resides In .env File! • 1 day ago

Should laravel build the server for people too, to protect them from their own lack of knowledge? I see way to many people improperly set up their servers, especially shared hosting, and you can access .env directly and see all of the raw credentials.

Like this guy who I told about it 2 days ago and still hasn't fixed it: http://admin.creativehedgehog.co.uk/.env

Cronix left a reply on Ajax Send Data In Localhost But Send Null In Server • 1 day ago

Is there only one "like" button on the page? You're using an id on the anchor, #like. If there's only one thing on the page with the id of 'like', then it's find. If not, you need to use classnames. ID's are supposed to be unique (html specs) per page, while you can have as many elements using the same classnames as you want.

I'd also put the postId, userId and type as data properties on your <a> tag and not read them from the href of the anchor.

<a href="/your-url" data-postId="post-id" data-userId="user-id" data-type="type">Like</a>

then in jquery you can access them from the <a> tag like

var postId = $(this).data('postId');

Cronix left a reply on Ajax Send Data In Localhost But Send Null In Server • 1 day ago

I'd suspect your getURLParameter() function, but you don't show that code. Everything else is pretty vanilla and doesn't look like it would be an issues.

Cronix left a reply on Method Should Not Be Called Statically.... • 1 day ago

It also happens for a lot of laravels "magic" methods that IDE's can't figure out bc the methods don't actually exist, but they get called via php's magic __get() method.

Things like Model::whereName('some-name') cause issues instead of Model::where('name', 'some-name'), because there isn't an actual whereName method but there is a where method.

It is annoying, so I don't use any of them.

Cronix left a reply on Security Issue No1 Suggestion: Masking By Default The Information That Resides In .env File! • 1 day ago

you are lucky man, I bet you work in a team where nothing is left unchecked and have a 'replica' in case you fail, but I doubt you have been in a project where everything is expected only from you, everything... servers, networking, db, programming, maintenance and so on!!!

I did that for 12 years as an independent contractor when I started my company. I've built some very large, high traffic, multi-million dollar sites that are still running and generating a lot of revenue ;) And most of these automated tools and frameworks we have today to do this stuff for you didn't exist. So you really actually had to know things. But thanks for assuming. ;)

22nd June, 2018

Cronix left a reply on How To Correctly Receive Ajax's Post Data? • 2 days ago

In your browsers development tools network tab. It shows each request, what was sent with the request, the heders, and what was received back.

Cronix left a reply on One Guard For Domain And One Guard For Subdomains • 2 days ago

What's your SESSION_DOMAIN set to in .env? Try ".yourdomain.com", in quotes, with a . in front. That should make the session cookie available to all subdomains and main domain.

Cronix left a reply on Home Page Is Working On Local Host But Shows Error In The Server • 2 days ago

No, it won't affect security, but if you want to fix it, it's pretty easy.

ORDER BY clause is not in SELECT list

Your order by is using id, but you don't select id in the query. Simply select id in your query along with the other fields you're selecting.

Cronix left a reply on Array_merge In Laravel Not Working • 2 days ago

And if this is the output for that method

images  
300 "/upload/images/2018/300_tvto.jpg"
600 "/upload/images/2018/600_tvto.jpg"
900 "/upload/images/2018/900_tvto.jpg"
original    "/upload/images/2018/tvto.jpg"
thumb   "/upload/images/2018/300_tvto.jpg"

of course this won't work

$article = auth()->user()->article()->create(array_merge($request->all(), ['images' => $imagesUrl]));

It has nothing to do with array_merge. It has to do with whatever you're doing in this secret method uploadImages($request->file('images')) and what you're trying to save.

Cronix left a reply on Array_merge In Laravel Not Working • 2 days ago

You don't show all of your relevant code. What's going on here? Show the uploadImages method.

$imagesUrl = $this->uploadImages($request->file('images'));

Cronix left a reply on Where To Post Jobs? • 2 days ago

None of the leaders have it lol

Sure they do. You have to visit their profile. It doesn't show the "hire me" button on the leaderboard.

Cronix left a reply on Spatie Laravel-analytcis • 2 days ago

Cronix left a reply on Spatie Laravel-analytcis • 2 days ago

Showing your code would help.

Cronix left a reply on How To Use The Slug As Url • 2 days ago

You'll probably want to use firstOrFail() instead of first(), so it will 404 if not found.

Cronix left a reply on Accessing Controller Functions From Queue Class • 2 days ago

Another option is to create a trait that contains the common functionality, and use the trait in the controller and the job.

21st June, 2018

Cronix left a reply on How To Install Laravel 5.6 Via Composer? • 3 days ago

Just go to the github page for laravel, and go to "releases" https://github.com/laravel/laravel/releases

Cronix left a reply on Can You Calculate The Maximum Number Of Requests This System Can Handle? • 3 days ago

Not without know what kind of requests they were... Like were they hitting the db? How complex was the query? Etc. Stats are meaningless without the context.

Cronix left a reply on Security Issue No1 Suggestion: Masking By Default The Information That Resides In .env File! • 3 days ago

Can you tell me who to contact for this issue?! Thanks

Sure, in the github repo, but you'll only embarrass yourself with this. https://github.com/laravel/framework/issues

Cronix left a reply on Security Issue No1 Suggestion: Masking By Default The Information That Resides In .env File! • 3 days ago

Because you have debug=true, so it's showing you all of the values so you can, you know, debug things. debug=false, doesn't show any such details. Yes, I understand the issue. It seems you don't understand what the different settings are for, and got burned because you didn't do your homework.

Cronix left a reply on Security Issue No1 Suggestion: Masking By Default The Information That Resides In .env File! • 3 days ago

Future will tell

Yep, but seeing as how it's been this way for over 5 years now, and your post is the very first post I've seen asking for this type of thing, I tend to doubt it will be "fixed". It's how it is supposed to be. So, just don't hold your breath for it to change. It really won't.

Cronix left a reply on Security Issue No1 Suggestion: Masking By Default The Information That Resides In .env File! • 3 days ago

That's like blaiming Messi for today's match! Or Ronaldo when he looses a penalty!

Not really the same thing, unless Messi or Ronaldo were neglectful in being a professional fighter and just sat there or something and let the other guy knock him out. Or they stayed up too late partying the night before the match and couldn't concentrate.

I said the disscusion is closed but I feel like I'll continue until a solution will be provided by laravel

It won't be fixed, because it's how it's supposed to be, and is the whole point of the .env library that laravel uses.

Cronix left a reply on Security Issue No1 Suggestion: Masking By Default The Information That Resides In .env File! • 3 days ago

APP_ENV=production
APP_DEBUG=false

Is that so hard to do on your production server? Problem solved... No altering anything except the .env file, which is the whole point of the file...

Cronix left a reply on JS Libraries To Handle Image Uploads • 3 days ago

What is there to delete with file uploads?

Cronix left a reply on How To Pre-fill Select List Default Value From Database? • 3 days ago

No, you could use a single table to store options. Something like

options
-id
-type_id
-name

option_types
-id
-name

where type_id would be the id for different lists. So you could store multiple lists, with multiple values in a single table.

So you could have the following option types (name field):

  • id: 1, name=Fuel
  • id: 2, name = Food

And then in options you could have

  • id:1, type_id=1, name=Gas
  • id:2, type_id=1, name=Oil
  • id:3, type_id=2, name=Corn
  • id:4, type_id=2, name=Beans

THEN, you could just query for a specific option (like type_id=2) and get all values for Food (Corn/Beans), or select type_id=1 to get all Fuel options (Gas/Oil).

Cronix left a reply on Calculate Dates In Mysql Using Carbon And Laravel • 3 days ago

@marvino Please format your code with 3 backticks on their own line, followed by code, followed by 3 more backticks on their own line

```

code...

```

Cronix left a reply on Uploaded To A Server But Public • 3 days ago

Your /public dir is NOT the DocumentRoot. It should be. Without that, not only do you have to specify /public in all urls, but your site is insecure and exposed. See? I can see all of your credentials in .env, and so can everyone else.

http://admin.creativehedgehog.co.uk/.env

20th June, 2018

Cronix left a reply on Calculate Dates In Mysql Using Carbon And Laravel • 4 days ago

Simply ->format() the carbon instance.

$today = Carbon::today()->format('m/d/Y');

https://carbon.nesbot.com/docs/

Cronix left a reply on Ways To Determine Both Role And If CurrentTeam Is Model Team • 4 days ago

I'm not sure why you need it on the models if you are denying access via middleware, and using the middleware on the team routes? Doesn't it basically accomplish the same thing? If they middleware denies them, then they'd never make it to the controller?

Cronix left a reply on Ways To Determine Both Role And If CurrentTeam Is Model Team • 4 days ago

You can always create a helper method on the User model that returns the result of that. Or make a trait, and use the trait in the affected models, or use gates/policies, or a combination of these.

Cronix left a reply on Add Timestamp And Reverse Messages • 4 days ago

Did you use unshift() in both places that you're using push()?

Cronix left a reply on Call To A Member Function Update() On Null • 4 days ago

@rin4ik Yes, I know. I looked at your code and that's why I said to add it to the Requisition model. I should have scrolled up higher at the actual code he's using. My bad.

Cronix left a reply on Call To A Member Function Update() On Null • 4 days ago

Sorry, I was looking at @rin4ik post, which looks like it's using the wrong model. It should be the model you're actually updating.

public function update(Request $request, SubmitApplication $submitApplication)

So, the SubmitApplication model, if that's the correct model...

Cronix left a reply on Running Staging And Production On Same Forge Server? Best Practices? • 4 days ago

No worries, I'm glad you have something working for your needs.

Edit Your Profile
Update

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