Khudadad

Khudadad

Member Since 3 Years Ago

Experience Points 7,070
Experience
Level
Lessons Completed 6
Lessons
Completed
Best Reply Awards 5
Best Answer
Awards
  • Start Your Engines Achievement

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • First Thousand Achievement

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • One Year Member Achievement

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • Two Year Member Achievement

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • Three Year Member Achievement

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • Four Year Member Achievement

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • Five Year Member Achievement

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • School In Session Achievement

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • Welcome To The Community Achievement

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • Full Time Learner Achievement

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • Pay It Forward Achievement

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • Subscriber Achievement

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • Lifer Achievement

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • Laracasts Evangelist Achievement

    Laracasts Evangelist

    Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.

  • Chatty Cathy Achievement

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • Laracasts Veteran Achievement

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • Ten Thousand Strong Achievement

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • Laracasts Master Achievement

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • Laracasts Tutor Achievement

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • Laracasts Sensei Achievement

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • Top 50 Achievement

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

03 Aug
2 years ago

Khudadad left a reply on Laravel How Can I Make My Video_id Column Equal To Id Of My Videos Table?

Add this in your Video model:

protected  $primarykey = 'video_id';

That's it.

29 Jun
2 years ago

Khudadad left a reply on Spatie Package Not Working

@willvincent one more thing how about production server, I mean will differ 'dump_command_path' ? and how to set it?

'dump_command_path' => 'C:\wamp\bin\mysql\mysql5.6.17\bin'

Khudadad left a reply on Spatie Package Not Working

@ willvincent, this is my config/database.php and where I add the dump_command_path?

<?php

return [

/*
|--------------------------------------------------------------------------
| PDO Fetch Style
|--------------------------------------------------------------------------
|
| By default, database results will be returned as instances of the PHP
| stdClass object; however, you may desire to retrieve records in an
| array format for simplicity. Here you can tweak the fetch style.
|
*/

'fetch' => PDO::FETCH_CLASS,

/*
|--------------------------------------------------------------------------
| Default Database Connection Name
|--------------------------------------------------------------------------
|
| Here you may specify which of the database connections below you wish
| to use as your default connection for all database work. Of course
| you may use many connections at once using the Database library.
|
*/

'default' => env('DB_CONNECTION', 'mysql'),

/*
|--------------------------------------------------------------------------
| Database Connections
|--------------------------------------------------------------------------
|
| Here are each of the database connections setup for your application.
| Of course, examples of configuring each database platform that is
| supported by Laravel is shown below to make development simple.
|
|
| All database work in Laravel is done through the PHP PDO facilities
| so make sure you have the driver for your particular database of
| choice installed on your machine before you begin development.
|
*/

'connections' => [

    'sqlite' => [
        'driver'   => 'sqlite',
        'database' => database_path('database.sqlite'),
        'prefix'   => '',
    ],

    'mysql' => [
        'driver'    => 'mysql',
        'host'      => env('DB_HOST', 'localhost'),
        'database'  => env('DB_DATABASE', 'accounting'),
        'username'  => env('DB_USERNAME', 'root'),
        'password'  => env('DB_PASSWORD', ''),
        'charset'   => 'utf8',
        'collation' => 'utf8_general_ci',
        'prefix'    => '',
        'strict'    => false,
        'engine'    => null,
    ],

    'pgsql' => [
        'driver'   => 'pgsql',
        'host'     => env('DB_HOST', 'localhost'),
        'database' => env('DB_DATABASE', 'forge'),
        'username' => env('DB_USERNAME', 'forge'),
        'password' => env('DB_PASSWORD', ''),
        'charset'  => 'utf8',
        'prefix'   => '',
        'schema'   => 'public',
    ],

    'sqlsrv' => [
        'driver'   => 'sqlsrv',
        'host'     => env('DB_HOST', 'localhost'),
        'database' => env('DB_DATABASE', 'forge'),
        'username' => env('DB_USERNAME', 'forge'),
        'password' => env('DB_PASSWORD', ''),
        'charset'  => 'utf8',
        'prefix'   => '',
    ],

],

/*
|--------------------------------------------------------------------------
| Migration Repository Table
|--------------------------------------------------------------------------
|
| This table keeps track of all the migrations that have already run for
| your application. Using this information, we can determine which of
| the migrations on disk haven't actually been run in the database.
|
*/

'migrations' => 'migrations',

/*
|--------------------------------------------------------------------------
| Redis Databases
|--------------------------------------------------------------------------
|
| Redis is an open source, fast, and advanced key-value store that also
| provides a richer set of commands than a typical key-value systems
| such as APC or Memcached. Laravel makes it easy to dig right in.
|
*/

'redis' => [

    'cluster' => false,

    'default' => [
        'host'     => env('REDIS_HOST', 'localhost'),
        'password' => env('REDIS_PASSWORD', null),
        'port'     => env('REDIS_PORT', 6379),
        'database' => 0,
    ],

],

];

Khudadad left a reply on Spatie Package Not Working

@bobbybouwmann When I run backup:run command my database file (ie, accounting.sql) is created in storage->laravel-backup->temp but 0kb

Khudadad left a reply on Spatie Package Not Working

Thanks for the reply @bobbybouwmann , I googled but couldn't find an answer, it's my first time using Spatie package maybe I'm missing something in configuration of this package, could you guide me about configuring this package.

Khudadad started a new conversation Spatie Package Not Working

I'm using spatie package for backing up of my database in Laravel 5.2 but it is not working

When I run bellow artisan command:

php artisan backup:run

I get this error:

Dumping database accounting...
Backup failed because The dump process failed with exitcode 1 : General error : 'mysqldump' is not recognized as an internal    or external command,
operable program or batch file.

How to solve it?

Khudadad left a reply on Laravel Join Two Tables Using Model

Try this:

$results = Category::find(1)->with(['product'])->where('status',1)->get();
26 Jun
2 years ago

Khudadad left a reply on Laravel 5.3 Wish List

Pagination of more than one model in one pagination in the view. $model1 = Model1::paginate(10) $model2 = Model2::paginate(10) merge both and paginate in controller

    <code>{!! $all->render() !!}</code>

in views

Khudadad left a reply on Transaction Not Working For Update

@bobbybouwmann , how to kow both operation is done or one of them is not done?

24 Jun
2 years ago

Khudadad left a reply on Data Not Saved And Image Not Uploaded

User Validation and see the errors maybe your image is too large.

Khudadad left a reply on Laravel Application Not Working On Production Server

When I comment this line in php.ini and set debug to false it works on localhost

    ;zend_extension = "c:/wamp/bin/php/php5.5.12/zend_ext/php_xdebug-2.2.5-5.5-vc11-x86_64.dll"

inside .evn file DEBUG = false;

I'm stuck here how to solve it , if someone faced this problem and or know about it please share.

Khudadad started a new conversation Laravel Application Not Working On Production Server

I've made a project with laravel 5.2 and when I upload on production server it does not works and nothing, of course I upload on a sub domain. It works on my computer fine but if I move it to another computer it does not, except I change debug option in .env file to false and comment xdebu of line in php.ini. Don't know how to make it to work on production server Errors on localhost as same as production https://laracasts.com/discuss/channels/laravel/blade-view-are-not-showing

23 Jun
2 years ago

Khudadad left a reply on Updating View After AJAX Post Without Reload

Make a partial page return it in your ajax response:

    <div >
           <?php $likes = $post->likes->count() ?>
             
                <span class="like @if ( $post->isLiked ) active @endif" data-postid="{{ $post->id }} data-original-title="@if($likes ==     1) Jij vind dit leuk @else Jij en {{ $likes }} anderen vinden dit leuk @endif" data-toggle="tooltip" data-placement="bottom"><i     class="zmdi zmdi-thumb-up" data-postid="{{ $post->id }}"></i> {{ $likes }}</span>
    </div>


$.ajax({
     method: 'POST',
     url: urlLike,
     data: {postId: postId, _token: token},
 })
 .done(function(msg) {
     console.log(msg); // 
$('.wis-numbers').html(msg);
 });

Khudadad left a reply on Pass Data From Ajax To Controller In Laravel

@massum You returned the data to roombooking page and know you can display it.

return view ('partials.roombooking', compact('data'))->render() ;
{{ $data }}

Note: If you returned data as json simply get your element id and set it to the data returned.

$.ajax({
      url: 'roombooking',
      type: "get",
      data: {id:data},
       success: function(response){ // What to do if we succeed
      if(data == "success")
   // alert(response); 
$('#elementID').data(response.data); 
  },

error: function(response){ alert('Error'+response); } });

Khudadad left a reply on Pass Data From Ajax To Controller In Laravel

Change your url and add a slush (/)

$.ajax({
      url: '/roombooking',
      type: "get",
      data: {id:data},
       success: function(response){ // What to do if we succeed
           $data = $(response);
          console.log($data); 
          },
        error: function(response){
            alert('Error'+response);
            }
        });
        
});

Khudadad left a reply on Pass Data From Ajax To Controller In Laravel

Try this and debug alert in error: after success You'r send the variable as id and get it as dataval

public function roombooking(Request $request)

{

$data= $request->id;
  
     return response()->json($data);

}

alert error :

 $.ajax({
          url: 'roombooking',
          type: "get",
          data: {id:data},
           success: function(response){ // What to do if we succeed
          if(data == "success")
        alert(response); 
    },
error: function(response){
    alert('Error'+response);
}
        });

Khudadad left a reply on Pass Data From Ajax To Controller In Laravel

Have you changed your route method from post to get?

Route::get('roombooking','[email protected]');

Khudadad left a reply on Blade Views Are Not Showing

By disabling Debug=false it solved.

Thanks

Khudadad left a reply on Undefined Variable: Comments

Your are missing $comments variable when returning the view use like @tomo_pongrac mentioned above.

Khudadad left a reply on Pass Data From Ajax To Controller In Laravel

Yeah, Why not , but if you want to send $data variable to a view, you can send as a json or even you can make a partial view and return it in your ajax response.

public function roombooking(Request $request)
   {

    $data= $request->dataval;
      
         return view ('pages.roombooking', compact('data')->render() ;
        

  }

Note: render() is important when you return a view in ajax response, you have to chain it otherwise it does not work.

Khudadad left a reply on Undefined Variable: Comments

Could you show your controller? My be you'r not sending the variable

Khudadad left a reply on Pass Data From Ajax To Controller In Laravel

As @usama.ashraf mentioned, you have to have same method in your route and ajax .

Khudadad left a reply on Blade Views Are Not Showing

Sorry still not working.

22 Jun
2 years ago

Khudadad started a new conversation Blade View Are Not Showing

I've make a project with Laravel 5.2 and when I move it to another computer it does not display the views, I mean views with Laravel syntax is not loaded and when I view page source in Chrome it displays lots of errors.

                <div id="sf-resetcontent" class="sf-reset">
            <h1>Whoops, looks like something went wrong.</h1>
                                    <h2 class="block_exception clear_fix">
                        <span class="exception_counter">1/1</span>
                        <span class="exception_title"><abbr title="Symfony\Component\Debug\Exception\FatalErrorException">FatalErrorException</abbr> in <a title="D:\accounting\vendor\composer\ClassLoader.php line 347" ondblclick="var f=this.innerHTML;this.innerHTML=this.title;this.title=f;">ClassLoader.php line 347</a>:</span>
                        <span class="exception_message">Maximum function nesting level of &#039;100&#039; reached, aborting!</span>
                    </h2>
                    <div class="block">
                        <ol class="traces list_exception">
   <li> in <a title="D:\accounting\vendor\composer\ClassLoader.php line 347" ondblclick="var f=this.innerHTML;this.innerHTML=this.title;this.title=f;">ClassLoader.php line 347</a></li>
   <li>at <abbr title="Symfony\Component\Debug\Exception\FatalErrorException">FatalErrorException</abbr>->__construct() in <a title="D:\accounting\vendor\laravel\framework\src\Illuminate\Foundation\Bootstrap\HandleExceptions.php line 133" ondblclick="var f=this.innerHTML;this.innerHTML=this.title;this.title=f;">HandleExceptions.php line 133</a></li>
   <li>at <abbr title="Illuminate\Foundation\Bootstrap\HandleExceptions">HandleExceptions</abbr>->fatalExceptionFromError() in <a title="D:\accounting\vendor\laravel\framework\src\Illuminate\Foundation\Bootstrap\HandleExceptions.php line 118" ondblclick="var f=this.innerHTML;this.innerHTML=this.title;this.title=f;">HandleExceptions.php line 118</a></li>
   <li>at <abbr title="Illuminate\Foundation\Bootstrap\HandleExceptions">HandleExceptions</abbr>->handleShutdown() in <a title="D:\accounting\vendor\laravel\framework\src\Illuminate\Foundation\Bootstrap\HandleExceptions.php line 0" ondblclick="var f=this.innerHTML;this.innerHTML=this.title;this.title=f;">HandleExceptions.php line 0</a></li>
   <li>at <abbr title="Composer\Autoload\ClassLoader">ClassLoader</abbr>->findFileWithExtension() in <a title="D:\accounting\vendor\composer\ClassLoader.php line 329" ondblclick="var f=this.innerHTML;this.innerHTML=this.title;this.title=f;">ClassLoader.php line 329</a></li>
   <li>at <abbr title="Composer\Autoload\ClassLoader">ClassLoader</abbr>->findFile() in <a title="D:\accounting\vendor\composer\ClassLoader.php line 300" ondblclick="var f=this.innerHTML;this.innerHTML=this.title;this.title=f;">ClassLoader.php line 300</a></li>
   <li>at <abbr title="Composer\Autoload\ClassLoader">ClassLoader</abbr>->loadClass() in <a title="D:\accounting\vendor\laravel\framework\src\Illuminate\Foundation\Application.php line 0" ondblclick="var f=this.innerHTML;this.innerHTML=this.title;this.title=f;">Application.php line 0</a></li>
   <li>at <abbr title=""></abbr>spl_autoload_call() in <a title="D:\accounting\vendor\laravel\framework\src\Illuminate\Foundation\Application.php line 648" ondblclick="var f=this.innerHTML;this.innerHTML=this.title;this.title=f;">Application.php line 648</a></li>
   <li>at <abbr title="Illuminate\Foundation\Application">Application</abbr>->registerDeferredProvider() in <a title="D:\accounting\vendor\laravel\framework\src\Illuminate\Foundation\Application.php line 628" ondblclick="var f=this.innerHTML;this.innerHTML=this.title;this.title=f;">Application.php line 628</a></li>
   <li>at <abbr title="Illuminate\Foundation\Application">Application</abbr>->loadDeferredProvider() in <a title="D:\accounting\v
21 Jun
2 years ago

Khudadad started a new conversation How To Paginage The Result Of Two Queries?

I have to collections of two queries and want to paginate in one pagination and don't know how to do this, any help. my queries:

    $expenses = DB::table('expenses')
        ->join('units','units.unit_id','=','expenses.unit_id')
        ->join('currencies','currencies.cur_id','=','expenses.currency_id')
        ->join('expense_type','expense_type.exp_type_id','=','expenses.expense_type_id')
        ->select('expenses.*','units.unit_name','currencies.currency','expense_type.exp_type_name','expense_type.exp_type_id')
        ->orderBy('created_at','desc')
        ->paginate(10);
    $purchases = DB::table('purchases')
        ->join('brands','brands.bid','=','purchases.brand_id')
        ->join('units','units.unit_id','=','purchases.unit_id')
        ->join('stock_item','stock_item.stm_id','=','purchases.item_id')
        ->join('categories','categories.cat_id','=','purchases.category_id')
        ->join('currencies','currencies.cur_id','=','purchases.currency_id')
        ->select('purchases.*','brands.brand_name','units.unit_name','stock_item.item_name','currencies.currency','categories.category_name')
        ->orderBy('purchases.created_at','desc')
        ->paginate(10);

The View :

    <?php $i = 1;?>
                                        @foreach($expenses as $expense)
                                            <tr>
                                                <td style="border-right: 1px solid #ddd;"><?php echo $i;?></td>
                                                <td>{{ $expense->exp_name }}</td>
                                                <td>{{ $expense->exp_type_name }}</td>
                                                <td>{{ \Carbon::parse($expense->exp_date)->format('d/M/Y') }}</td>
                                                <td>{{ $expense->currency }}</td>
                                                <td>{{ $expense->quantity }}</td>
                                                <td>{{ $expense->unit_name }}</td>
                                                <td>{{ number_format($expense->price,2) }}</td>
                                                <td>
                                                    <span class="symbol">$</span> {{ number_format($expense->c_price,2)  }}
                                                </td>
                                                <td class="total">
                                                    {{ number_format($expense->total,2) }} <span class="symbol">AFN</span>
                                                </td>
                                                <td class="total">
                                                    <span class="symbol">$</span> <?php echo number_format($expense->c_total,2,'.','');?>
                                                </td>
                                               
                                            </tr>
                                            <?php $i++; ?>
                                        @endforeach
                                        @foreach($purchases as $pr)
                                            <tr>
                                                <td style="border-right: 1px solid #ddd;"><?php echo $i;?></td>
                                                <td>{{ $pr->item_name }}</td>
                                                <td>{{ "Purchase" }}</td>
                                                <td>{{ \Carbon::parse($pr->buy_date)->format('d/M/Y') }}</td>
                                                <td>{{ $pr->currency }}</td>
                                                <td>{{ $pr->quantity }}</td>
                                                <td>{{ $pr->unit_name }}</td>
                                                <td>{{ number_format($pr->unit_price,2) }}</td>
                                                <td>
                                                    <span class="symbol">$</span> {{ number_format($pr->c_price,2)  }}
                                                </td>
                                                <td class="total">
                                                    {{ number_format($pr->unit_price*$pr->quantity,2) }} <span class="symbol">AFN</span>
                                                </td>
                                                <td class="total">
                                                    <span class="symbol">$</span> <?php echo number_format($pr->c_price*$pr->quantity,2,'.','');?>
                                                </td>
                                                {{--<td>--}}
                                                {{--<a href="/purchase/item" class="btn btn-xs btn-green mr-5"><i class="fa fa-search"> &nbsp; View</i></a>--}}
                                                {{--<a href="#" class="btn btn-xs btn-lightred"><i class="fa fa-remove"> &nbsp; Delete</i></a>--}}
                                                {{--</td>--}}
                                            </tr>
                                            <?php $i++; ?>
                                        @endforeach
                                 

pagination .......................

18 Jun
2 years ago

Khudadad started a new conversation How To Assign Role In Default AuthController

I want to assign a role to user during sign up in Laravel default AuthController, so how to do this if anyone idea? Thanks users migration:

public function up()
{
    Schema::create('users', function (Blueprint $table) {
        $table->increments('id');
        $table->string('name');
        $table->string('email')->unique();
        $table->string('password', 60);
        $table->rememberToken();
        $table->timestamps();
    });
}

user_roles migration:

public function up()
{
    Schema::create('user_roles', function (Blueprint $table) {
        $table->increments('id');
        $table->integer('user_id');
        $table->integer('role_id');
        $table->timestamps();
    });
}

roles migration:

 public function up()
{
    Schema::create('roles', function (Blueprint $table) {
        $table->increments('id');
        $table->string('name', 60);
        $table->text('description');
        $table->timestamps();
    });
}

register.blade:

    ......
    <div class="form-group{{ $errors->has('password_confirmation') ? ' has-error' : '' }}">
            <select name="role" id="role" class="form-control mb-10">
                <option value="" selected="selected">Select A Role</option>
                @foreach($roles as  $role)
                    <option value="{!! $role->r_id !!}">{!! $role->role_name !!}</option>
                @endforeach
            </select>
            @if ($errors->has('role'))
                <span class="help-block">
                    <strong>{{ $errors->first('role') }}</strong>
                </span>
            @endif
        </div>
13 Jun
2 years ago

Khudadad left a reply on How To Handle Htmlentities() Exception

After using dd($purchase )

{#111 ▼

+"id": 1 +"item_name": "Muscle" +"quantity": 12 +"unit_price": "100.0000" +"c_price": "1.4440" +"description": "" +"buy_date": "2016-06-12" +"purchase_type_id": 1 +"unit_id": 1 +"currency_id": 2 +"rate_id": 4 +"brand_id": 1 +"category_id": 1 +"created_at": "2016-06-12 22:35:10" +"updated_at": "2016-06-12 22:35:10" +"currency": "AFN" +"total": "28900.0000" +"usd_total": "417.3280" }

Khudadad left a reply on Why Does Ajax Call Give "Internal Server Error"

change the code like this:

    headers: { 'X-CSRF-Token' : $('meta[name=_token]').attr('content') }

Khudadad started a new conversation How To Handle Htmlentities() Exception

I'm tackling with the below error for a long time but couldn't solve it and don't know what I'm missing here.

    htmlentities() expects parameter 1 to be string, object given (View: E:\accounting\resources\views\index.blade.php)

this is cause when I rung this query: $purchase = DB::table('purchases') ->join('currencies', 'currencies.cur_id', '=', 'purchases.currency_id') ->selectRaw('purchases., currencies.currency ,SUM(purchases.quantityunit_price) as total, SUM(purchases.c_price*quantity) as usd_total') ->first();

View:

    <div class="col-xs-8">
        <p class="text-elg text-strong mb-0">
        {{ number_format($purchase->usd_total,2) }}
                                    </p>
        <span>Purchases</span>
     </div>

Any help.

Khudadad left a reply on Why I'm Getting Htmlenties() Error

                <div class="col-xs-8">
                                        <p class="text-elg text-strong mb-0">
                                            {{ number_format($purchase->usd_total,2) }}
                                        </p>
                                        <span>Purchases</span>
                                    </div>

Khudadad left a reply on Why I'm Getting Htmlenties() Error

When dd() the result is :

"417.3280"

Khudadad started a new conversation Why I'm Getting Htmlenties() Error

I'm trying to display sum of a column but getting this error:

    htmlentities() expects parameter 1 to be string, object given

This is my code in the controller:

    $purchase = DB::table('purchases')
        ->join('currencies', 'currencies.cur_id', '=', 'purchases.currency_id')
        ->selectRaw('purchases.*, currencies.currency ,SUM(purchases.quantity*unit_price) as total, SUM(purchases.c_price*quantity) as usd_total')
        ->first();

And the View:

    {{ number_format($purchase->usd_total,2) }}

any help.

12 Jun
2 years ago

Khudadad left a reply on For Money Field Integer Or Decimal?

Thanks @Snapey , could you explain a little more with example I really need it. Thanks

Khudadad left a reply on For Money Field Integer Or Decimal?

I used decimal but when I inserting into database it was getting changed. ie. 55400 to 55.0000 , format was (10,4)

Khudadad started a new conversation For Money Field Integer Or Decimal?

I'm trying to save amount of money in the database as integer, but when I want to display it, it gets rounded, How can I maintain integrity of amount of money.

    ei. 28.8808 rounded to 29

Khudadad left a reply on Laravel Money

I'm using decimal (10.4) but when storing to database on two first digits stored. ie 55400 is stored 55.0000 , don't know why?

11 Jun
2 years ago

Khudadad started a new conversation How To Sum Based On A Condition

Hi, all. I want to sum a field in the database(via query builder) based on a condition (ie. date<6/11/2016) and don't know which way is the best. I'm doing like this, is there any other better way to do this.

    $income = DB::table('incomes')
            ->join('currencies', 'currencies.cur_id','=','incomes.currency_id')
            ->selectRaw('incomes.*, currencies.currency ,sum(incomes.total) as total')
            ->where('inc_date','>',$sd)->where('inc_date','<',$ed)->get();
        return view('report.report', compact('income','sd','ed'))->render();

thanks.

02 Jun
2 years ago

Khudadad left a reply on Best Practice For Handling "active" Menu Item In L5

I 'm doing this like bellow : in my controller I declare $menu = '...'; and <$sub_menu = '....'; and check it in the views.

 <li class="<?php if ($menu == 'purchase') echo "active open dropdown"; ?>">
                                <a role="button" tabindex="0"><i class="fa fa-shopping-cart"></i> <span>Purchase Management</span> <span class="badge bg-lightred"></span></a>
                                <ul>
                                    {{--<li><a href="/purchase/new"><i class="fa fa-caret-right"></i> Add New Purchase</a></li>--}}
                                    <li class="<?php if ($sub_menu == 'purchase_list') echo "active"; ?>"><a href="/purchase"><i class="fa fa-caret-right"></i> Purchase List</a></li>
                                    <li class="<?php if ($sub_menu == 'add_new_purchase') echo "active"; ?>"><a href="/purchase/add" ><i class="fa fa-caret-right"></i> Add New Purchase</a></li>
                                </ul>
                            </li>

Khudadad left a reply on Ajax Pagination Issue

The error:

 GET http://localhost:8000/stock?page=2 500 (Internal Server Error)

Khudadad left a reply on Ajax Pagination Issue

Still same error

Khudadad left a reply on Ajax Pagination Issue

This is the code:

function ajaxPagination(active){

 if(active===true){

        $('.pagination a').each(function(e){

            $( ".ajax_overlay" ).show();
            $( ".loader" ).show();

            $(this).attr('data',$(this).attr('href'));
            $(this).attr('href','javascript:void(0);');

            $(this).bind('click',function(){

                $.ajax({
                    url: $(this).attr('data')
                    })
                    .done(function( html ) {
                    $( ".ajaxable" ).html( '' );
                    $( ".ajaxable" ).html( html );

                    $( ".ajax_overlay" ).hide();
                    $( ".loader" ).hide();

                    });

            });

            });

 }

}

ajaxPagination(true);

Controller

  public function index()
    {

    $items = DB::table('items')
        ->join('categories','categories.cat_id','=','items.category_id')
        ->join('units','units.unit_id','=','items.unit_id')
        ->select('items.*','categories.cat_id','categories.category_name','units.unit_id','units.unit_name')
        ->where('items.quantity','>',0)
        ->paginate(1);
    $total = Item::where('status', 0)->count();
    if (Request::ajax()) {
        return Response::json(['key'=>'OK']);//(view('partials.pagination')->with(compact('items','total'))->render());
    }
    return view('stock.stock-list', compact('items','category', 'purchase_type', 'units','brands','total','menu', 'sub_menu'));
}

Khudadad started a new conversation Ajax Pagination Issue

I want to make the default laravel pagination do not refresh the page and following

http://sharpten.com/blog/2014/10/02/ajax-based-pagination-laravel-4.html tutorial but not working. getting 500 Internal error in Chrome console

    ( GET http://localhost:8000/stock?page=2 500 (Internal Server Error))

Any help.

30 May
2 years ago

Khudadad left a reply on Dates Not Saved As Expected

Oh, God. yeah worked.

Thanks @Swaz

Khudadad left a reply on Laravel 5 Form

Have you added the aliases in config/app.php ?

Khudadad left a reply on Dates Not Saved As Expected

I'm using https://github.com/Eonasdan/bootstrap-datetimepicker and the result of dd($request->input('buy-date')); is OK. The date is changed after bellow operation

$purchaseDate = Carbon::createFromFormat('d/m/Y',$date );

Khudadad started a new conversation Dates Not Saved As Expected

I'm using a date picker in front end and when submit the form the date changed and another date is stored in the database (i.e 2016-30-05 is changed to 2018-06-05). any help.

Code: $date = $request->input('buy-date'); $purchaseDate = Carbon::createFromFormat('d/m/Y',$date ); $newPurchase->buy_date = $purchaseDate->toDateString();

12 Apr
2 years ago

Khudadad started a new conversation NotFoundHttpException

Hi, all. Why i'm getting NotFoundHttpException in RouteCollection.php line 161: error when ajax call. this is my route:

Route::post('general/search','StaffController@generalSearch');

this is my view:

{!! Form::open(['action'=>'StaffController@generalSearch','id'=>'searchForm']) !!}
            <div class="af-search-input fa-search-input">
                <input type="text" name="keyword" id="keyword" placeholder="جستجو ..." style="background-position: left !important;">
                <input type="hidden" name="general-search" id="general-search" value="general/search">
            </div>
            {!! Form::close() !!}
            <br>

and Controller method:

public function generalSearch()
{
    $keyword = Input::get('keyWord');

    $staff = DB::table('staffs')
        ->join('positions','staffs.position_id','=','positions.position_id')
        ->join('degrees','staffs.degree_id','=','degrees.degree_id')
        ->where('staffs.name', $keyword)
        ->orWhere('positions.position_name', $keyword)
        ->orWhere('degrees.degree_name', $keyword)
        ->select('staffs.*','positions.position_name')
        ->orderBy('s_id','desc')->paginate(5);
    return response()->json($staff);

}

jquery and ajax:

 $('#keyword').keypress(function (e) {
    if (e.keyCode == 13) {
        e.preventDefault();
        console.log();
        var search_url = $('#general-search').val();
        var query = $('#keyword').val();
        alert(search_url)
        $.ajax({
            url: search_url,
            type: 'post',
            dataType: 'json',
            data: {keyword: query},
            success: function (response) {
                alert('Success' +response.data.length)
                if(response.data.length > 0)
                {
                    $('#media-wrapp').empty();
                    $.each(response.data, function (admission, staffObj) {
                        $('#media-wrapp').append('<div class="media"><div class="media-right">' +
                            '<a href="/staff/details/'+staffObj.name +'/'+ staffObj.s_id+'" class="profile">' +
                            '<img src="/'+staffObj.photo+'" class="media-object af-circle-border" alt="'+staffObj.name+'" width="60"></a>' +
                            '</div>' +
                            '<div class="media-body af-media-body fa-media-body" ><h4 class="media-heading ">' +
                            '<a href="/staff/details/'+staffObj.name +'/'+staffObj.s_id+'" class="link">'+staffObj.name+'</a>' +
                            '</h4><p><span>فرزند: </span> <span>'+staffObj.f_name+'</span> &nbsp;|&nbsp; <span> وظیفه: </span>' +
                            '<span>'+staffObj.position_name+'</span> &nbsp;|&nbsp; <span>شماره تماس:</span> <span>'+staffObj.phone_number+'</span>'+
                            '</p>' +
                            '</div>' +
                            '</div>'
                        );
                    });
                }
                else {
                    $('#media-wrapp').empty();
                    $('#media-wrapp').append('<div class="alert alert-warning"><p>هیچ موردی یافت نشد!</p></div>');
                }
            },
            error: function (response) {
                alert('Oops something went wrong!');
            }
        });
    }
});