Tuesday, September 29, 2020

Laravel Ajax image upload system

 https://laravelarticle.com/laravel-ajax-image-upload

Laravel send email

https://laravelarticle.com/laravel-send-email 

Laravel scheduler on cpanel

 https://laravelarticle.com/laravel-scheduler-on-cpanel-shared-hosting

Laravel request validation extend

 <?php namespace App\Http\Requests;


use Illuminate\Foundation\Http\FormRequest;

class PostRequest extends FormRequest
{

    public function authorize()
    {
    	// we can check more things 
        return true;
    }

    public function rules()
    {
		switch ($this->method()) {
		    case 'GET':
		    case 'DELETE': {
		        return [
		        	'id'=>'required|exists:posts,id'
		        ];
		    }
		    case 'POST': {
		        return [
		    		'title'=> 'required|min:10',
		    		'description' => 'required'
		        ];
		    }
		    case 'PUT':
		    case 'PATCH': {
		        return [
		        	'id'=>'required|exists:posts,id'
		    		'title'=> 'required|min:10',
		    		'description' => 'required'
		        ];
		    }
		    default:
		        break;
		}
    }

}

Laravel xcel import export

 https://laravelarticle.com/laravel-excel-import-export

Laravel ajax query param


<input type="hidden" name="_token" value="{{csrf_token()}}">

or use only CSRF blade directive

@csrf



$(function(){

	 $('#form').submit(function(e){
	 	e.preventDefault();

	 	var _url = $(this).attr('action'),
	 		_type = 'POST',
	 		_data = $(this).serialize();

	 	$.ajax({
		    url: _url,
		    type: _type,
		    data: _data,
		    success: function (data) { 
		        // do something after success
		    }
		});

	 })
 

}); 

Laravel repository-design-pattern

 https://laravelarticle.com/repository-design-pattern-in-laravel

Larave .htaccess sucrity code

 #disable directory browsing

Options -Indexes

#PROTECT ENV FILE
<Files .env>
order allow,deny
Deny from all
</Files>

#PROTECT ENV FILE
<Files .htaccess>
order allow,deny
Deny from all
</Files>

Deploy Laravel on shared hosting

 https://laravelarticle.com/deploy-laravel-on-shared-hosting