Search
 
SCRIPT & CODE EXAMPLE
 

PHP

laravel access JsonResponse content

    // In Controller 
    // Method 1: Consumes get_json()
	public function test_json()
    {
        $res = $this->get_json();

        // dd($res->getData());
        // {
        //     "error": "Error Message"
        //     "success": false
        // }

        $data = $res->getData();

        dd($data->error); // 'Error Message'
    }
	// Methos 2; returns json
    public function get_json()
    {
        return response()->json(['error' => 'Error Message','success' => false], 403);
    }
Comment

PREVIOUS NEXT
Code Example
Php :: get data in descending order in laravel 
Php :: get parameter php 
Php :: Notice: Trying to access array offset on value of type int in /var/www/pdam/modules/phpexcel/PHPExcel/Cell/DefaultValueBinder.php on line 82 
Php :: php artisan migrate single file 
Php :: how to echo only certain character number in php 
Php :: json to array php 
Php :: php scandir 
Php :: php select option 
Php :: drupal load all nodes of type 
Php :: php server sent events 
Php :: iterating rows in php 
Php :: get app url in laravel 
Php :: current time input field in laravel form 
Php :: array_fill php 
Php :: File Reading Modes PHP 
Php :: crul in laravel 
Php :: laravel get image extension 
Php :: find substring regx php 
Php :: yii2 html a 
Php :: foreach in php 
Php :: php array_filter 
Php :: custom 404 page in laravel 
Php :: PDOException::("could not find driver") windows 
Php :: how do i open a new tab with php 
Php :: validation in laravel 
Php :: trim array in map php 
Php :: hide env file in laravel 
Php :: magento 1.9 print blank page error 
Php :: How to get the current taxonomy term ID (not the slug) in WordPress? 
Php :: show php all errors 
ADD CONTENT
Topic
Content
Source link
Name
1+7 =