Cronix

Experience

169,770

191 Best Reply Awards

  • Member Since 4 Years Ago
  • 495 Lessons Completed
  • 2 Favorites

24th November, 2017

Cronix left a reply on Non Creditcard Payments Using Stripe • 8 hours ago

Out of the box Spark is only set up for credit card payment subscriptions. I have not done it, but you can extend it to use other payment methods which is pretty easy if braintree or stripe themselves support it. FYI Spark is using Laravels Cashier package so you can probably find more info in that package (which also supports single payments as opposed to subscriptions). https://laravel.com/docs/5.5/billing

Cronix left a reply on How Can I Manually Increment By Any Number For The Letter Of Alphabet? • 8 hours ago

I'm not totally clear on what you're after, but based on what you said I think I'd put the letters in an array, and use $row (a number) to access the corresponding letter.

$letters = ['A', 'B', 'C', 'D'];  // all the way to Z

$row = 0;

echo $letters[$row];// Echos A

$row++
echo $letters[$row]; // Echos B

$row++;
$echo $letters[$row]; // Echos C

23rd November, 2017

Cronix left a reply on Submit Form Within Bootstrap Modal - TokenMismatchException Error • 1 day ago

Why even use javascript here? It's not doing anything except submitting the form, just the same as it would if there wasn't any javascript.

22nd November, 2017

Cronix left a reply on Remove TLSv1 • 2 days ago

I haven't tried this, but I imagine it's just removing TLSv1 from the nginx config for the site you want to remove it from here:

ssl_protocols TLSv1 TLSv1.1 TLSv1.2;

Cronix left a reply on How Many Users Has Laracasts? • 2 days ago

Are you trying to figure out Jeffrey's income lol?

Cronix left a reply on Regarding The Doc And Request From Middleware • 2 days ago

Think of it like the PHP globals like $_SERVER, $_POST, $_GET, etc. Always available (even if $request isn't passed, the request() helper is still available).

Cronix left a reply on What Is The Best Way To Get Feedback On A Forge Issue? • 2 days ago

Personally I find the lack of support for these paid packages/services disturbing. They are what pay the bills (Forge/Spark/Envoyer/Etc). They should get priority support above a free framework. They make great products, but aren't very good businessmen, apparently. It shouldn't take more than an hour or two to get a response for something you pay for.

Cronix left a reply on Is There A Controller Naming Convention For An Acronym? • 2 days ago

Plural/Singular controllers are really up to you. I name mine singular, mostly for the reason @martinbean spells out. There is nothing automatic in laravel that assumes it for controllers (since you have to manually link endpoints to controllers via the routes), unlike when it comes to naming Models and DB Tables where part of Laravels magic assumes plural Table names and singular Model names so it can automatically link a model with a table (you can override this by specifying the table name in the model).

I also highly suggest watching Adams Laracon talk linked above when it comes to breaking up controllers into responsibilities. If a controllers methods grow beyond the basic REST verbs, time to make an additional controller.

21st November, 2017

Cronix left a reply on Is There A Controller Naming Convention For An Acronym? • 3 days ago

CMSController seems overly broad. Is this controller going to have all methods for the cms? Probably not, or it'd be a huge controller. Break it up into individual responsibilities. ArticleController, PublishController, WidgetController, MediaController, etc.

Cronix left a reply on Check If Password Has Been Used Before • 3 days ago

Try checking against Hash::make($value)

Cronix left a reply on Create, Use And Modify A Variable In Blade • 3 days ago

I agree with everybody that it's best to do the logic in the controller, however, there are cases where that doesn't make sense, such as this one where you're basically creating header for each section of values when the value changes from the previous. What you're doing is perfectly fine, imo. Don't forget all of these @foreach(), etc, is php too. It's impossible to have NO php in your views (blade directives are just shortcuts for php!)

The only thing I'd do differently is declare $lastLetter = ''; in your controller, and pass that variable along with $variablesthat you're already passing to the view so you don't have to declare it in the view. The rest would look like @BryceSharp showed in his first post.

@foreach($variables as $variable)
    @if($lastLetter != $variable->letter)
            @php
                    $lastLetter = $variable->letter;
            @endphp
            {{ $lastLetter }}
    @endif
@endforeach

20th November, 2017

Cronix left a reply on How Do You Work With Different Computer? • 4 days ago

+1 homestead

18th November, 2017

Cronix left a reply on What Kind Of OOP Concept Is This? • 5 days ago

This is special for middleware. There are usually many pieces of middleware that get executed in order. Usually you do something with request to do some checking, and if it doesn't pass you do something (like redirect to home in this case). If it passes, you tell it to continue on down the middleware chain. $next is the next middleware in the chain, and you pass $request to it (just like this handle method accepts $request.

I hope that makes some sense.

Cronix left a reply on Automatic Ajax Request • 6 days ago

$(function(){ 
    // whatever code is here will be executed when the page loads
});

Put your ajax in there.

17th November, 2017

Cronix left a reply on Is There A Way To Make These Queries Hit The Database Once? • 1 week ago

Ok, then no, you can't eliminate the 2nd query if you want to do it that way.

Cronix left a reply on Is There A Way To Make These Queries Hit The Database Once? • 1 week ago

Why are you saving 2 ids of the same value in the same table (opener_id and id)? Just use id. That would also eliminate the 2nd query both times.

Cronix left a reply on How To Make Js Work On Laravel 5.4? • 1 week ago

So you put your file in /public/js/logos.js, but if you browse to http://yoursite.com/js you only see app.js? If that's the case it sounds like a file permission issue.

16th November, 2017

Cronix left a reply on Redirect To External URL Not Working • 1 week ago

I have two domain names for my website (abc.com and abc.ca), and I'm trying to redirect anyone trying to go on abc.com to abc.ca.

By your description, I'm assuming you want to redirect ALL traffic from abc.com to abc.ca (not just certain urls). Do this in nginx/apache config for the abc.com site, not laravel. It's faster and uses almost no server resources anyway since it doesn't force laravel to even load. It just redirects before it even hits laravel.

Just google nginx redirect or apache depending on what you're using. It's pretty simple.

Cronix left a reply on Make My Website As An Application • 1 week ago

It has nothing at all to do with "laravel", so just remove that from the equation. You'll have to do a lot of research no matter what javascript front end you use (vue, react, etc) and what search engines need to be able to use your javascript. It's not straight forward. You might need to do some prerendering. This is actually WHY the hashbang (#!) that you want to remove is in the url. You'll want to read up on all this stuff (SPA+SEO) and understand how it actually works. Search engines used to totally ignore your javascript. They've gotten better, but its not perfect, especially since it differs from search engine to search engine (Google vs Bing vs Yahoo, etc).

https://adkgroup.com/insights/single-page-applications-spa-and-seo-problem

Cronix left a reply on Make My Website As An Application • 1 week ago

But in this video, there a '#' in the url and i dont want it...

You can remove it by telling it to use 'history' mode.

https://stackoverflow.com/questions/34623833/how-to-remove-hashbang-from-url

15th November, 2017

Cronix left a reply on Best Practice For Passing Models With Relationship Data To Views • 1 week ago

The docs, videos here on laracasts, etc, all show passing the single variable, $company in your case, to the view. So, I'd say that's the best practice over creating extra variables. I don't really think $company->profile, $company->payments are unclear. If anything, they are more clear as you can actually tell they belong to the $company since they are self-contained.

Cronix left a reply on How Can I View The Image I Uploaded To Storage/app/images In An Img Tag(HTML) • 1 week ago

The files should be in storage/app/public, with storage/app/public linked to public/storage

So if you upload an image to storage/app/public/application_attachments, the url would just be <img src="/application_attachments/file.jpeg">

Cronix left a reply on Sending Php Data Through Html Form To Jquery • 1 week ago

in HTML, the specs say IDs need to be unique. 1 per page (as opposed to classes, of which you can have many). You're creating a form in a loop (creating many forms), all using the same id, like <input name="comment" Itemid="{{$order['itemId']}}" id="comment"> creates many inputs with the id="comment".

Cronix left a reply on [solved] Different Generated Queries On Different Servers?? • 1 week ago

Glad you solved it. The first query you showed was using ID of 2 as the bound query parameter. The 2nd was using IDs 1 and 6. That's why I was thinking the data was different on the boxes.

Cronix left a reply on SweetAlert Vs SweetAlert 2 • 1 week ago

I really don't know. The docs don't show anything about it. I'd suggest swapping it out for sweetalert2. They even show html in the examples, and it's almost the same as the original sweetalert. https://limonte.github.io/sweetalert2/

Cronix left a reply on SweetAlert Vs SweetAlert 2 • 1 week ago

@sylvert Try using 'html' instead of 'content'. It probably depends on if you're using the original sweetalert, or sweetalert2. I know 'html' works with sweetalert2, not sure on the original sweetalert as I don't use it.

Cronix left a reply on Diffrent Generated Queries On Different Servers?? • 1 week ago

Are you sure the db data is the same on the dev and production servers? It would do that because of the other queries being run. It takes the results, grabs the id's from the first result and uses them in the next query (in (?, ?)). Look at the queries being run on the relationships before it gets to the one you posted. I'd bet the data isn't the same on both boxes.

14th November, 2017

Cronix left a reply on Select Option Property Not Working • 1 week ago

BTW selected="selected" is outdated. With HTML5, you just need the selected attribute. Same with checked for checkboxes.

<option value="sms" {{($template->type=='sms') ? 'selected' : ''}} > SMS </option>

Cronix left a reply on PHPStorm Not Helping To Find The Right Namespace • 1 week ago

It could be bc you have a space in a directory name. I'd change "Admin Controllers" to just "Admin". It's also kind of redundant to say controllers/admin controllers. You can assume that if there is an Admin dir within Controllers, it's Admin Controllers. "Controllers/Admin/User" is pretty self explanatory and logical without being redundant.

11th November, 2017

Cronix left a reply on Laravel - How To Generate Page Dynamically • 1 week ago

Define fully dynamic?

<title>{{ $page->title }}</title>

<div class="main-content">{{ nl2br($page->body) }}</div>

Cronix left a reply on User Required To Re-login If Accesses Web Site With Www • 1 week ago

This is easily taken care of by forcing redirects at the server level using apache/ngingx/whatever.

Don't use www and non www. Use one or the other.

If you want yoursite.com, set up a redirect for www.yoursite.com to go to yoursite.com, and vice versa if you want www.yoursite.com. Your site should be available using one or the other, not both. You will also get penalized in search engines if your content is available on both. Technically, www.yoursite.com and yoursite.com are 2 separate domains. If www.yoursite.com/some-page and yoursite.com/some-page have the same content, you'll get a lower ranking. You'll also have this problem.

Cronix left a reply on Laravel - Give Specific Names In Database Specific Colours In Blade • 1 week ago

Well that would be the easiest. You could also create an array in your controller and send it to your view.

$colors = [
    'channel1' => 'red',
    'channel2' => '#334433'
];

Then in the view: {{ $colors[$post->channel->name] }}

Cronix left a reply on Laravel - How To Generate Page Dynamically • 1 week ago

For each page (assume you have a "pages" table), I'd have a slug in the database that would then be the url. You'd only need a single route to handle all pages. Well, that depends on what you're doing, but it would be something like:

// this route should be very last in your routes file
Route::get('/{page}', '[email protected]');  
PagesController extends Controller {
    // Tell laravel to retrieve the model by the $slug instead of the default $id
    public function getRouteKeyName()
    {
        return 'slug';
    }

    // Show the requested page
    public show(Page $page)
    {
        return view('pages', compact('page'));
    }
}

Most pages have a title. You could just use str_slug($title) to create a slug from the title. You'd also want to verify that the slug doesn't already exist in the db when creating an article. https://laravel.com/docs/5.5/helpers#method-str-slug

Then you'd just

http://yoursite.com/some-page-slug
http:://yoursite.com/some-other-page

This might not be 100% correct code as I just typed it off the top of my head, but should help get you there.

Cronix left a reply on Laravel - Give Specific Names In Database Specific Colours In Blade • 1 week ago

Why not just put the colors in the database in the channels table, just like you are channel_name. {{ $post->channel->color }}

10th November, 2017

Cronix left a reply on Display More Than One Tag On Views • 2 weeks ago

Right after you get the posts and assign them to $post

9th November, 2017

Cronix left a reply on Does Laravel Have A Feature For Handling Printing CSS? Printing, As In, Printing A Web Page To A Piece Of Paper. • 2 weeks ago

Yes, but laravel doesn't really have any css, except for its 'welcome' page. Most people are using some css framework that usually has a css for printing specific to that css framework, like bootstrap, bulma, etc.

Cronix left a reply on How To Use A Normal If Statement In PHP In Controller To Check If A Dropdown Has A Selected Value • 2 weeks ago

I usually have a default option that has no value

<select name="user">
    <option value="" selected>Select a User</option>
    <option value="4">Bill</option>
    <option value="13">Jen</option>
</select>

Then in controller:

$user = $request->user;

if ( ! empty($user)) {
  // a user was selected
} else {
  // no user was selected
}

Cronix left a reply on Why Does The Collection Get() Return More Than One Thing Sometimes • 2 weeks ago

It can be a bit confusing because there are 2 different get()'s in laravel. One is for executing a database query, which is what you're showing in your 2nd example. That will return all records matching whatever criteria is set in the query.

The other is a collection method to get a specific (single) entry from a collection (could be a manually built collection, or a collection returned from a database query), which you linked to.

Cronix left a reply on Does Laravel Have A Feature For Handling Printing CSS? Printing, As In, Printing A Web Page To A Piece Of Paper. • 2 weeks ago

The process is exactly the same whether it's a regular css or one that's meant for printing. The only difference is how you link to them in the head of your document. You'd have 2 css files. One for the site and one for printing.

Cronix left a reply on Does Laravel Have A Feature For Handling Printing CSS? Printing, As In, Printing A Web Page To A Piece Of Paper. • 2 weeks ago

I'm not sure what your question has to do with laravel. As you mentioned, you just add media="print" to the css link. When someone goes to print the page, it will use that css. What are you hoping laravel can do for you here?

Cronix left a reply on Flagged Enum • 2 weeks ago

I just use the built in day of week functions of mysql and store the day in the db as an integer. 0 = Sunday, 6 = Saturday, which is also the same scheme that php assigns numbers to days of the week (w flag in date()). This just makes it easier to use php/mysql's built in date functions and translating, like back to the textual representation "Sunday", etc.

https://dev.mysql.com/doc/refman/5.7/en/date-and-time-functions.html http://php.net/manual/en/function.date.php

Cronix left a reply on Does Spark Comes With Multisite Capability? • 2 weeks ago

It depends on how you're meaning to use it. The single license version of spark allows it to be installed on a single domain, like abc.com, which is tied to your license key. The unlimited license allows you to install it on as many domains as you want.

If you are charging subscriptions from a single domain, you can use the single license. If you are going to use it on multiple, you need the unlimited license.

8th November, 2017

Cronix left a reply on Trying To Connect Forge To New Github Account • 2 weeks ago

To be fair, the button used to be more obvious than it is now (just an icon). It used to say "contact support" or something similar. Don't remember now.

Cronix left a reply on Overwrite/Replace Spark Routes • 2 weeks ago

First, in config/app.php, make sure these 2 providers are in this order:

Laravel\Spark\Providers\SparkServiceProvider::class,
App\Providers\RouteServiceProvider::class

Then you can just override any spark-specific routes with your own routes in the /routes/api.php or routes/web.php files. Just put your custom routes at the top and use the same url that Spark is using (unless you want to have to edit all of the views and js files using those urls since they're hardcoded) but change the controller/method it's using to yours.

As always, you will have to clear cache in between changes if your routes/config is cached.

Cronix left a reply on Trying To Connect Forge To New Github Account • 2 weeks ago

Contact Forge support. Log into your forge account and click the round blue icon in the lower-right corner of the screen.

7th November, 2017

Cronix left a reply on Aligning Main Section And Sidebar To One Row • 2 weeks ago

I realized that after the initial post and edited it probably as you were posting. Please mark as solved.

Cronix left a reply on Please How Can I Solve This Error 404 Not Found • 2 weeks ago

Please format your code so it's readable. 3 backticks (```) on a line by itself, followed by your code, followed by 3 more backticks on its own line.

Cronix left a reply on Aligning Main Section And Sidebar To One Row • 2 weeks ago

You're creating a new col-md-8 for each post in your loop. Posts should be IN the col-md-8.


        <div class="col-md-8">
            <div class="panel panel-default">
        @foreach ($posts as $post)
                <a href="/posts/{{ $post->id }}/{{ $post->slug }}">
                    <div class="panel-heading">{{ $post->title }} </div>
                </a>
                <p>{{ $post->description }}</p>
                        <p>by 
                            @if(!empty($post->user->name)) 
                                {{ $post->user->name }} 
                            @else
                                 Anonymous
                            @endif
                        </p> 
            @endforeach 
            </div>
        </div>
        

Maybe something like that

Cronix left a reply on Eloquent Many To Many Query Searching Values From Both Tables. All Values Should Be Present. • 2 weeks ago

Also I believe pluck() returns an array of the plucked values, so you can't do toArray() on it.

Cronix left a reply on Best Way To Use Custom Css In Laravel • 2 weeks ago

Strange, it works here. You're editing the files only in the resources dir while watch is running?

Edit Your Profile
Update

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