mardi 26 décembre 2017

How to call a controller from view in laravel 5

I am using laravel 5 in which i have to call a controller from view blade.But it showing me parse error.Please find my code.

Controller name:ReportController(path=app/Http/Controllers/Admin/ReportController)

<?php

namespace App\Http\Controllers\Admin;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use DB;
//send email use helper
use App\Helpers\MyHelperFunction;

 public static function my($args){
        // do your stuff or return something.
        echo $args."I am called on view.";
    }
?>

View:customerorders.blade.php

<?php 
use App\Http\Controllers\Admin\ReportController;
     echo ReportController::my('hello'); 
?>

I facing this error:

Method Illuminate\View\View::__toString() must not throw an exception, caught ErrorException: Parse error: syntax error, unexpected 'use' (T_USE) (View:/opt/lampp/htdocs/buddyiq_dev/resources/views/Admin/reports/customerorders.blade.php)

I refer above code from below stack url.Please help me to resolve this issue. How to call a controller function inside a view in laravel 5



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2zwEIQv
via IFTTT

Aucun commentaire:

Enregistrer un commentaire