Skip to content

Instantly share code, notes, and snippets.

View johnadan's full-sized avatar
👨‍💻
Back in the office!

John McLem Adan johnadan

👨‍💻
Back in the office!
View GitHub Profile
@johnadan
johnadan / add_asterisk_borders_to_one_d_array_in_php.html
Created June 26, 2023 08:12
user-defined php function that will accept a one-dimensional array and add asterisk as borders in start and end of array
<!DOCTYPE html>
<html>
<body>
<?php
//$txt = "PHP";
//echo "I love $txt!";
//echo "test";
//echo("test");
//print("test");
@johnadan
johnadan / model_function.php
Created June 13, 2023 06:33
create and use a function inside a model to controller
<?php
class UserModel extends Model
{
public function totalUsers() {
$users = DB::table('users')->get();
return $users->count();
}
}
@johnadan
johnadan / list_with_query_params.php
Created June 6, 2023 10:58
List with query params in laravel api controller
<?php
public function index(Request $request)
{
UserLog::insertLog('Listed cities', URL::full());
$cities = AddressCity::query();
$provinceCode = $request->provinceCode;
if ($provinceCode) {
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\DB;
return new class extends Migration
{
/**
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\DB;
return new class extends Migration
{
/**
@johnadan
johnadan / ajax_get_request_laravel_blade.php
Created May 23, 2023 09:29
ajax get request laravel blade
<?php
@foreach(jobs as $job)
<button class="btn btn-danger rmvbtn-jo" data-id="{{ $job->id }}" style="border: none; background-color:transparent;">
<i class="fas fa-trash fa-lg text-danger"></i>
</button>
@endforeach
$(document).on('click', '.rmvbtn-jo', function () {
@johnadan
johnadan / change_date_format_to_string_lrvl.php
Created June 2, 2022 03:37
change date format to string in laravel blade
$fdate = strtotime($datevalue);
$fdate = date("F j, Y", $fdate);
@johnadan
johnadan / change_date_format_to_string_js.js
Created June 2, 2022 03:36
change date format to string in javascript
const dateValue = (datevalue);
const options = {year: 'numeric', month: 'long', day: 'numeric'};
const dateFormatted = new Date(dateValue).toLocaleDateString('en-US', options);