Month: August 2016

options-permalink.php not found error 404 – wordpress

If there are no issues in your .htaccess.
If you have tried everything and it is not working… try

/wp-admin/includes/misc.php

Line 16 it will be

 function got_mod_rewrite() { to function got_mod_rewrite() {return true;

Line 42 it will be

 function got_url_rewrite() { to function got_url_rewrite() {return true;

Setting up first route,view,controller and sending data to view laravel 5

Example Route

<?php
Route::get('home','HomeController@index');  // you tell if url has /home then home controller index function handles that
?>

Then Controller will be
app/Http/Controllers/HomeController.php

<?php
namespace App\Http\Controllers;
class HomeController extends Controller
{
	//this is the funtion handling the /home
	public function index(){
		$data = "abc"; // here is sample data
	    return View::make('home/myhome', array('data' => $data));  // this is html file will be saved in views/home/myhome.blade.php
	}

}
?>

resources/views/home/myhome.blade.php

{{ $data }} 

Model relations and Querying Laravel

Posts model may look like below

    public function tags(){
        return $this->hasMany('App\Models\Posttag','post_id','post_id');
    }
    public function user(){
        return $this->belongsTo('App\Models\User','user_id');
    }
    public function comments(){
        return $this->hasMany('App\Models\Comment','post_id','post_id');
    }
    public function comments_count(){
        return $this->hasOne('App\Models\Comment','post_id','post_id')->selectRaw('post_id, count(*) as aggregate')->groupBy('post_id');
    }

Then we can query data like so

	   $data = Post::with(['tags','comments' => function($query){
			$query->with(array('owner'))->orderBy('created_at','DESC')->limit(1);
			},'user' => function($query){
                                  $query->select('id','name','profile_pic');
                       }])->get();