Skip to content

Instantly share code, notes, and snippets.

View rizkhal's full-sized avatar
🌴
On vacation

Rizkhal rizkhal

🌴
On vacation
View GitHub Profile
<?php
function setActive($path, $active = 'active'){
return call_user_func_array('Request::is', (array) $path) ? $active : '';
}
@rizkhal
rizkhal / file.cpp
Created October 8, 2018 12:48
Hitung Luas Persegi Panjang Menggunakan C++
#include "stdio.h"
#include "iostream"
using namespace std;
int main()
{
int luas = 0, panjang = 0, lebar = 0;
printf("%s" "\n", "Calculate the area of ​​a rectangle");
@rizkhal
rizkhal / avg.php
Last active May 5, 2019 19:30
Simple way to calculate stars ratings like ecomerce
<?php
// our php array for example, if you using data from database, make it
$array = [
252, 124, 40, 29, 1
];
// stars, 1 - 5
$star = [
5, 4, 3, 2, 1
@rizkhal
rizkhal / fetch-api-examples.md
Created May 31, 2019 19:06 — forked from justsml/fetch-api-examples.md
JavaScript Fetch API Examples
<?php
namespace App\Repositories;
interface PostRepositoryInterface {
public function all();
public function take(int $limit);
<?php
namespace App\Repositories\Eloquent;
use App\Repositories\Eloquent\Entities\Post;
use App\Repositories\PostRepositoryInterface as PostInterface;
class PostEloquent implements PostInterface
{
protected $model;
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreatePostsTable extends Migration
{
//...
public function up()
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
class RepositoryServiceProvider extends ServiceProvider
{
/**
* Register services.
<?php
namespace App\Http\Requests;
use Illuminate\Support\Str;
use Illuminate\Foundation\Http\FormRequest;
class PostRequestValidate extends FormRequest
{
/**
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Requests\PostRequestValidate;
use App\Repositories\PostRepositoryInterface as PostEloquent;
class PostController extends Controller