Showing posts with label Laravel. Show all posts
Showing posts with label Laravel. Show all posts

Monday, January 2, 2017

Soft-Delete Restore in Laravel


Tuesday, November 1, 2016

$_SERVER content in Laravel 5.3



Test basename in Laravel 5.3



parse_url in laravel




is_null and empty in laravel 5.3

So I have an empty table here :
Let's see the first output of this code :
So if we use ::find(), then variabel will pass both empty and null checker....Next how about this one :
Result :
Naaah... as we can see, if we use ::select then variabel is not empty or null... :v
buuut... let's see what happens if we check $empty->name,
Result :
We can't use $empty->name for is_null, so :
Sooo... if we just check $empty, then it won't be empty, but if we use $empty->name, it will be an empty .... yaaapss... Next code :
Again, we can't use $empty->name, so just comment it on.....aaaand... the output is like this :
So if we use ->first(), it will be an empty and null... but how about ->get();
So ->get() will fail at is_null... :D.. Then it will be safe if we use empty($var) instead of using is_null.... Ok... the last :
Like we got from get() before, is_null can't be applied, but if we change it to use ->first(), then :












Wednesday, October 19, 2016

Sunday, October 9, 2016

Simple Event-Listener Example in Laravel 5.3

So mmm....Let's create an event first by executing this command :
"php artisan make:event hisoka_event"
We will gonna see a new file in our events dir like this one :
Next... Create a listener for this event, type :
php artisan make:listener hisoka_listener --event="hisoka_event"
Result :

Next... let's register this event and it's listener to EventServiceProvider. Open eventServiceProvider.php in app/Providers/EvenServiceProvider.php, then add this line :
That will make our event and it's listener get connected each other, so when hisoka_event get's fired, hisoka_listener will gonna be executed...Next... Let's fire this event, we will gonna put it on a controller. For example here, it will be put on my HisokaController.php as shown below :
So we just need to trigger this controller when a link is clicked or another thing that we can use to do that... :D..... mmm... here I will just put it to a link like this :

Sooowh... The last thing we have to do is creating a route for hisoka_event :

Okiee... Let's try to run our awesome hisoka_event...
So when we click "Trigger hisoka event", our event will be executed and the route back to this page, but currently we can't see anything because we just put an empty event-listener here...wkwkwk...
So let's add this line to our listener :

Aaaand... let's hit the hisoka_event link again... then open laravel log... We'll gonna see our above log :


Soooo... That's all... Thank you for reading my post... ;)

Tuesday, October 4, 2016

Changing Default Timeout Value Laravel 5.3

Here is the error message for timeout :
That's happened because of this code :
So I just slept for 120 seconds and got timeout... This timeout value actually comes from php apache server, so if wanto change it, we can change it on php.ini file, but this way will gonna be changed globally. Aand if we just want to change the timeout value only for one process or class we can put this line on the top of each class like this :
We can use another method :
Both of these work... sooo... mmm... yaaaaps... that's all... :D