Skip to content

Instantly share code, notes, and snippets.

View tisuchi's full-sized avatar
🙂
Smile is Sadaqah (righteousness)

Thouhedul Islam tisuchi

🙂
Smile is Sadaqah (righteousness)
View GitHub Profile
@tisuchi
tisuchi / default-primary-key.php
Created April 7, 2018 04:57
How to set laravel custom primary key
<?php
class Product extends Eloquent {
protected $primaryKey = 'product_id';
}
<?php
class StoreOffer extends Model
{
public function store()
{
return $this->belongsTo('App\Models\Store', 'store_id', 'store_id');
}
@tisuchi
tisuchi / laravel-unauthenticated-error.php
Last active August 24, 2018 12:17
Laravel Call to undefined method App\Exceptions\Handler::unauthenticated()
<?php
/**
* Convert an authentication exception into an unauthenticated response.
*
* @param \Illuminate\Http\Request $request
* @param \Illuminate\Auth\AuthenticationException $exception
* @return \Illuminate\Http\Response
*/
@tisuchi
tisuchi / .htaccess
Created February 14, 2018 05:21
How to upload laravel in cPanel
RewriteEngine On
Options +FollowSymLinks
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
RewriteRule ^(.*)$ public/$1 [L]
{{ $model->created_at->setTimezone('Asia/Dhaka') }}
public function foo()
{
// Container Access
$checker = app()->make('email.checker');
$checker->isValid('address@domain.com');
}
public function foo()
{
// Facade Access
EmailChecker::isValid('address@domain.com');
}
@tisuchi
tisuchi / all-posts-of-a-category.php
Last active January 12, 2018 03:57
Wordpress show all posts of a category
<?php
$args = array( 'category' => 1, 'post_type' => 'post' );
$postslist = get_posts( $args );
foreach ($postslist as $post) : setup_postdata($post);
?>
<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
<?php the_excerpt(); ?>
<?php endforeach; ?>
<?php
Post::selectRaw('title, categoryid, count(*) total')
->orderBy('total', 'desc')
->groupBy('categoryid')
->get();
@tisuchi
tisuchi / domdocument.php
Created January 9, 2018 01:39
Laravel DOMDocument() class not found
<?php
namespace App\Http\Controllers;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
class TestController extends Controller