Tagged: 5.6

global variable for all controller and views in Laravel 0

global variable for all controller and views in Laravel

Today, We want to share with you global variable for all controller and views in Laravel.In this post we will show you set global dynamic variables in Laravel 5.8, hear for Laravel define global constants Config php file we will give you demo and example for implement.In this post, we will learn about How to set a variable inside Laravel’s blade template with an example.

global variable for all controller and views in Laravel

There are the Following The simple About global variable for all controller and views in Laravel Full Information With Example and source code.

As I will cover this Post with live Working example to develop How to define Global Variables in Laravel 5.8?, so the Laravel 5.8 – global and dynamic variable for this example is following below.

How to create global variable in laravel 5.6?

config/global.php

set simple your array here.

return [
  'website_title' => 'pakainfo Blog',
  'pagination' => 10,
  'tagLine' => 'Welcome to pakainfo website Love You',
  'API_KEY' => 'hjh566s5df$#FDsf45f4df7ds8ds',
];

Use in your laravel blade view file.

{{ config('global.website_title') }}

{{ config('global.tagLine') }}

Web Programming Tutorials Example with Demo

Read :

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about global variable for all controller and views in Laravel.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Laravel Remove Public From URL Steps 0

Laravel Remove Public From URL Steps

Today, We want to share with you Laravel Remove Public From URL Steps.In this post we will show you Remove “public” in URL in Laravel 5.7 Step By Step, hear for Laravel 5.7 – Remove Public from URL using htaccess we will give you demo and example for implement.In this post, we will learn about How to Remove Public Directory in Laravel 5.5, 5.6, 5.7 with an example.

Laravel Remove Public From URL Steps

There are the Following The simple About Laravel Remove Public From URL Steps Full Information With Example and source code.

As I will cover this Post with live Working example to develop how to remove public from url in laravel on server,, so the some laravel 5.7 remove public from url for this example is following below.

Step 1: Rename File

Laravel’s .htaccess to remove “public” from URL

simple change your server.php file in the root file to index.php

//Rename 
server.php 
//in your Laravel root folder to 
index.php

Step 2: Update .htaccess

Simple Your .htaccess file and put it laravel Main root folder

Options -MultiViews -Indexes

RewriteEngine On

# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]


# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]

 
# Handle Front Laravel Controller...
RewriteCond %{REQUEST_URI} !(\.css|\.js|\.png|\.jpg|\.gif|robots\.txt)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]


RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !^/public/
RewriteRule ^(css|js|images)/(.*)$ public/$1/$2 [L,NC]

Laravel 5.* Project- Remove public from URL

Move Laravel Project From localhost to live production server : More Easy MethodsRemoving PUBLIC from URL in Laravel

Change:
require __DIR__.'/../bootstrap/autoload.php';
to:
require __DIR__.'/../laravel/bootstrap/autoload.php';
----------------------------------
Change:
$app = require_once __DIR__.'/../bootstrap/app.php';
to:
$app = require_once __DIR__.'/../laravel/bootstrap/app.php';

Note : And Last You remove all cache and cookies.

Angular 6 CRUD Operations Application Tutorials

Read :

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about Laravel Remove Public From URL Steps.
I would like to have feedback on my Pakainfo.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

File upload size validation using Laravel 5.7 0

File upload size validation using Laravel 5.7

Today, We want to share with you File upload size validation using Laravel 5.7.In this post we will show you Laravel 5.7 max file size validation for file/image fields, hear for Check (Validate) File Size before upload using Laravel we will give you demo and example for implement.In this post, we will learn about How to validate upload file size and file extension using Laravel 5.7 with an example.

File upload size validation using Laravel 5.7

There are the Following The simple About File upload size validation using Laravel 5.7 Full Information With Example and source code.

As I will cover this Post with live Working example to develop Laravel 5.7 File upload size validation using jQuery with demo, so the Laravel 5.7 file upload size validation for this example is following below.

Validate Max File Size in Laravel

[
  'image' => 'required|mimes:jpeg,bmp,png|size:20000',
]

Your File size should be not more than 20 MB (20000 kB).

According to the Laravel 5.7 documentation:

$validator = Validator::make($request->all(), [
    'file' => 'max:500000',
]);

The value is in kilobytes. I.e. max:10240 = max 10 MB.

You Can Also Read step By step My Tiny Post Forlaravel 5.7 crud

Example 1: Laravel File Size Validation

app/Http/Controllers/ImageUploadController.php

public function imagePostUpload()
{
    request()->validate([
        'image' => 'required|image|mimes:jpeg,png,jpg,gif,svg|max:2048',
    ]);
    $imgFlName = time().'.'.request()->image->getClientOriginalExtension();
    request()->image->move(public_path('images'), $imgFlName);
    return back()
        ->with('success','You have successfully upload files/image.')
        ->with('image',$imgFlName);
}

Example 2: Laravel Image Upload Validation

    public function imagePostUpload(Request $req)
    {
        $this->validate($req, [
            'image' => 'required|image|mimes:jpeg,png,jpg,gif,svg|max:2048',
        ]);

        $image = $req->file('image');
        $input['flimgname'] = time().'.'.$image->getClientOriginalExtension();
        $uploadPath = public_path('/images');
        $image->move($uploadPath, $input['flimgname']);


        $this->postImage->add($input);
        return back()->with('success','Image Upload successful');
      }

You Can Also Read step By step My Tiny Post Forupload image in laravel 5.7

Laravel 5.7 – image dimension validation rules examples

There are the Following List of the laravel image dimension validation

$this->validate($request, [
    'image' => 'required|image|mimes:jpeg,png,jpg,gif,svg|max:2048|dimensions:width=500,height=500',
]);

$this->validate($request, [
    'image' => 'required|image|mimes:jpeg,png,jpg,gif,svg|max:2048|dimensions:min_width=350,min_height=600',
]);

$this->validate($request, [
    'image' => 'required|image|mimes:jpeg,png,jpg,gif,svg|max:2048|dimensions:max_width=350,max_height=600',
]);

$this->validate($request, [
    'image' => 'required|image|mimes:jpeg,png,jpg,gif,svg|max:2048|dimensions:ratio=3/2',
]);

You Can Also Read step By step My Tiny Post Forlaravel activity log

Angular 6 CRUD Operations Application Tutorials

Read :

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about File upload size validation using Laravel 5.7.
I would like to have feedback on my Pakainfo.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Laravel Send Emails Mailgun setup Tutorial 0

Laravel Send Emails Mailgun setup Tutorial

Today, We want to share with you Laravel Send Emails Mailgun setup Tutorial.In this post we will show you Mailgun setup with Laravel 5 example, hear for Emails with Laravel 5.7 Mailables we will give you demo and example for implement.In this post, we will learn about Send email in Laravel through email sending services with an example.

Laravel Send Emails Mailgun setup Tutorial

There are the Following The simple About Laravel Send Emails Mailgun setup Tutorial Full Information With Example and source code.

As I will cover this Post with live Working example to develop Laravel Send Emails Using PHP Mailgun , so the some How To Send Email In Laravel Tutorial for this example is following below.

  • Laravel configration(.env file)
  • Global Setting Of the Mailgun
  • Define Laravel Route
  • Create a Controller
  • Laravel Send Email Template View File

Sttep 1 : setting of the Laravel configration

open .env file and bellow code

add configration on mail Sending Emails with Laravel and Mailgun

MAIL_DRIVER=mailgun
MAIL_HOST=smtp.mailgun.org
MAIL_PORT=587
[email protected]
[email protected]
MAIL_ENCRYPTION=tls

Good, now I required to Include secret key as well as your domain of mailgun send mail api configration. Therefor I make a new account in offical website mailgun.com SignUp and then I registeration and active your simple step to mailgun new account as well as click on simple tabs Like Domails Into Add New Domail button.

Step 2 : Global Setting Of the Mailgun

config/services.php

And then We have to open Laravel services.php file as well as put here simple mailgun configration key and url this way :

 'mailgun' => array(
    'domain' => 'pakainfo.com',
    'secret' => 'key-225487c09e58-056a9e692c96dd832jd0cc',
),

Step 3 : Define Laravel Route

app/Http/routes.php

After I am step 3 ready to each client send mail for first welcome so first usnig laravel 5.4, 5.5, 5.6 and 5.7 make welcome route for email sending.

Route::get('mail', '[email protected]');

Step 4 : Create a Controller

app/Http/Controllers/SendMailController.php

Good way, Then add simple send mail function in SendMailController.php file there for add Laravel this way :

public function mail()
{
    $client = Client::find(1)->toArray();
    Mail::send('emails.simpleSendMailTemplate', $client, function($message) use ($client) {
        $message->to($client->email);
        $message->subject('Laravel Mailgun Testing');
    });
    dd('Mail Send Successfully');
}

Laravel mailgun Send Mail
////////mailgun///////////
      try {
            $data = [
                'title'=>'Email'
            ];
            $sent = Mail::send('emails.simpleSendMailTemplate', $data, function($message) {
                $message->from('[email protected]', 'Example Person');
                $message->to('[email protected]');
                $message->subject('Laravel Send Emails Mailgun setup Tutorial - Mailgun Testing');
            });
            if( ! $sent) dd("something wrong");
            dd('Mail Send Successfully');
        }
        catch (GenericHTTPError $e) {
           // return $e->getMessage();
            dd($e->getMessage());
        }

Step 5 : Laravel Send Email Template View File

resources/views/emails/simpleSendMailTemplate.blade.php

At Final step to make Laravel email template file for mailgun send mail therefor let’s make a simpleSendMailTemplate.blade.php file in emials folder.

<h1>Laravel Send Emails Mailgun setup Tutorial</h1>
Hi, I am from pakainfo.com from mailgun testing.

Thanks
Jaydeep Gondaliya

Angular 6 CRUD Operations Application Tutorials

Read :

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about Laravel Send Emails Mailgun setup Tutorial.
I would like to have feedback on my Pakainfo.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Laravel GroupBy Error Solution 5.5 , 5.6, 5.7 0

Laravel GroupBy Error Solution 5.5 , 5.6, 5.7

Today, We want to share with you Laravel GroupBy Error Solution 5.5 , 5.6, 5.7.In this post we will show you GroupBy Not Working In Laravel Fix, hear for laravel only_full_group_by we will give you demo and example for implement.In this post, we will learn about laravel select list is not in group by clause and contains nonaggregated column with an example.

Laravel GroupBy Error Solution 5.5 , 5.6, 5.7

There are the Following The simple About Laravel GroupBy Error Solution 5.5 , 5.6, 5.7 Full Information With Example and source code.

As I will cover this Post with live Working example to develop laravel only_full_group_by, so the some major files and Directory structures for this example is following below.

  • laravel groupby tutorial

Laravel 5.5 , 5.6, 5.7 group by fixed

Error : SQLSTATE[42000]: Syntax error or access violation: 1055

Syntax error or access violation: 1055 isn’t in GROUP BY in Laravel

Step 1 : Open Your config/database.php file

config/database.php

simply Laravel Project“strict” mode make it boolean value true into false in (config/database.php)database.php file

//Database setting
...
'strict' => true,
To
'strict' => false,
....

Laravel : Syntax error or access violation: 1055 Error

Laravel group by Example – fixed

groupBy Query

$members = DB::table("members")
            ->groupBy("name")
            ->get();
dd($members);

How To Fix GroupBy Not Working In Laravel 5.5 , 5.6, 5.7

CallLogModel::selectRaw('count(*) AS cnt, caller')->groupBy('caller')->orderBy('cnt', 'DESC')->limit(5)->get();

laravel select list is not in group by clause and contains nonaggregated column

Laravel Group By Count Multiple Columns
Angular 6 CRUD Operations Application Tutorials

Read :

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about Laravel GroupBy Error Solution 5.5 , 5.6, 5.7.
I would like to have feedback on my Pakainfo.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.