Skip to content

Instantly share code, notes, and snippets.

View edomaru's full-sized avatar

Eding Muhamad edomaru

View GitHub Profile
@edomaru
edomaru / Laravel5-AJAX-Session-Expired-Checker.md
Last active February 3, 2023 08:47
Laravel AJAX Session Expired Checker

AJAX check session expired

  • Create a middleware

php artisan make:middleware AjaxSessionExpiredMiddleware

  • Open the AjaxSessionExpiredMiddleware and add following code:
<?php
@edomaru
edomaru / RegisterController.php
Created November 11, 2016 17:59
Laravel Multi Auth RegisterController
<?php
namespace App\Http\Controllers\AdminAuth;
use App\AdminUser;
use Validator;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\RegistersUsers;
class RegisterController extends Controller
@edomaru
edomaru / laravel-dependend-dropdown.MD
Last active June 25, 2023 14:55
Laravel Dependent Dropdown

Laravel Dependent Dropdown

  • Create Model with migration php artisan make:model Category -m

  • Custom cateory migration

public function up()
{
    Schema::create('categories', function (Blueprint $table) {
@edomaru
edomaru / ciajaxvalidation.md
Created June 29, 2016 02:26
codeigniter ajax array validation

Controller

<?php defined('BASEPATH') OR exit('No direct script access allowed');

class Users extends CI_Controller {
	
	public function create()
	{
@edomaru
edomaru / search-issue.md
Created June 1, 2016 04:20
fix contact manager search issue
public function index(Request $request)
    {        
        $userId   = $request->user()->id;
        $groupId  = $request->get('group_id');
        $keywords = '%' . $request->get('term') . '%';

        $contacts = Contact::where(function($query) use ($userId, $groupId, $keywords) {
                            // filter by current user
                            $query->where("user_id", $userId);

Custom Laravel pagination style

  • create new file for example CustomPaginationPresenter.php below app directory
  • Extends the class from SimpleBootstrapThreePresenter like so:
<?php
namespace App;

use Illuminate\Support\HtmlString;
@edomaru
edomaru / upload_file_with_post_data.php
Created March 28, 2016 16:30
store other post when uplaod
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Site extends CI_Controller {
public function upload()
{
if ( ! empty($_FILES))
{
$config['upload_path'] = "./assets/uploads";
$config['allowed_types'] = 'gif|jpg|png|mp4|ogv';
@edomaru
edomaru / ci-bootstrap-pagination-config.php
Last active May 4, 2020 07:09
Codeigniter Pagination config to apply bootstrap style
<?php
$config["full_tag_open"] = '<ul class="pagination">';
$config["full_tag_close"] = '</ul>';
$config["first_link"] = "&laquo;";
$config["first_tag_open"] = "<li>";
$config["first_tag_close"] = "</li>";
$config["last_link"] = "&raquo;";
$config["last_tag_open"] = "<li>";
@edomaru
edomaru / yii2 errors summary.md
Last active August 29, 2015 14:24
Yii2 Errors Summary

Yii Errors

Invalid Parameter – yii\base\InvalidParamException ... bower/jquery/dist

Invalid Parameter – yii\base\InvalidParamException

The file or directory to be published does not exist: /mnt/Data/Sites/Learn/yii2/yii_crmapp/vendor/bower/jquery/dist
@edomaru
edomaru / rails-upload-file-with-carrierwave.md
Created June 27, 2015 22:36
Rails - Upload File with Carrierwave

Upload File with Carrierwave

Installation

Add this gem in Gemfile:

gem "carrierwave", "0.10.0"
gem 'mini_magick', '~> 4.2.7'