Wednesday, October 31, 2018

Laravel 5.5 create custom facade example from scratch

In this article, here i will give you step by step guide to create a custom facade in Laravel 5.5 application. You can also learn how to create custom service provider and custom aliases for your class in laravel 5.
Ok So, We may need to create custom facade for creating general helper, some method that always use in whole application like here in example, i created getUserImage() method for getting pull path of user image, Here i will check file is exist or not on following on path then return full path. But it is as an example, So that way you can create your method that you reuse in whole application.
So, Just follow few step to create custom facades in Laravel 5.5 application

How To Create Custom Helper In Laravel 5.5

Today in this article we are share with you how to make custom helper in laravel. you need some time make your own custom helper for some repeted code or logic. like get fullname of current user. convert currency helper, number formate etc...
So, you can create above all logic in one time in one helper function then you can use this custom helper function in everywere in laravel application. you use this custom helper in your laravel blade file and also use in any controller.
in this article we are make one custom helper which get current user full name and how to use this custom helper in blade file and laraval controller.
Please follow step to create custom helper in laravel application

How to Create a Laravel Helper

As we discussed earlier, there are plenty of helpers available in the core of the Laravel framework. They are grouped together based on the functionality they provide. Here’s a list of helper groups.
Helpers in this group provide functionality to manipulate array elements. More often than not, you're in the situation where you want to perform different operations on array elements. So this is the place where you should look first to see if what you're looking for already exists.
I find helpers in this category most useful. They return the fully qualified path of different directories like app, storage, config, and the like. I bet you're using most of these helpers already in your Laravel application.
String manipulation is something inevitable in your day-to-day application development. Although there are plenty of string manipulation functions provided by PHP itself, you'll find a few more useful goodies in this section.
You'll find very few in this category, but they are used throughout the application. They are used to generate route, asset, and form action URLs.
This category contains helpers that provide a variety of functionalities ranging from logging to debugging and many more.

Tuesday, October 30, 2018

Dependency injection vs just using facades?

Dependency injection vs just using facades?

Hi guys, I see a lot of people recommending this:
use App\User;

class BlahController extends Controller {

    protected $user;

    public function __construct(User $user)
    {
        $this->user = $user;
    }

    public function show($id)
    {
        return $this->user->find($id);
    }

}
Over this:
use App\User;

class BlahController extends Controller {

    public function show($id)
    {
        return User::find($id);
    }

}

REST API CRUD With Laravel 5 and Fractal

Laravel Rest Api CRUD

Monday, October 29, 2018

Dirty Forms is a jQuery plugin to help prevent users from losing data when editing forms.

Dirty Forms is a jQuery plugin to help prevent users from losing data when editing forms.
Dirty Forms will alert a user when they attempt to leave a page without submitting a form they have entered data into. It alerts them in a modal popup box, and also falls back to the browser's default onBeforeUnload handler for events outside the scope of the document such as, but not limited to, page refreshes and browser navigation buttons.
Oh, and it's pretty easy to use.
$('form').dirtyForms();
Existing solutions were not flexible enough, so Dirty Forms was created to support a wider range of scenarios including support for dynamically added inputs and forms, TinyMCE and CKEditor rich text editor "dirtyness" support, custom widget "dirtyness" support, interoperability with any dialog framework (or the browser's built-in dialog), a "stash" that can be used in cases where dialogs don't have stacking support and you want to have a form inside of a dialog, and correct handling of events to refire when the user decides to proceed to an off-page destination.

Sunday, October 28, 2018

Calculating Area

Area is a measure of how much space there is inside a shape.  Calculating the area of a shape or surface can be useful in everyday life – for example you may need to know how much paint to buy to cover a wall or how much grass seed you need to sow a lawn.
This page covers the essentials you need to know in order to understand and calculate the areas of common shapes including squares and rectangles, triangles and circles.

Calculating Area Using the Grid Method

When a shape is drawn on a scaled grid you can find the area by counting the number of grid squares inside the shape.

In this example there are 10 grid squares inside the rectangle.

In order to find an area value, using the grid method, we need to know the size that a grid square represents.
This example uses centimetres but the same method applies for any unit of length or distance. You could, for example be using inches, metres, miles, feet etc.
In this example each grid square has a width of 1cm and a height of 1cm. In other words each grid square is one 'square centimeter'.
Count the grid squares inside the large square to find its area..
There are 16 small squares so the area of the large square is 16 square centimeters.
In mathematics we abbreviate 'square centimeters' to cm2.  The 2 means ‘squared’. 
Each grid square is 1cm2.
The area of the large square is 16cm2.

Counting squares on a grid to find the area works for all shapes – as long as the grid sizes are known. However, this method becomes more challenging when shapes do not fit the grid exactly or when you need to count fractions of grid squares.
In this example the square does not fit exactly onto the grid.

We can still calculate the area by counting grid squares.
  • There are 25 full grid squares (shaded in blue)
  • 10 half grid squares (shaded in yellow) – 10 half squares is the same as 5 full squares.
  • There is also 1 quarter square. (¼ or 0.25 of a whole square).
  • Add the whole squares and fractions together: 25 + 5 + 0.25 = 30.25.
The area of this square is therefore 30.25cm2 .
You can also write this as 30¼cm2.

Although using a grid and counting squares within a shape is a very simple way of learning the concepts of area it is less useful for finding exact areas with more complex shapes, when there may be many fractions of grid squares to add together.
Area can be calculated using simple formulas, depending on the type of shape you are working with.
The remainder of this page explains and give examples of how to calculate the area of a shape without using the grid system.

Areas of Squares and Rectangles (and parallelograms).

The simplest (and most commonly used) area calculations are for squares and rectangles.
To find the area of a rectangle multiply its height by its width.
For a square you only need to find the length of one of the sides (as each side is the same length) and then multiply this by itself to find the area. This is the same as saying length2 or length squared.
It is good practice to check that a shape is actually a square by measuring two sides.  For example the wall of a room may look like a square but when you measure it you find it is actually a rectangle.

Often, in real life, shapes can be more complex. For example, imagine you want to find the area of a floor, so that you can order the right amount of carpet.
A typical floor-plan of a room may not consist of a simple rectangle or square:

In this example, and other examples like it, the trick is to split the shape into several rectangles (or squares). It doesn’t matter how you split the shape - any of the three solutions will result in the same answer.
Solution 1 and 2 require that you make two shapes and add their areas together to find the total area.
For solution 3 you make a larger shape (A) and subtract the smaller shape (B) from it to find the area.


Read more at: https://www.skillsyouneed.com/num/area.html

MySQL SHOW DATABASES: List All Databases in MySQL

Laravel Associate users with permissions and roles with spatie


This package allows you to manage user permissions and roles in a database.

https://github.com/spatie/laravel-permission

git : How can I determine the URL that a local Git repository was originally cloned from?


4154down voteaccepted
If you want only the remote URL, or referential integrity has been broken:
git config --get remote.origin.url
If you require full output or referential integrity is intact:
git remote show origin
When using git clone (from GitHub, or any source repository for that matter) the default name for the source of the clone is "origin". Using git remote show will display the information about this remote name. The first few lines should show:
C:\Users\jaredpar\VsVim> git remote show origin
* remote origin
  Fetch URL: git@github.com:jaredpar/VsVim.git
  Push  URL: git@github.com:jaredpar/VsVim.git
  HEAD branch: master
  Remote branches:
If you want to use the value in the script, you would use the first command listed in this answer.

Git Branching - Basic Branching and Merging

Basic Branching and Merging

Let’s go through a simple example of branching and merging with a workflow that you might use in the real world. You’ll follow these steps:
  1. Do some work on a website.
  2. Create a branch for a new story you’re working on.
  3. Do some work in that branch.
At this stage, you’ll receive a call that another issue is critical and you need a hotfix. You’ll do the following:
  1. Switch to your production branch.
  2. Create a branch to add the hotfix.
  3. After it’s tested, merge the hotfix branch, and push to production.
  4. Switch back to your original story and continue working.

Basic Branching

First, let’s say you’re working on your project and have a couple of commits already on the masterbranch.

What's the difference between 'git pull'and 'git fetch?

The objective of both these commands is the same - to get updates from the remote repository to my local repository.
But, they work in a different way.
Git pull: when you do a git pull, it gets all the changes from the remote or central repository and attaches it to your corresponding branch in your local repository.
Git fetch: when you do a git fetch, it gets all the changes from the remote repository, stores the changes in a separate branch in your local repository and if you want to reflect those changes in your corresponding branches, use a git merge to do that.
To summarize,
git pull = git fetch + git merge

Tuesday, October 23, 2018

khan academi



সকলের জন্য, সব জায়গায় বিনামূল্যে বিশ্বমানের শিক্ষা পৌঁছে দেওয়াই আমাদের লক্ষ্য।
খান একাডেমি একটি 501(c)(3) অলাভজনক প্রতিষ্ঠান। খান একাডেমি অনুদান অথবা স্বেচ্ছাসেবা প্রদান করুন আজই!link

10 less-known (but awesome!) Laravel Collections methods

10 less-known (but awesome!) Laravel Collections methods

Laravel Eloquent is awesome – probably I don’t need to tell you that. What is less known is the list of methods to work with Eloquent Collections. You can filter them, slice them, easily modify etc. But let’s look at it one by one.
A little notice here – that Collections are a broader term, whereas Eloquent Collections are the implementation of these broader Collections. So everything that we cover here in this article can be used for both instances.

Json placehoder demo site

<?php
$url="https://jsonplaceholder.typicode.com/photos";

$ch = curl_init();

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

curl_setopt($ch, CURLOPT_URL,$url);
$result=curl_exec($ch);
curl_close($ch);

echo "<pre>";
//var_dump(json_decode($result));
echo "</pre>";

$abc=json_decode($result);
foreach ($abc as $key => $value) {
echo $value->id;
}

This site will give you a banch of api data for test api jsonlink

cURL Requests with PHP

Introduction

cURL allows transfer of data across a wide variety of protocols, and is a very powerful system. It's widely used as a way to send data across websites, including things like API interaction and oAuth. cURL is unrestricted in what it can do, from the basic HTTP request, to the more complex FTP upload or interaction with an authentication enclosed HTTPS site. We'll be looking at the simple difference between sending a GET and POST request and dealing with the returned response, as well as highlighting some useful parameters.link

Laravel 5 import export to excel and csv using maatwebsite exampl

In this post i will show you how to import excel or csv to store in database and how to export or download excel or csv file from database table by maatwebsite. maatwebsite packages throught you can easily get data, also you can group by data, also create more then one sheet etc. so now i show you simple example of items table data, you can donwload in xls, xlsx and csv formate and also you import data in xls, xlsx and csv formate file. In following few step you can implement import and export both function in your project. First see your browser preview will become like this:link

learning sites

One of the best site for learninghttps://scotch.io/tag/css

laravel blog

Hey, I'm Matt Stauffer, partner & technical director at Tighten.https://mattstauffer.com/

laravel projects open source

Laravel tricks

Laravel Best Practices.

Welcome

Disclaimer: Majority of the assets, design and format of this site is borrowed (forked might be the more better term) from the original PHP : The Right Way site. The original contributors is given all the credits due to them.
This site serves as a guide for those who is using Laravel Framework by Taylor Otwell and its contributors. Laravel : Best Practices aims to put together all the resources and best practices in using the Laravel Framework.
Laravel Framework is not strict on how and where you define your classes as long as it could be loaded by Composer. This is a double-sided blade – it’s beneficial for advanced developers, but coud be confusing for beginners and for those who is trying to reverse engineer an existing codebase. The ability to place anything, anywhere is good. But there are times some methods is way better than the others, and that is what we are after. This site tried to collect all the best practices, tools and methodologies, so that it could serve a guide for beginners and existing developers alike.
This is a living document and will continue to be updated with more helpful information and examples as they become available.http://www.laravelbestpractices.com/

Laravel 5.2 - User ACL Roles and Permissions with Middleware using entrust from Scratch Tutorial

Laravel 5 provides authentication to us but that it simple to get user register, login, logout, and reset password and run quickly and easily. Laravel 5 give you simple authentication and it's fast and it's consider to all developer requirement.
But if you are work on big ERP or Project then you need to control access to certain sections of the website. I mean you require to role permissions based access control database design that way you can specify level of user.
Roles and Permissions through you can create several types of users with different role and permission, i mean some user have only see listing of items module, some user can also edit items modules, for delete and etc.
So if you also want to build ACL(Access Control List) based on Roles and Permissions with Middleware then you can do it simple by following few step. In this tutorial i give you very simple step to create ACL from scratch using entrust package, it is provides lots of method to check permission and roles, so no worry if you don't know more laravel.
In this examples i created three modules as listed bellow:Link

Laravel for RESTful: Build Your RESTful API with Laravel

What you'll learn
  • Create your own projects with Laravel (not only RESTful APIs)
  • Make the most of your work tools (Sublime Text 3, Git, Github, Composer, PHP artisan and Laravel)

  • Generate and maintain the structure of the database in an automated way with Laravel and the PHP Artisan console

  • Use PHP Artisan effectively and be much more efficient
  • Create and configure your own local development environment
  • Properly configure your development environment for all your projects
  • Hone the main HTTP methods/verbs for HTTP and RESTful APIs
  • Use free professional tools to improve your productivitylink

Javatpoint - A Best Portal to Learn Technologies

JavaTpoint offers Online Training and Winter Training on Java, Blockchain, Machine Learning, Meanstack, Artifical Intelligence, Kotlin, Cloud Computing, Angular, React, IOT, DevOps, RPA, Virtual Realty, Embedded Systems, Robotics, PHP, .Net, Big Data and Hadoop, Spark, Data Analytics, R Programming, SAP, Android, Python, Oracle, Web Designing, Spring, Hibernate, Software Testing, Seleninum, Linux, C++ and many more technologies. For more visit javatpoint trainingtraining.javatpoint.com
Approach us for Placement Oriented Training on Java, PHP, Android and Selenium.https://www.javatpoint.com/

Laravel Speed and Performance Optimization 101 – The Guideline

I am working with a pretty heavy Laravel site with many requests and lots of Eloquent/SQL calls. Even though the high-memory and high-cpu VPS, I felt there is room for performance improvement. That is why I would like to write out some improvements to speed up Laravel:https://www.devproblems.com/laravel-speed-and-performance-optimization-101-the-guideline/?fbclid=IwAR2COC6UpH2U9yJ06SsvyrKCD212XxSDs2QoOHanNNhHwmx1eeHXYUgBQh4

OPTIMIZING LARAVEL PERFORMANCE

Laravel is currently the most popular PHPframework for building a variety of sites and applications. Here at Fresh, we’ve built both complex Laravel API platforms and simple portals. The set of libraries and architecture that Laravel provides makes it easy to build amazing sites using well structured and “beautiful code” (their words exactly). click here to get link

Sunday, October 21, 2018

bangladesh-geocode

This Github link will give you all the Geo location information of Bangladesh with longitude and latitude and gov websites for each district.Click for getting GitHub link

Thursday, October 18, 2018

CakePHP JWT AUTH Plugin

https://github.com/ADmad/cakephp-jwt-auth

CakePhp Eluquent Subquery Example

public function beforeSave(Event $event, Entity $entity){ } public function initialize(array $config) { $this->addBehavior('Timestamp'); //gestion des colonnes created et modified $this->hasMany('ForumPosts'); $this->hasOne('LastForumPost', [ 'className' => 'ForumPosts', 'foreignKey' => false, 'conditions' => function ($exp, $query) { $subquery = $query ->getConnection() ->newQuery() ->select(['SubLastForumPost.id']) ->from(['SubLastForumPost' => 'forum_posts']) ->where([ 'SubLastForumPost.draft = false', //to remove for admin 'SubLastForumPost.created IS NOT NULL', 'ForumCategories.id = SubLastForumPost.forum_category_id', 'SubLastForumPost.parent_id IS NULL']) ->order(['SubLastForumPost.created' => 'DESC']) ->limit(1); return $exp->add(['LastForumPost.id' => $subquery]); } ]); }From cakephp forum