Skip to content

Instantly share code, notes, and snippets.

View yasaryousuf's full-sized avatar

Yasar Yousuf yasaryousuf

  • Dhaka, Bangladesh.
View GitHub Profile
var isError = false;
$('[name="member-books-guest"]').submit(function (e) {
$.LoadingOverlay("show");
$( ".error-message" ).remove();
for ( let i = 0; i < e.target.length; i++ ) {
let currentField = e.target[i];
if (currentField.type == 'text') {
if(!currentField.value) {
$('[name="'+currentField.name+'"]').after("<span style='color:tomato' class='error-message'>* Field can't be empty</span>");
<?php
# app/Exceptions/Handler.php
public function render($request, Exception $exception)
{
if ($exception instanceof \Illuminate\Database\Eloquent\ModelNotFoundException)
{
return response()->json([
'message' => 'Resource not found'
], 404);
<?php
# In factory
use Faker\Generator as Faker;
$factory->define(App\Poll::class, function (Faker $faker) {
return [
'title' => $faker->text
];
});
@yasaryousuf
yasaryousuf / laravel_multiple_file_upload_validation.php
Last active February 4, 2019 06:22
multiple file upload validation with array in laravel 5.x
<?php
public function store(Request $request)
{
$this->validate($request, [
'images.*' => 'required|mimes:jpg,jpeg,png,bmp|max:2000'
],[
'images.*.required' => 'Please upload an image only',
'images.*.mimes' => 'Only jpeg, png, jpg and bmp images are allowed',
'images.*.max' => 'Sorry! Maximum allowed size for an image is 2MB',
<?php
public static function segmentation_option()
{
global $wpdb;
$version = '1.0';
$table_name = $wpdb->prefix . 'segmentation_option';
$seg_table=$wpdb->prefix . 'question';
$charset_collate = $wpdb->get_charset_collate();
$sql = "CREATE TABLE $table_name (
<?php
// config
// -------------------------------
// only file name + .zip
$zip_filename = $_POST['zip_filename'] ?? '';
?>
<!DOCTYPE html>
<html>
<head>
$('.ui.search').search({
apiSettings: {
action: 'search',
url: '/wp-admin/admin-ajax.php?action=search_customer&query={query}'
},
fields: {
results: 'results',
title: 'FirstName',
description: 'Email',
},
<?php if(!is_user_logged_in()): ?>
<h3>Please <a href="<?php echo wp_login_url(get_the_permalink()) ?>">Login</a></h3>
<?php return; endif ?>
individualPriceChange();
totalPriceChange();
$(".qty").change(function() {
individualPriceChange();
totalPriceChange();
});
// price calculation row
function individualPriceChange() {