Concrete 5.6 Block won’t show up in install list

Capture

 

As I am learning how to write blocks for Concrete 5 aka Laravel that mated with a goat behind a 7-11. I tried to install it via FTP and the new block wasn’t appearing in the list. This was due to my folder name not matching the controller name. I found the answer to this issue here → http://www.concrete5.org/community/forums/customizing_c5/new-block-isnt-recognized/#309922 . So make sure to name your folder the same name as your controller and you should be golden. Below is how a new block, loaded via FTP should look:

 

Capture

Naming your routes in Laravel

So if you are like me, you whip out code faster than a swinging nudist at Woodstock. However before you know it you’re routes are a mess, there’s money missing off the dresser and your daughter is knocked up…..I’ve seen it a hundred times…….

 

Anyway instead of doing your routes like this :

Route::get('/','FooController@method');

 

You should name your routes like this :

 

Route::get('/',array('as'=>'home','uses'=>'FooController@method'));

 

 

This makes it so that when you need to start doing redirects or simple navigation tasks you can do:

 

$url = URL::route('home');

OR…

$redirect = Redirect::route('home');

With ease. Good luck!

Laravel DB::Table()->get() returns an array of objects

Take this code for example:

DB::table('user_charges')->where('uID',$user_id)->get();

 

This will return an array of result objects from your database table ‘user_charges’. This is good to know if you are trying to access the information within the objects in a foreach loop

 

Instead of using:

 

foreach($user_charges as $key=>$value){
  echo $value;
}

Use :

foreach($user_charges as $key=>$value){

echo $value->object_name;

}

Using ‘keyup’ vs ‘keydown’ on jQuery .val() for HTML elements

So I had a code that looked like this

 

$('#invoice_details').on('keydown','#item_amount',function(){

 var qty = $(this).parent().prev().children('#item_qty').val();
 var amt = $(this).val();
 console.log(qty);

 //Do the Math
 var total = (qty * amt);

 $('#item_total').val(total);

})

 

Because of using keydown, jQuery doesn’t have time to tell what the input is until after you essentially “enter” the command from the keyboard aka “pulling your finger up off the key”. Once the keyboard sends the data, then jQuery can see the value. This is why you need to use ‘keyup’. Jquery waits for the keyup event to happen on your keyboard and then sends the results to the .val() function. Good thing to know :)

 

It should look like this:

 

$('#invoice_details').on('keyup','#item_amount',function(){

 var qty = $(this).parent().prev().children('#item_qty').val();
 var amt = $(this).val();
 console.log(qty);

 //Do the Math
 var total = (qty * amt);

 $('#item_total').val(total);

})