Skip to content

Instantly share code, notes, and snippets.

View devzakir's full-sized avatar
🏠
Building @JuggleHire for busy recruiters

Zakir Hossen devzakir

🏠
Building @JuggleHire for busy recruiters
View GitHub Profile
@devzakir
devzakir / generator.php
Created June 1, 2020 01:49
4 Digit Code Generator with Alphabet Character
function generatePIN(){
$alphabetArray = array("A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z");
$letter = $alphabetArray[array_rand($alphabetArray)];
function generateNumber($letter, $digits = 3){
$i = 0;
$pin = "";
while($i < $digits){
$pin .= mt_rand(0, 9);
$i++;
@devzakir
devzakir / UploadController.php
Created June 11, 2020 10:33
Image upload in Laravel and Vue.js
public function account_verification(Request $request){
$pan_card_image = 'image';
if($request->get('pan_card_image')) {
$image = $request->get('pan_card_image');
$pan_card_image = time().'.' . explode('/', explode(':', substr($image, 0, strpos($image, ';')))[1])[1];
\Image::make($request->get('pan_card_image'))->save(public_path('storage/').$pan_card_image);
}
}
@devzakir
devzakir / slug.php
Last active May 25, 2021 15:17
Bangla URL Slug Builder
// Converting String to Slug
$special_characters = [",", ";", "'", '"', "`", "/", "\\", ":", "‘", "’", "!", "?", "%", "^", "#", "@", "*", "~", ")", "("];
$title = str_replace($special_characters, '', $request->title);
$title_slug = preg_replace('/\s+/u', '-', $title);
// Example
$post = Post::create([
'title' => $title,
'slug' => $title_slug,
@devzakir
devzakir / setting.json
Created June 25, 2020 10:26
Visual Studio Code Settings
{
"workbench.colorTheme": "Ayu Mirage Bordered",
"workbench.iconTheme": "ayu",
"editor.wordWrap": "off",
"editor.fontLigatures": true,
"editor.fontFamily": "Operator Mono Light",
"editor.fontSize": 14,
"php.executablePath": "/usr/bin/php",
"php.validate.run": "onType",
"php.suggest.basic": false,
@devzakir
devzakir / india-states-and-districts.json
Created June 28, 2020 02:42
India State and District List in JSON Format
{
"states":[
{
"id": 1,
"state":"Andhra Pradesh",
"districts":[
{ "id": 1, "name": "Anantapur" },
{ "id": 2, "name": "Chittoor" },
{ "id": 3, "name": "East Godavari" },
{ "id": 4, "name": "Guntur" },
@devzakir
devzakir / Upload.vue
Last active June 27, 2021 14:56
Laravel and Vue.js Image upload with the help of vform package.
<template>
<form @submit.prevent="updateUser">
<div class="form-group">
<label>Choose Avatar</label>
<input type="file" class="form-control-file" name="avatar" placeholder="avatar" @change="onAvatarChange" :class="{ 'is-invalid': user.errors.has('avatar') }">
<has-error :form="user" field="avatar"></has-error>
</div>
</form>
</template>
@devzakir
devzakir / gh-pages-deploy.md
Created January 27, 2021 01:02 — forked from cobyism/gh-pages-deploy.md
Deploy to `gh-pages` from a `dist` folder on the master branch. Useful for use with [yeoman](http://yeoman.io).

Deploying a subfolder to GitHub Pages

Sometimes you want to have a subdirectory on the master branch be the root directory of a repository’s gh-pages branch. This is useful for things like sites developed with Yeoman, or if you have a Jekyll site contained in the master branch alongside the rest of your code.

For the sake of this example, let’s pretend the subfolder containing your site is named dist.

Step 1

Remove the dist directory from the project’s .gitignore file (it’s ignored by default by Yeoman).

@devzakir
devzakir / app.js
Created March 24, 2021 15:34
vuejs navigation guard
// check authentication
let auth = localStorage.getItem("auth");
if(auth){
store.dispatch('authUser').then(() => {
new Vue({
router,
store,
render: h => h(App)
}).$mount('#app')
@devzakir
devzakir / auth.js
Created March 24, 2021 15:37
Vuex Store Action Example
import axios from 'axios'
import router from '../router'
export default {
namespaced: true,
state: {
authenticated: false,
user: null
},
@devzakir
devzakir / file.php
Created March 31, 2021 08:07
Show Laravel Email Notification In the Browser
Route::get('preview', function () {
$message = (new \App\Notifications\OrderPlaced(\App\Models\Order::first(), \App\Models\User::first()))->toMail('test@test.com');
return $message->render();
});