CoderFunda
  • Home
  • About us
    • Contact Us
    • Disclaimer
    • Privacy Policy
    • About us
  • Home
  • Php
  • HTML
  • CSS
  • JavaScript
    • JavaScript
    • Jquery
    • JqueryUI
    • Stock
  • SQL
  • Vue.Js
  • Python
  • Wordpress
  • C++
    • C++
    • C
  • Laravel
    • Laravel
      • Overview
      • Namespaces
      • Middleware
      • Routing
      • Configuration
      • Application Structure
      • Installation
    • Overview
  • DBMS
    • DBMS
      • PL/SQL
      • SQLite
      • MongoDB
      • Cassandra
      • MySQL
      • Oracle
      • CouchDB
      • Neo4j
      • DB2
      • Quiz
    • Overview
  • Entertainment
    • TV Series Update
    • Movie Review
    • Movie Review
  • More
    • Vue. Js
    • Php Question
    • Php Interview Question
    • Laravel Interview Question
    • SQL Interview Question
    • IAS Interview Question
    • PCS Interview Question
    • Technology
    • Other

07 September, 2020

Regex pattern validation in laravel

 Programing Coderfunda     September 07, 2020     No comments   

'name' => ['required', 'regex:^[A-ZÀÂÇÉÈÊËÎÏÔÛÙÜŸÑÆŒa-zàâçéèêëîïôûùüÿñæœ0-9_.,()]+$^']


'name' => ['required', 'regex:/^[A-ZÀÂÇÉÈÊËÎÏÔÛÙÜŸÑÆŒa-zàâçéèêëîïôûùüÿñæœ0-9_.,() ]+$/']


address:{
                minlength:2,
                maxlength:500,
                regex:/^[a-zA-z,-/_=. #]+$/,
            },

protected static $rules = [
'zip_code' => 'required|regex:/\b\d{5}\b/'
];
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Xampp Server Start

 Programing Coderfunda     September 07, 2020     No comments   


sudo /etc/init.d/apache2 stop
sudo /opt/lampp/lampp start
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Regex pattern validation in laravel

 Programing Coderfunda     September 07, 2020     No comments   

'name' => ['required', 'regex:^[A-ZÀÂÇÉÈÊËÎÏÔÛÙÜŸÑÆŒa-zàâçéèêëîïôûùüÿñæœ0-9_.,()]+$^']


'name' => ['required', 'regex:/^[A-ZÀÂÇÉÈÊËÎÏÔÛÙÜŸÑÆŒa-zàâçéèêëîïôûùüÿñæœ0-9_.,() ]+$/']


address:{
                minlength:2,
                maxlength:500,
                regex:/^[a-zA-z,-/_=. #]+$/,
            },

protected static $rules = [
     'zip_code' => 'required|regex:/\b\d{5}\b/'
];
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Xampp Server Start

 Programing Coderfunda     September 07, 2020     No comments   


sudo /etc/init.d/apache2 stop
sudo /opt/lampp/lampp start
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Laravel validate decimal 0-99.99

 Programing Coderfunda     September 07, 2020     No comments   

Laravel validate decimal 0-99.99
The Laravel between validation rule is actually pretty powerful and can handle decimal values as well. So there's no need to use regex just do this:
'required|between:0,99.99'

function rules(){

return [
'field_name'=> array('regex:/^(?:d*.d{1,2}|d+)$/','min:1','max:10')
];
}


Validate decimal numbers in JavaScript - IsNumeric()


// Whitespace strings:
IsNumeric(' ') == true;
IsNumeric('\t\t') == true;
IsNumeric('\n\r') == true;

// Number literals:
IsNumeric(-1) == false;
IsNumeric(0) == false;
IsNumeric(1.1) == false;
IsNumeric(8e5) == false;
Some time ago I had to implement an IsNumeric function, to find out if a variable contained a numeric value, regardless of its type, it could be a String containing a numeric value (I had to consider also exponential notation, etc.), a Number object, virtually anything could be passed to that function, I couldn't make any type assumptions, taking care of type coercion (eg. +true == 1; but true shouldn't be considered as "numeric").

2nd...................

Arrrgh! Don't listen to the regular expression answers. RegEx is icky for this, and I'm not talking just performance. It's so easy to make subtle, impossible to spot mistakes with your regular expression.
If you can't use isNaN(), this should work much better:
function IsNumeric(input)
{
return (input - 0) == input && (''+input).trim().length > 0;
}
Here's how it works:
The (input - 0) expression forces JavaScript to do type coercion on your input value; it must first be interpreted as a number for the subtraction operation. If that conversion to a number fails, the expression will result in NaN. This numeric result is then compared to the original value you passed in. Since the left hand side is now numeric, type coercion is again used. Now that the input from both sides was coerced to the same type from the same original value, you would think they should always be the same (always true). However, there's a special rule that says NaN is never equal to NaN, and so a value that can't be converted to a number (and only values that cannot be converted to numbers) will result in false.
The check on the length is for a special case involving empty strings. Also note that it falls down on your 0x89f test, but that's because in many environments that's an okay way to define a number literal. If you want to catch that specific scenario you could add an additional check. Even better, if that's your reason for not using isNaN() then just wrap your own function around isNaN() that can also do the additional check.





Laravel set between digits in validation

'required|integer|digits_between:1,10'
or
'display_post_count' => 'required|min:1|max:10',
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Get Multipal Array Data Array in Array Laravel

 Programing Coderfunda     September 07, 2020     Laravel     No comments   

Array
(
    [0] => Array
        (
            [id] => 8
            [restaurant_id] => 5
            [category_id] => 1
            [deleted_at] =>
            [created_at] => 2020-08-31T08:40:58.000000Z
            [updated_at] => 2020-08-31T08:40:58.000000Z
            [categorylistdd] => Array
                (
                    [id] => 1
                    [name] => Burger
                    [image] => Burger.svg
                    [banner] =>
                    [deleted_at] =>
                    [created_at] =>
                    [updated_at] =>
                )

        )

    [1] => Array
        (
            [id] => 9
            [restaurant_id] => 5
            [category_id] => 2
            [deleted_at] =>
            [created_at] => 2020-08-31T08:44:40.000000Z
            [updated_at] => 2020-08-31T08:44:40.000000Z
            [categorylistdd] => Array
                (
                    [id] => 2
                    [name] => Desert
                    [image] => Dessert.svg
                    [banner] =>
                    [deleted_at] =>
                    [created_at] =>
                    [updated_at] =>
                )

        )


Answer : $value['categorylistdd']['name'],

you can use Also pluck in laravel 

Note: by use get->()->plucke(' Desert ')->addArray();
You will get all data of Name, Image , banner check top On
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Laravel validate decimal 0-99.99

 Programing Coderfunda     September 07, 2020     No comments   

Laravel validate decimal 0-99.99
The Laravel between validation rule is actually pretty powerful and can handle decimal values as well. So there's no need to use regex just do this:
'required|between:0,99.99'

function rules(){

   return [
   'field_name'=> array('regex:/^(?:d*.d{1,2}|d+)$/','min:1','max:10')
        ]; 
}

Validate decimal numbers in JavaScript - IsNumeric()


// Whitespace strings:
IsNumeric(' ')    == true;
IsNumeric('\t\t') == true;
IsNumeric('\n\r') == true;

// Number literals:
IsNumeric(-1)  == false;
IsNumeric(0)   == false;
IsNumeric(1.1) == false;
IsNumeric(8e5) == false;
Some time ago I had to implement an IsNumeric function, to find out if a variable contained a numeric value, regardless of its type, it could be a String containing a numeric value (I had to consider also exponential notation, etc.), a Number object, virtually anything could be passed to that function, I couldn't make any type assumptions, taking care of type coercion (eg. +true == 1; but true shouldn't be considered as "numeric").

2nd...................

Arrrgh! Don't listen to the regular expression answers. RegEx is icky for this, and I'm not talking just performance. It's so easy to make subtle, impossible to spot mistakes with your regular expression.
If you can't use isNaN(), this should work much better:
function IsNumeric(input)
{
    return (input - 0) == input && (''+input).trim().length > 0;
}
Here's how it works:
The (input - 0) expression forces JavaScript to do type coercion on your input value; it must first be interpreted as a number for the subtraction operation. If that conversion to a number fails, the expression will result in NaN. This numeric result is then compared to the original value you passed in. Since the left hand side is now numeric, type coercion is again used. Now that the input from both sides was coerced to the same type from the same original value, you would think they should always be the same (always true). However, there's a special rule that says NaN is never equal to NaN, and so a value that can't be converted to a number (and only values that cannot be converted to numbers) will result in false.
The check on the length is for a special case involving empty strings. Also note that it falls down on your 0x89f test, but that's because in many environments that's an okay way to define a number literal. If you want to catch that specific scenario you could add an additional check. Even better, if that's your reason for not using isNaN() then just wrap your own function around isNaN() that can also do the additional check.





Laravel set between digits in validation

'required|integer|digits_between:1,10'
or
'display_post_count' => 'required|min:1|max:10',
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Get Multipal Array Data Array in Array Laravel

 Programing Coderfunda     September 07, 2020     Laravel     No comments   

Array
(
    [0] => Array
        (
            [id] => 8
            [restaurant_id] => 5
            [category_id] => 1
            [deleted_at] =>
            [created_at] => 2020-08-31T08:40:58.000000Z
            [updated_at] => 2020-08-31T08:40:58.000000Z
            [categorylistdd] => Array
                (
                    [id] => 1
                    [name] => Burger
                    [image] => Burger.svg
                    [banner] =>
                    [deleted_at] =>
                    [created_at] =>
                    [updated_at] =>
                )

        )

    [1] => Array
        (
            [id] => 9
            [restaurant_id] => 5
            [category_id] => 2
            [deleted_at] =>
            [created_at] => 2020-08-31T08:44:40.000000Z
            [updated_at] => 2020-08-31T08:44:40.000000Z
            [categorylistdd] => Array
                (
                    [id] => 2
                    [name] => Desert
                    [image] => Dessert.svg
                    [banner] =>
                    [deleted_at] =>
                    [created_at] =>
                    [updated_at] =>
                )

        )


Answer : $value['categorylistdd']['name'],

you can use Also pluck in laravel 

Note: by use get->()->plucke(' Desert ')->addArray();
You will get all data of Name, Image , banner check top On
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

03 September, 2020

Laravel: Login and Register forms on the same page

 Programing Coderfunda     September 03, 2020     No comments   

Laravel: Login and Register forms on the same page

July 1, 2019
Quite often, especially in e-shop projects, you can see a page to login or register before finishing the purchase. But Laravel has these two routes as separate login and register pages. So how to merge them together and avoid conflicts?

Notice: at the end of this article, you will find a link to Github project with a simple Laravel checkout process.

This is the pre-checkout page we’re aiming for:

On the surface, it’s pretty easy – just copy/paste all the Blade code from /resources/views/auth/login.blade.php and /resources/views/auth/register.blade.php into one common, let’s say, /resources/views/checkout.blade.php. And that’s true, but that’s only one part of the story.

The problem arises because of the same names of fields.

Login form has this:

<input id="email" type="email"
       class="form-control @error('email') is-invalid @enderror" name="email"
       value="{{ old('email') }}" required autocomplete="email" autofocus>
Register form has this:

<input id="email" type="email"
       class="form-control @error('email') is-invalid @enderror" name="register_email"
       value="{{ old('email') }}" required autocomplete="email">
See the difference? I don’t either. Except for autofocus, which is irrelevant in our case.

And you would think that it’s ok, because those two forms POST to different URLs and perform different actions. But in case of failing validation, you get errors on both forms instead of one. For example, in case of invalid credentials when you login, you see this:


Step 1. Rename the fields in one of the form.
For this example, we will rename the fields in the registration part, adding “register_” prefix to them:

<input id="register_name" type="text"
       class="form-control @error('register_name') is-invalid @enderror" name="register_name"
       value="{{ old('register_name') }}" required autocomplete="name" autofocus>

@error('register_name')
    <span class="invalid-feedback" role="alert">
        <strong>{{ $message }}</strong>
    </span>
@enderror

...

<input id="register_email" type="email"
       class="form-control @error('register_email') is-invalid @enderror" name="register_email"
       value="{{ old('register_email') }}" required autocomplete="email">

@error('register_email')
    <span class="invalid-feedback" role="alert">
        <strong>{{ $message }}</strong>
    </span>
@enderror

...

<input id="register_password" type="password"
       class="form-control @error('register_password') is-invalid @enderror"
       name="register_password"
       required autocomplete="new-password">

@error('register_password')
    <span class="invalid-feedback" role="alert">
        <strong>{{ $message }}</strong>
    </span>
@enderror

...

<input id="password-confirm" type="password" class="form-control"
    name="register_password_confirmation" required autocomplete="new-password">
Step 2. Override validator in RegisterController.
Here’s the method validator() from the original app/Http/Controllers/Auth/RegisterController.php, that comes from the framework itself:

protected function validator(array $data)
{
    return Validator::make($data, [
        'name' => ['required', 'string', 'max:255'],
        'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
        'password' => ['required', 'string', 'min:8', 'confirmed'],
    ]);
}
So, we need to override that validator with our own, adding some rules to it. In fact, we just need to use the renamed fields from Step 1, and then assign their names properly. Here’s the code:

protected function validator(array $data)
{
    $validator = Validator::make($data, [
        'register_name' => ['required', 'string', 'max:255'],
        'register_email' => ['required', 'string', 'email', 'max:255', 'unique:users,email'],
        'register_password' => ['required', 'string', 'min:8', 'confirmed'],
    ]);
    $validator->setAttributeNames([
        'register_name' => 'name',
        'register_email' => 'email',
        'register_password' => 'password',
    ]);

    return $validator;
}
As you can see, we now use register_xxx fields instead of just xxx, but we also need to make sure they return validation errors with their “original” names, so for that we use less-known setAttributeNames() method. It’s not officially mentioned in documentation, but you see another example of its use in this StackOverflow thread.

And that’s it! Now, we have separate two forms on the same “checkout” page.

Bonus: E-shop Checkout Demo Project
As a part of this article, we actually created a typical checkout process mini-project, which is available on Github for you to see. Homepage contains list of products, you can buy each of them, and then session has your “cart” which you can checkout at any time, by clicking “Checkout” on top.
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Laravel: Login and Register forms on the same page

 Programing Coderfunda     September 03, 2020     No comments   

Laravel: Login and Register forms on the same page

July 1, 2019
Quite often, especially in e-shop projects, you can see a page to login or register before finishing the purchase. But Laravel has these two routes as separate login and register pages. So how to merge them together and avoid conflicts?

Notice: at the end of this article, you will find a link to Github project with a simple Laravel checkout process.

This is the pre-checkout page we’re aiming for:

On the surface, it’s pretty easy – just copy/paste all the Blade code from /resources/views/auth/login.blade.php and /resources/views/auth/register.blade.php into one common, let’s say, /resources/views/checkout.blade.php. And that’s true, but that’s only one part of the story.

The problem arises because of the same names of fields.

Login form has this:

<input id="email" type="email"
       class="form-control @error('email') is-invalid @enderror" name="email"
       value="{{ old('email') }}" required autocomplete="email" autofocus>
Register form has this:

<input id="email" type="email"
       class="form-control @error('email') is-invalid @enderror" name="register_email"
       value="{{ old('email') }}" required autocomplete="email">
See the difference? I don’t either. Except for autofocus, which is irrelevant in our case.

And you would think that it’s ok, because those two forms POST to different URLs and perform different actions. But in case of failing validation, you get errors on both forms instead of one. For example, in case of invalid credentials when you login, you see this:


Step 1. Rename the fields in one of the form.
For this example, we will rename the fields in the registration part, adding “register_” prefix to them:

<input id="register_name" type="text"
       class="form-control @error('register_name') is-invalid @enderror" name="register_name"
       value="{{ old('register_name') }}" required autocomplete="name" autofocus>

@error('register_name')
    <span class="invalid-feedback" role="alert">
        <strong>{{ $message }}</strong>
    </span>
@enderror

...

<input id="register_email" type="email"
       class="form-control @error('register_email') is-invalid @enderror" name="register_email"
       value="{{ old('register_email') }}" required autocomplete="email">

@error('register_email')
    <span class="invalid-feedback" role="alert">
        <strong>{{ $message }}</strong>
    </span>
@enderror

...

<input id="register_password" type="password"
       class="form-control @error('register_password') is-invalid @enderror"
       name="register_password"
       required autocomplete="new-password">

@error('register_password')
    <span class="invalid-feedback" role="alert">
        <strong>{{ $message }}</strong>
    </span>
@enderror

...

<input id="password-confirm" type="password" class="form-control"
    name="register_password_confirmation" required autocomplete="new-password">
Step 2. Override validator in RegisterController.
Here’s the method validator() from the original app/Http/Controllers/Auth/RegisterController.php, that comes from the framework itself:

protected function validator(array $data)
{
    return Validator::make($data, [
        'name' => ['required', 'string', 'max:255'],
        'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
        'password' => ['required', 'string', 'min:8', 'confirmed'],
    ]);
}
So, we need to override that validator with our own, adding some rules to it. In fact, we just need to use the renamed fields from Step 1, and then assign their names properly. Here’s the code:

protected function validator(array $data)
{
    $validator = Validator::make($data, [
        'register_name' => ['required', 'string', 'max:255'],
        'register_email' => ['required', 'string', 'email', 'max:255', 'unique:users,email'],
        'register_password' => ['required', 'string', 'min:8', 'confirmed'],
    ]);
    $validator->setAttributeNames([
        'register_name' => 'name',
        'register_email' => 'email',
        'register_password' => 'password',
    ]);

    return $validator;
}
As you can see, we now use register_xxx fields instead of just xxx, but we also need to make sure they return validation errors with their “original” names, so for that we use less-known setAttributeNames() method. It’s not officially mentioned in documentation, but you see another example of its use in this StackOverflow thread.

And that’s it! Now, we have separate two forms on the same “checkout” page.

Bonus: E-shop Checkout Demo Project
As a part of this article, we actually created a typical checkout process mini-project, which is available on Github for you to see. Homepage contains list of products, you can buy each of them, and then session has your “cart” which you can checkout at any time, by clicking “Checkout” on top.
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Advanced Laravel: 14 Topics and Links to Learn Them

 Programing Coderfunda     September 03, 2020     Laravel     No comments   

Advanced Laravel: 14 Topics and Links to Learn Them

Quite often I get a question from junior developers like “how to get better at Laravel”, and there’s so much to study potentially that I decided to gather the topics and classify them somehow. Let’s begin.


Topic 1. Sending emails and notifications
It seems like a topic for basic Laravel developer, but while it’s easy to send emails, but the whole system of various notifications is much deeper, and worth studying. Sub-topics:

Sending Laravel notifications (not only email, but also Slack, SMS etc);
Email templates – customization, Markdown messages;
Putting emails into queue (more on that later);
Using external services to send emails – Mailgun, Mailchimp etc.

Topic 2. Queues and Jobs
Modern web-applications are much more than just browser-based synchronous page rendering, a lot of stuff is happening in the background on the server, while user may not even be online. So queues are getting more and more vital to learn. Also, there are a few tools related to the queues mechanism.

Sub-topics and links:

Laravel Queues and Jobs official documentation;
Laravel Horizon – dashboard to monitor queues;
Redis – most popular driver to use for queues (you need to be able to install and configure it);
Jobs, Queues and Scheduling Tasks – my video from the course “How to Structure Laravel Project”;
Demystifying Laravel Queues – article on Dev.to.
Side note: Jobs may be not queue-able and just run whenever you ask them, maybe even in sync mode, but it may be a good practice to structure your project code into Jobs, for clarity.

Topic 3. Advanced Eloquent and DB Operations
Eloquent is a great Laravel mechanism to deal with the database, but there’s so many less-known functions under the hood, like: Observers, Accessors/Mutators, Seeding, “magic methods” like firstOrCreate(), Collections etc.

Sub-topics and links:

Eloquent: Expert Level – my course on the topic;
Eloquent Relationships: The Ultimate Guide;
Model Observers – official documentation;
Accessors and Mutators – official documentation;
Collection Essentials – video from Laracasts.

Topic 4. Advanced Error/Exception Managing and Preventing
Bugs happen everyday, and that’s normal. But you can do a lot of things to prevent them or help the team to fix them easier. Using try-catch blocks, creating exceptions, configuring logging parameters, using tools like Bugsnag/Rollbar/Sentry, sending bug notifications to Slack/email etc.

Sub-topics and links:

Laravel Exceptions: How to Catch, Handle and Create Your Own;
Laravel API Errors and Exceptions: How to Return Responses;
PHP Try Catch: Basics & Advanced PHP Exception Handling Tutorial;
Laravel Error Handling – official documentation.

Topic 5. Creating Artisan Commands
We all probably use commands like “php artisan migrate” or “php artisan make:model“, but it’s often useful to create your own command, and potentially put it as a job into queue (see Topic 2 above).

Sub-topics and links:

Writing Artisan Commands – official documentation;
List of 16 artisan make:XXXX Commands with Parameters;
Writing Custom Laravel Artisan Commands – article from Laravel News.
Topic 6. APIs: Resources, Auth and Passport
This one is pretty huge – the whole world is going API, and you need to learn it. A while ago I would recommend learning Lumen, but now it lost popularity and performance advantage over main Laravel.

Sub-topics and links:

Eloquent: API Resources – official documentation;
Laravel API Tutorial: How to Build and Test a RESTful API – article from Toptal;
Build a REST API with Laravel API resources – article from Pusher;
Laravel API Authentication – official documentation;
Laravel Passport – official documentation;
Laravel API Errors and Exceptions: How to Return Responses.

Topic 7. Events and Listeners
Small topic, representing one of the design patterns in Laravel. You can fire an event, and have a separate class “listening” for when it happens.

Sub-topics and links:

Laravel Events – official documentation;
Custom Events in Laravel – article from TutsPlus.

Topic 8. Payments and Cashier
If you work on any serious project, probably some kind of payment will be involved. There are various payment methods/gateways, depending on the world region you’re in, but I would recommend to learn handling Stripe anyway, even if you don’t use it in production.

Sub-topics and links:

Stripe Payments in Laravel: The Ultimate Guide;
PayPal payments in Laravel: The Ultimate Guide;
Laravel Cashier – official documentation;
Laravel Cashier (Braintree) – official documentation.

Topic 9. Automated Testing, TDD and Dusk
This is a hot topic, with constant debates around it. Should we do unit testing? Should we do TDD? (test-driven development) What kind of tests do we write? How to make them run smoothly?

My personal take is that you have to have some automated tests, for the crucial parts of your application – especially related to money transactions, or main authentication. Basically, test everything that would make you lose your job, if it fails. Testing everything else – not a priority.

Sub-topics and links:

Laravel Testing: Getting Started – official documentation;
Test-Driven Laravel – awesome course by Adam Wathan, highly recommended;
Laravel Dusk – official documentation;
Build A Laravel App With TDD – Laracasts Series;
How to build a Laravel REST API with Test-Driven Development – article from freeCodeCamp;
Simple TDD in Laravel with 11 steps – article from Medium.

Topic 10. Deployment to Servers and Continuous Integration
Related to the previous topic – part of the deployment of your features, you should run your automated tests on some kind of staging server, and ideally set it up to run automatically.

Some of this knowledge isn’t specific to Laravel – you need to know how to set up and configure a new server (or use tools for it), how to do git branching and how to push your code correctly (especially if you work in a team), how to do zero-time deployment, rollback if something happens etc.

Sub-topics and links:

Laravel Deployment – official documentation;
How to Deploy Laravel Projects to Live Server: The Ultimate Guide;
Laravel Forge – tool to create/provision new servers for Laravel in minutes (and see my video DEMO: New Server and Deployment with Laravel Forge);
Envoyer.io – zero-time PHP deployment, official tool by Laravel (again, my video – How to Deploy Laravel Project with Envoyer);
Laravel Continuous Deployment With CircleCI and Deployer.

Topic 11. Package Development
At some point you grow a few projects that may require the same functionality, so it makes sense to turn it into a package, and maybe release it as open-source.

Sub-topics and links:

PHP Package Development – course by Marcel Pociot;
Laravel Package Development – video course on YouTube;
Package Development – official documentation.


Topic 12. Laravel Scout Search and Algolia
If you’re dealing with text-based search in a big database (like products in e-shop), you would definitely use a search mechanism like Laravel Scout. There are multiple drivers for it, I personally use Algolia and their free plan is more than sufficient for small projects.

Sub-topics and links:

Laravel Scout – official documentation;
Getting started with Laravel Scout and Vue Instant Search – article from Algolia;
Laravel Scout Algolia Search Tutorial With Example.


Topic 13. Socialite and OAuth
If you’ve ever seen a button “Login with Facebook” or “Sign in with Google”, it is usually powered by OAuth protocol, and its implementation tool in Laravel is called Socialite. Pretty easy to install and configure, and valuable to learn.

Sub-topics and links:

Laravel Socialite – official documentation;
From Google+ API to Google Sign In with Laravel Socialite;
Add Facebook, Twitter, and GitHub Login To Laravel with Socialite.

Topic 14. Vue.js
This may sound controversial, but these days it’s almost a must to be able to at least understand how front-end coding works. Of course, every employer is looking for a full-stack developer, but my personal opinion is that most of us are back-enders with some front-end knowledge, or vice versa, you can’t be good at both.

That said, you need to be able to construct a basic Vue.js structure to work with your Laravel API, also taking care of authentication and error handling.

Of course, you may choose other framework like Angular or React, but it seems that Vue is the most “Laravel-friendly” and supported by community, with articles and tutorials.

Sub-topics and links:

Laravel – JavaScript & CSS Scaffolding – official documentation;
The Ultimate Vue.js & Laravel CRUD Tutorial;
Quick Start with Laravel 5.5 + Vue.js: Simple CRUD Project;
Learn Vue 2: Step By Step – course from Laracasts.
So, this is my list. There are much more things to learn, outside of these topics, and with every new project you will bump into something you need to google/stackoverflow. And that’s ok. Especially these days, things are always evolving with enormous pace, so even if you master it all now, you may have to re-learn in a few years.

Anything I’ve missed here? Anything you would advise to study, to become an Advanced Laravel master?
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Advanced Laravel: 14 Topics and Links to Learn Them

 Programing Coderfunda     September 03, 2020     Laravel     No comments   

Advanced Laravel: 14 Topics and Links to Learn Them

Quite often I get a question from junior developers like “how to get better at Laravel”, and there’s so much to study potentially that I decided to gather the topics and classify them somehow. Let’s begin.


Topic 1. Sending emails and notifications
It seems like a topic for basic Laravel developer, but while it’s easy to send emails, but the whole system of various notifications is much deeper, and worth studying. Sub-topics:

Sending Laravel notifications (not only email, but also Slack, SMS etc);
Email templates – customization, Markdown messages;
Putting emails into queue (more on that later);
Using external services to send emails – Mailgun, Mailchimp etc.

Topic 2. Queues and Jobs
Modern web-applications are much more than just browser-based synchronous page rendering, a lot of stuff is happening in the background on the server, while user may not even be online. So queues are getting more and more vital to learn. Also, there are a few tools related to the queues mechanism.

Sub-topics and links:

Laravel Queues and Jobs official documentation;
Laravel Horizon – dashboard to monitor queues;
Redis – most popular driver to use for queues (you need to be able to install and configure it);
Jobs, Queues and Scheduling Tasks – my video from the course “How to Structure Laravel Project”;
Demystifying Laravel Queues – article on Dev.to.
Side note: Jobs may be not queue-able and just run whenever you ask them, maybe even in sync mode, but it may be a good practice to structure your project code into Jobs, for clarity.

Topic 3. Advanced Eloquent and DB Operations
Eloquent is a great Laravel mechanism to deal with the database, but there’s so many less-known functions under the hood, like: Observers, Accessors/Mutators, Seeding, “magic methods” like firstOrCreate(), Collections etc.

Sub-topics and links:

Eloquent: Expert Level – my course on the topic;
Eloquent Relationships: The Ultimate Guide;
Model Observers – official documentation;
Accessors and Mutators – official documentation;
Collection Essentials – video from Laracasts.

Topic 4. Advanced Error/Exception Managing and Preventing
Bugs happen everyday, and that’s normal. But you can do a lot of things to prevent them or help the team to fix them easier. Using try-catch blocks, creating exceptions, configuring logging parameters, using tools like Bugsnag/Rollbar/Sentry, sending bug notifications to Slack/email etc.

Sub-topics and links:

Laravel Exceptions: How to Catch, Handle and Create Your Own;
Laravel API Errors and Exceptions: How to Return Responses;
PHP Try Catch: Basics & Advanced PHP Exception Handling Tutorial;
Laravel Error Handling – official documentation.

Topic 5. Creating Artisan Commands
We all probably use commands like “php artisan migrate” or “php artisan make:model“, but it’s often useful to create your own command, and potentially put it as a job into queue (see Topic 2 above).

Sub-topics and links:

Writing Artisan Commands – official documentation;
List of 16 artisan make:XXXX Commands with Parameters;
Writing Custom Laravel Artisan Commands – article from Laravel News.
Topic 6. APIs: Resources, Auth and Passport
This one is pretty huge – the whole world is going API, and you need to learn it. A while ago I would recommend learning Lumen, but now it lost popularity and performance advantage over main Laravel.

Sub-topics and links:

Eloquent: API Resources – official documentation;
Laravel API Tutorial: How to Build and Test a RESTful API – article from Toptal;
Build a REST API with Laravel API resources – article from Pusher;
Laravel API Authentication – official documentation;
Laravel Passport – official documentation;
Laravel API Errors and Exceptions: How to Return Responses.

Topic 7. Events and Listeners
Small topic, representing one of the design patterns in Laravel. You can fire an event, and have a separate class “listening” for when it happens.

Sub-topics and links:

Laravel Events – official documentation;
Custom Events in Laravel – article from TutsPlus.

Topic 8. Payments and Cashier
If you work on any serious project, probably some kind of payment will be involved. There are various payment methods/gateways, depending on the world region you’re in, but I would recommend to learn handling Stripe anyway, even if you don’t use it in production.

Sub-topics and links:

Stripe Payments in Laravel: The Ultimate Guide;
PayPal payments in Laravel: The Ultimate Guide;
Laravel Cashier – official documentation;
Laravel Cashier (Braintree) – official documentation.

Topic 9. Automated Testing, TDD and Dusk
This is a hot topic, with constant debates around it. Should we do unit testing? Should we do TDD? (test-driven development) What kind of tests do we write? How to make them run smoothly?

My personal take is that you have to have some automated tests, for the crucial parts of your application – especially related to money transactions, or main authentication. Basically, test everything that would make you lose your job, if it fails. Testing everything else – not a priority.

Sub-topics and links:

Laravel Testing: Getting Started – official documentation;
Test-Driven Laravel – awesome course by Adam Wathan, highly recommended;
Laravel Dusk – official documentation;
Build A Laravel App With TDD – Laracasts Series;
How to build a Laravel REST API with Test-Driven Development – article from freeCodeCamp;
Simple TDD in Laravel with 11 steps – article from Medium.

Topic 10. Deployment to Servers and Continuous Integration
Related to the previous topic – part of the deployment of your features, you should run your automated tests on some kind of staging server, and ideally set it up to run automatically.

Some of this knowledge isn’t specific to Laravel – you need to know how to set up and configure a new server (or use tools for it), how to do git branching and how to push your code correctly (especially if you work in a team), how to do zero-time deployment, rollback if something happens etc.

Sub-topics and links:

Laravel Deployment – official documentation;
How to Deploy Laravel Projects to Live Server: The Ultimate Guide;
Laravel Forge – tool to create/provision new servers for Laravel in minutes (and see my video DEMO: New Server and Deployment with Laravel Forge);
Envoyer.io – zero-time PHP deployment, official tool by Laravel (again, my video – How to Deploy Laravel Project with Envoyer);
Laravel Continuous Deployment With CircleCI and Deployer.

Topic 11. Package Development
At some point you grow a few projects that may require the same functionality, so it makes sense to turn it into a package, and maybe release it as open-source.

Sub-topics and links:

PHP Package Development – course by Marcel Pociot;
Laravel Package Development – video course on YouTube;
Package Development – official documentation.


Topic 12. Laravel Scout Search and Algolia
If you’re dealing with text-based search in a big database (like products in e-shop), you would definitely use a search mechanism like Laravel Scout. There are multiple drivers for it, I personally use Algolia and their free plan is more than sufficient for small projects.

Sub-topics and links:

Laravel Scout – official documentation;
Getting started with Laravel Scout and Vue Instant Search – article from Algolia;
Laravel Scout Algolia Search Tutorial With Example.


Topic 13. Socialite and OAuth
If you’ve ever seen a button “Login with Facebook” or “Sign in with Google”, it is usually powered by OAuth protocol, and its implementation tool in Laravel is called Socialite. Pretty easy to install and configure, and valuable to learn.

Sub-topics and links:

Laravel Socialite – official documentation;
From Google+ API to Google Sign In with Laravel Socialite;
Add Facebook, Twitter, and GitHub Login To Laravel with Socialite.

Topic 14. Vue.js
This may sound controversial, but these days it’s almost a must to be able to at least understand how front-end coding works. Of course, every employer is looking for a full-stack developer, but my personal opinion is that most of us are back-enders with some front-end knowledge, or vice versa, you can’t be good at both.

That said, you need to be able to construct a basic Vue.js structure to work with your Laravel API, also taking care of authentication and error handling.

Of course, you may choose other framework like Angular or React, but it seems that Vue is the most “Laravel-friendly” and supported by community, with articles and tutorials.

Sub-topics and links:

Laravel – JavaScript & CSS Scaffolding – official documentation;
The Ultimate Vue.js & Laravel CRUD Tutorial;
Quick Start with Laravel 5.5 + Vue.js: Simple CRUD Project;
Learn Vue 2: Step By Step – course from Laracasts.
So, this is my list. There are much more things to learn, outside of these topics, and with every new project you will bump into something you need to google/stackoverflow. And that’s ok. Especially these days, things are always evolving with enormous pace, so even if you master it all now, you may have to re-learn in a few years.

Anything I’ve missed here? Anything you would advise to study, to become an Advanced Laravel master?
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

02 September, 2020

Laravel 5 Eloquent where and or in Clauses

 Programing Coderfunda     September 02, 2020     No comments   

140
Using advanced wheres:
CabRes::where('m__Id', 46)
->where('t_Id', 2)
->where(function($q) {
$q
->where('Cab', 2)
->orWhere('Cab', 4);
})
->get();
Or, even better, using whereIn():
CabRes::where('m__Id', 46)
->where('t_Id', 2)
->whereIn('Cab', $cabIds)
->get();
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg
Newer Posts Older Posts Home

Meta

Popular Posts

  • Generate Migrations from an Existing Database With the Migration Generator Package
    Laravel Migration Generator Migration Generator for Laravel is a package by Bennett Treptow to generate migrations from existing database ...
  • Tailwindcss best practices for responsive design
    Tailwind CSS provides powerful utilities for responsive design out of the box. To use it effectively and maintain clean, scalable code, here...
  • Search Through Models with Laravel Searchable
      Laravel Searchable   is a package by   Spatie   to search through models and other sources pragmatically. Using this package, you can get ...
  • Laravel Razorpay Integration | Payment gateway integration Laravel in 30 mins | Laravel Razorpay
    1 Integration of Razorpay with Laravel. In this tutorial, I have taught how to integrate payment gateway with laravel with mini-project. If...
  • Vue.js Render functions
        Vue.js Render functions Vue.js recommends us to use templates to build HTML. Here, we can use the render function as a closer-to-the-co...

Categories

  • Ajax (26)
  • Bootstrap (30)
  • DBMS (42)
  • HTML (12)
  • HTML5 (45)
  • JavaScript (10)
  • Jquery (34)
  • Jquery UI (2)
  • JqueryUI (32)
  • Laravel (1017)
  • Laravel Tutorials (23)
  • Laravel-Question (6)
  • Magento (9)
  • Magento 2 (95)
  • MariaDB (1)
  • MySql Tutorial (2)
  • PHP-Interview-Questions (3)
  • Php Question (13)
  • Python (36)
  • RDBMS (13)
  • SQL Tutorial (79)
  • Vue.js Tutorial (69)
  • Wordpress (150)
  • Wordpress Theme (3)
  • codeigniter (108)
  • oops (4)
  • php (853)

Social Media Links

  • Follow on Twitter
  • Like on Facebook
  • Subscribe on Youtube
  • Follow on Instagram

Pages

  • Home
  • Contact Us
  • Privacy Policy
  • About us

Blog Archive

  • ▼  2026 (3)
    • ▼  07/26 - 08/02 (2)
      • A stormwater pond in Calgary appears filled with P...
      • Inside Kriti Sanon's duplex sea-facing penthouse w...
    • ►  06/28 - 07/05 (1)
  • ►  2025 (4)
    • ►  07/06 - 07/13 (2)
    • ►  06/29 - 07/06 (2)
  • ►  2024 (486)
    • ►  09/15 - 09/22 (30)
    • ►  09/08 - 09/15 (35)
    • ►  09/01 - 09/08 (35)
    • ►  08/11 - 08/18 (2)
    • ►  08/04 - 08/11 (33)
    • ►  07/28 - 08/04 (30)
    • ►  07/07 - 07/14 (11)
    • ►  06/30 - 07/07 (35)
    • ►  06/23 - 06/30 (5)
    • ►  06/02 - 06/09 (31)
    • ►  05/26 - 06/02 (20)
    • ►  05/05 - 05/12 (29)
    • ►  04/28 - 05/05 (26)
    • ►  04/07 - 04/14 (10)
    • ►  03/31 - 04/07 (34)
    • ►  03/24 - 03/31 (10)
    • ►  03/03 - 03/10 (35)
    • ►  02/25 - 03/03 (15)
    • ►  02/04 - 02/11 (22)
    • ►  01/28 - 02/04 (30)
    • ►  01/07 - 01/14 (8)
  • ►  2023 (484)
    • ►  12/31 - 01/07 (35)
    • ►  12/24 - 12/31 (10)
    • ►  12/03 - 12/10 (33)
    • ►  11/26 - 12/03 (20)
    • ►  11/05 - 11/12 (35)
    • ►  10/29 - 11/05 (20)
    • ►  10/22 - 10/29 (9)
    • ►  10/15 - 10/22 (7)
    • ►  10/08 - 10/15 (9)
    • ►  10/01 - 10/08 (10)
    • ►  09/24 - 10/01 (9)
    • ►  09/17 - 09/24 (9)
    • ►  09/10 - 09/17 (7)
    • ►  09/03 - 09/10 (9)
    • ►  08/27 - 09/03 (9)
    • ►  08/20 - 08/27 (8)
    • ►  08/13 - 08/20 (8)
    • ►  08/06 - 08/13 (8)
    • ►  07/30 - 08/06 (8)
    • ►  07/23 - 07/30 (7)
    • ►  07/16 - 07/23 (8)
    • ►  07/09 - 07/16 (7)
    • ►  07/02 - 07/09 (8)
    • ►  06/25 - 07/02 (7)
    • ►  06/18 - 06/25 (7)
    • ►  06/11 - 06/18 (7)
    • ►  06/04 - 06/11 (11)
    • ►  05/28 - 06/04 (7)
    • ►  05/21 - 05/28 (8)
    • ►  05/14 - 05/21 (11)
    • ►  05/07 - 05/14 (7)
    • ►  04/30 - 05/07 (7)
    • ►  04/23 - 04/30 (8)
    • ►  04/16 - 04/23 (9)
    • ►  04/09 - 04/16 (7)
    • ►  04/02 - 04/09 (4)
    • ►  03/26 - 04/02 (21)
    • ►  03/19 - 03/26 (2)
    • ►  03/12 - 03/19 (9)
    • ►  03/05 - 03/12 (26)
    • ►  02/26 - 03/05 (25)
    • ►  01/15 - 01/22 (7)
    • ►  01/08 - 01/15 (1)
  • ►  2022 (1037)
    • ►  12/11 - 12/18 (13)
    • ►  12/04 - 12/11 (1)
    • ►  11/27 - 12/04 (40)
    • ►  11/06 - 11/13 (1)
    • ►  10/16 - 10/23 (13)
    • ►  09/04 - 09/11 (5)
    • ►  08/21 - 08/28 (24)
    • ►  08/14 - 08/21 (24)
    • ►  07/03 - 07/10 (9)
    • ►  06/19 - 06/26 (3)
    • ►  05/29 - 06/05 (3)
    • ►  05/22 - 05/29 (3)
    • ►  05/15 - 05/22 (109)
    • ►  05/01 - 05/08 (7)
    • ►  04/24 - 05/01 (7)
    • ►  04/17 - 04/24 (64)
    • ►  04/10 - 04/17 (115)
    • ►  04/03 - 04/10 (73)
    • ►  03/27 - 04/03 (77)
    • ►  03/13 - 03/20 (2)
    • ►  03/06 - 03/13 (25)
    • ►  02/27 - 03/06 (18)
    • ►  02/20 - 02/27 (153)
    • ►  02/13 - 02/20 (187)
    • ►  01/30 - 02/06 (45)
    • ►  01/23 - 01/30 (15)
    • ►  01/16 - 01/23 (1)
  • ►  2021 (412)
    • ►  10/24 - 10/31 (2)
    • ►  07/25 - 08/01 (1)
    • ►  07/11 - 07/18 (10)
    • ►  06/13 - 06/20 (29)
    • ►  05/23 - 05/30 (1)
    • ►  05/02 - 05/09 (24)
    • ►  04/25 - 05/02 (24)
    • ►  04/18 - 04/25 (112)
    • ►  04/11 - 04/18 (1)
    • ►  04/04 - 04/11 (6)
    • ►  03/28 - 04/04 (86)
    • ►  03/21 - 03/28 (19)
    • ►  03/14 - 03/21 (2)
    • ►  03/07 - 03/14 (10)
    • ►  02/28 - 03/07 (1)
    • ►  02/21 - 02/28 (29)
    • ►  02/14 - 02/21 (13)
    • ►  02/07 - 02/14 (12)
    • ►  01/31 - 02/07 (6)
    • ►  01/17 - 01/24 (2)
    • ►  01/10 - 01/17 (8)
    • ►  01/03 - 01/10 (14)
  • ►  2020 (376)
    • ►  12/27 - 01/03 (37)
    • ►  12/20 - 12/27 (92)
    • ►  12/13 - 12/20 (29)
    • ►  12/06 - 12/13 (37)
    • ►  11/29 - 12/06 (4)
    • ►  11/15 - 11/22 (14)
    • ►  11/08 - 11/15 (8)
    • ►  11/01 - 11/08 (2)
    • ►  10/18 - 10/25 (14)
    • ►  10/11 - 10/18 (16)
    • ►  10/04 - 10/11 (10)
    • ►  09/20 - 09/27 (10)
    • ►  09/06 - 09/13 (19)
    • ►  08/30 - 09/06 (26)
    • ►  08/23 - 08/30 (4)
    • ►  08/16 - 08/23 (2)
    • ►  07/12 - 07/19 (48)
    • ►  05/17 - 05/24 (2)
    • ►  01/05 - 01/12 (2)
  • ►  2019 (74)
    • ►  07/07 - 07/14 (6)
    • ►  06/16 - 06/23 (6)
    • ►  02/10 - 02/17 (17)
    • ►  01/13 - 01/20 (37)
    • ►  01/06 - 01/13 (8)
  • ►  2018 (376)
    • ►  12/30 - 01/06 (24)
    • ►  12/16 - 12/23 (8)
    • ►  12/09 - 12/16 (98)
    • ►  12/02 - 12/09 (16)
    • ►  11/18 - 11/25 (36)
    • ►  11/04 - 11/11 (18)
    • ►  10/28 - 11/04 (10)
    • ►  10/21 - 10/28 (26)
    • ►  10/14 - 10/21 (52)
    • ►  10/07 - 10/14 (4)
    • ►  09/30 - 10/07 (2)
    • ►  09/23 - 09/30 (68)
    • ►  09/16 - 09/23 (4)
    • ►  09/09 - 09/16 (4)
    • ►  08/26 - 09/02 (6)

Data Publish News

Loading...

Al Jazeera – Breaking News, World News and Video from Al Jazeera

Loading...

Laravel News

Loading...

Copyright © CoderFunda | Powered by Blogger
Design by Coderfunda | Blogger Theme by Coderfunda | Distributed By Coderfunda