Error Update and Add data in Laravel MySQL

Want to ask earlier, I did insert add data in the attendance_details table, it worked, but I want the attendance table to be automatically changed to the Done table to 1 before 0 before submitting. But the error at signup says something like this Method IlluminateDatabaseEloquentCollection::save does not exist. Here is my MySQL table:

Table attendance_details:
Screenshot Table attendance_details in MySQL

and table attendance:
Screenshot Table attendance

in the attendance table there is a Done table still 0 after submitting it should be changed to 1

Code:

Blade

 <form method="POST" action="{{route('add.data')}}" enctype="multipart/form-data">
        @csrf
        <input type="hidden" name="id_atte" value="{{ $dataAttendance->id_atte }}"
>

Controller

public function AddData(Request $request) {
        // Add Data attendance_details
        foreach($request->get('id_atte') as $index => $value) {
            AttendanceDetail::create([
                'id_atte' => $value,
                'id_student' => $request->get('id_student')[$index],
                'id_atte_type' =>$request->get('id_atte_type')[$index],
                'note' => $request->get('note')[$index]
            ]);
        }

        // Update Data attendance
        $data = Attendance::find($request->id_atte);
        $data->done = '0';
        $data->save();

        return redirect('teacher/data-attendance');
    }

Where is the coding wrong?

Show surname and rest of the name

I have a database with customer names, and I want to separate the last name from the rest of the name.

In the name Diana Margarida Paulino Maria

If I use:

$str = "Diana Margarida Paulino Maria";

// Get Frist and Last Word
   $array = explode(" ",$str);

   $first_word = $array[0];

   $last_word  = $array[count($array)-1];

   echo $first_word. ', '.$last_word;

It’s every thin ok, anda show Diana as first_word and Maria as last_word

Even is I use:

    function getLastWord($string)
    {
        $string = explode(' ', $string);
        $last_word = array_pop($string);
        return $last_word;
    }

Or this

  $words = explode( " ", $str );
array_splice( $words, -1 );
echo implode( " ", $words );

In this case show name without surname

The problem is that if you return a php msqyl select query from that name and use these functions, the nickname never appears

I’ve tried directly through the mysql query itself

SELECT substring_index(nome, ' ', 1) as first, substring_index(nome, ' ', -1) as last

And in the specific case of this name (and some others – Leandro Monteiro Rodrigues Figueiredo; Pedro António Duarte Lopes) the nickname still does not appear

I used the above codes with many other names and in almost all situations the nickname is indicated correctly

In the mysql database the name field is encoded with utf8_general_ci

Either way it’s weird because I can’t find a pattern for the error

How to add unique identifier to each level of nested array with unknown values?

I have array that contains 4 levels of nesting:

$data =  [
    "" => [            
            'sub_level_1' => [                    
                    'sub_level_2' => [
                            'sub_level_3' => [
                                      0 => ""
                                      1 => "val"
                                 ]
                        ]
              ]
        ],
    "top_level_2" => [            
            'sub_level_1' => [                    
                    'sub_level_2' => [
                            'sub_level_3' => [
                                      0 => ""
                                      1 => "some_val"
                                      2 => "foo"
                                 ]
                        ]
              ]
        ] 
];

I want to add other unique identifier for each nested level, so I use a counter on each level:

$top_level_counter = 0;
$sub_level_1_counter = 0;
$sub_level_2_counter = 0;
$sub_level_3_counter = 0;

foreach ($data as &$top_level)
{
    $top_level['top_level_id'] = $top_level_counter++;

    foreach($top_level as &$sub_level_1)
    {
        sub_level_1['sub_level_1_id'] = $sub_level_1_counter++;

            foreach($top_level as &$sub_level_1)
            {
                sub_level_2['sub_level_2_id'] = $sub_level_2_counter++;
                // and continue with the last level..
            }
    }
}

But as the example above, the keys can be empty ("") or even null because that’s data from the database.

I end up getting errors related to invalid values, but I can’t find out which.

I did figure that as I go inside each level, I have to check for:

if (is_array($sub_level_<x>)

because on each level above I already store the unique id which is not an array. But still, even with that, I get invalid input for foreach for example.
But I can’t find out what’s causing that, though I suspect it might be because of a null or empty value

Is there a better way to do that?

The reason I want to do it is to have an easier to work with identifier for each element in the array because the actual data is strings in another language.

Expected result would be:

$data =  [
    "" => [ 
            'top_level_id' => 0,           
            'sub_level_1' => [ 
                    'sub_level_1_id' => 0,                      
                    'sub_level_2' => [
                            'sub_level_2_id' => 0,
                            'sub_level_3' => [
                                      0 => ""
                                      1 => "val"
                                 ]
                        ]
              ]
        ],
    "top_level_2" => [  
            'top_level_id' => 1,            
            'sub_level_1' => [      
                    'sub_level_1_id' => 1,              
                    'sub_level_2' => [
                            'sub_level_2_id' => 1,
                            'sub_level_3' => [
                                      0 => ""
                                      1 => "some_val"
                                      2 => "foo"
                                 ]
                        ]
              ]
        ] 
];

Performing insert and update with single button

I have a screen of 15 fields and a single card status button of hyperlink of other page in PHP.

My problem is while inserting I can open that button of link in my page, but then after I perform update on same page that button link is not redirecting – why?

<tr>
  <td colspan="1">
    <div class="d-flex justify-content-between">
      <button type="submit" style="width:200px;height:50px;" id="k" onclick="location.href='issue.php'" class="number-input btn btn-light" name="Card Issuance" value="Card Issuance">Card Issuance</button>
      <select style="width:250px;height:35px" class="form-control number-input my-3" name="cardstatus">
        <option value="" disabled selected hidden>Card Issuance Status...</option>
        <option value="1" <?php if ($cardstatus=="1") {echo "selected";}?>>Active</option>
        <option value="2" <?php if ($cardstatus=="2") {echo "selected";}?>>Inactive</option>
      </select>
    </div>
  </td>
  <td>
    <input type="text" class="number-input form-control" name="o10" style="width:200px" value=<?php echo "'$o10';" ?> autocomplete="off">
  </td>
  <td>
    <input type="date" class="number-input form-control" name="etenth" style="width:200px" value=<?php echo "'$etenth';" ?> autocomplete="off">
  </td>
  </td>
  <td>
    <input type="date" min="1710-04-01" style="width:200px" class="form-control" name="atenth" value=<?php echo "'$atenth';" ?> autocomplete="off">
  </td>
</tr>

ZipArchive PHP show Pop Up Execute

enter image description here

I used ZipArchive to create file ZIP and when i click it show Pop Up like that

I don’t know why file show like that, but content file still working

i have code like

$zip = new ZipArchive;

$zip->open($zip_path . $zipname, ZIPARCHIVE::CREATE);

$content = tar_write_contents_text()

$zip->addFromString($content)


    public function tar_write_contents_text($phisfn, $head = "")
{
    if (@is_dir($phisfn)) {
        return;
    }
    else {
        $r = null;
        if (!file_exists($phisfn)) {
            return;
        }
        $f2 = fopen($phisfn, "rb");
        if ($head) $r .= $head;
        while (!feof($f2)) {
            $r .= fgets($f2, 1024);
            ob_flush();
            flush();
        }
        fclose($f2);
        return $r;
    }
}

Thanks for all your help

I am getting “AAR:002 No JWT found” error while doing GET request in PHP [duplicate]

I am trying to execute a PHP code base for GET API request, but I am getting

“AAR: 002” “No JWT Found”

error. below is the code

I am executing a GET request with cURL commands in PHP . The same code base and keys are working fine in Java and C# but when trying in PHP got this error.

When I try executing the below query

//echo $jwt ;
    
$options = array(
    //CURLOPT_FAILONERROR => false,
    CURLOPT_RETURNTRANSFER => true,
    // CURLOPT_AUTOREFERER => true,
    //  CURLOPT_HEADER => true,
    //  CURLOPT_NOBODY =>true,
    CURLOPT_CUSTOMREQUEST => "GET",
    CURLOPT_SSLKEY =>$privatekey_sslkey,
    CURLOPT_SSLCERT => $pem,
    CURLOPT_KEYPASSWD => $sslCertPass,
    CURLOPT_SSLCERTPASSWD =>$sslCertPass,
    CURLOPT_SSL_VERIFYHOST => 2,
    CURLOPT_SSL_VERIFYPEER => true,
    // CURLOPT_POST => false,
    // CURLOPT_POSTFIELDS => $jwt,
    CURLOPT_HTTPHEADER => array(
        "Content-Type => application/json",
        "JWTToken => $jwt",
        "Pragma => akamai-x-get-extracted-values"
    ),
);

//print_r( $options);
curl_setopt_array($ch,$options );
$resp = curl_exec($ch);
echo $resp;
$ch_errno = curl_errno($ch);
$ch_erro = curl_error($ch);
curl_close($ch);
    
if ($ch_errno)
{
    echo "cURL Error #:". $ch_erro;
} 
else
{
    echo "Response:".$resp;
}
?>

enter image description here

How to register commands in bundle only on dev environment

So I have symfony 4.4 application and I would like to add new bundle that would be used only in dev environment to help with testing some backend functionalities. I would like this bundle to have commands that could be run on this dev enviroment only. On production enviroment such commands should be either not registered either disabled. Depends on implementation but overall goal here is to not be able to run such commands on production.

I know that such thing could be implemented by adding such check to command. But thing is that I would like not to have to add every time such lines. It should be done somehow automatically in other place. So when I would add 5 commands those 5 commands in bundle would be able to run only on dev environment

How can I achieve those 2 goals?

assertRedirect causing output of email already exists – PHP Testing

So my test case in laravel is the following:

  public function test_user_can_sign_up_using_the_sign_up_form()
    {
        $user = User::factory()->create();

        $user = [
            'username' => $user->username,
            'email' => $user->email,
            'password' => $user->password,
            'password_confirmation' => $user->password,
            'dob' => $user->dob
        ];

        $response = $this->post('/register', $user);

        // Removes password confirmation from array
        array_splice($user, 3);

        $this->assertDatabaseHas('users', $user);

        $response->assertRedirect('/home');

    }

This line:

$response->assertRedirect('/home');

is causing the test to fail and get an output of ‘The email has already been taken’ Why is this the case? I want to check upon sign up, the user is directed to the home page which it does but my test fails.

The user is being created in the database so that part works fine.

UserFactory:

<?php

namespace DatabaseFactories;

use IlluminateDatabaseEloquentFactoriesFactory;
use IlluminateSupportStr;

/**
 * @extends IlluminateDatabaseEloquentFactoriesFactory<AppModelsUser>
 */
class UserFactory extends Factory
{
    /**
     * Define the model's default state.
     *
     * @return array<string, mixed>
     */
    public function definition()
    {
        return [
            'username' => fake()->name(),
            'email' => fake()->unique()->safeEmail(),
            'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // password
            'dob' => fake()->date(),
        ];
    }

    /**
     * Indicate that the model's email address should be unverified.
     *
     * @return static
     */
    public function unverified()
    {
        return $this->state(fn (array $attributes) => [
            'email_verified_at' => null,
        ]);
    }
}

How to remove any character after .jpg

In my SQL database some content in “posts” table has string like this:

Some Text.... <img src="sanad1.jpg?width=1198&trim=1,1&bg-color=000">...Some Text.

how can i remove anything after .jpg with a query?

 Some Text.... <img src="sanad1.jpg">...Some Text.

how to replace all occurrences of the same values in an array

Hi i’m new to php and am just wondering how to iterate through an array

  $array = ["7","8","8","18","19","20","21","22","8"];

and replace all the values “8” with “1”

i tried

function firstFileInList($array) {
  foreach($array as $k => $v)
    if(strpos($v, "8") !== false){
      return $k;}


}

$testarray[firstFileInList($testarray)] =1;

but it only does the first instance

Datex II API request working, but not show data

I don’t know what is wrong. I don’t see data, but request working. Maybe something is wrong in my files, but maybe someone help me 🙂 Maybe something is wrong in request.php file. Some days ago all is working. I don’t know whats happening. Maybe VPS update making something.

PHP info is here
https://teated.nsc.ee/data/info.php

Test page is here with results
https://teated.nsc.ee/data/test.php

Request.php

/**
 * REST test scripts
 * @license MIT
 */
class Request {
    public $protocol;
    public $host;
    public $path;
    public $proxyURL;
    public $decoders;
    public $userAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36";
    public $allowInsecure = false;
    public $headers = array();
    // set to Basic for user/pass authorization
    public $authorize = null;
    public $defaultMime = 'application/json';
    /**
     * Creates a Request object
     */
    public function __construct($protocol = null, $host = null, $path = null) {
        $this->protocol = $protocol ?: 'https';
        $this->host = $host ?: 'localhost';
        $this->path = $path ?: '';
        $this->decoders = array(
            "application/xml" => function($res) {
                // Decode an XML response
                return json_decode(json_encode((array)simplexml_load_string($res)), true);
            },
            "application/json" => function($res) {
                // Decode a JSON response
                return json_decode($res, true);
            },
            "application/vnd.php.serialized" => function($res) {
                // Deserialize a PHP object
                return unserialize($res);
            },
            // "application/x-www-form-urlencoded" => function($res) {
            //  // Decode a url encoded string
            //  $result = $this->parseUrl(urldecode($res));
            //  return $result;
            // },
        );
        
    }
    /**
     * Make a request to the API with the following information.
     *
     * You can use params to contain uri query information, but you cannot use
     * both $uri and $params to create GET query parameters. It's probably best
     * to stick to $params so that it will be easier to manage them.
     * 
     * @param  string $uri    The endpoint
     * @param  array  $params Extra data for the request (GET/POST data)
     * @param  string $method The request type (GET/POST/PUT/DELETE)
     * @param  string $format The response format (JSON/XML)
     * @return Array
     */
    public function makeRequest($uri = "/", $params = null, $method = "GET", $mime = null) {
        // Build URL
        $uri = $this->protocol . "://" . $this->host . $this->path . $uri;
        $this->headers += array(
            "Accept" => $mime,
            "User-Agent" => $this->userAgent
        );
        if ($this->authorize) {
            $this->headers['Authorization'] = $this->authorize;
        }
        $params = $params ?: array();
        if ($params !== null && !is_array($params)) {
            throw new Exception(
                'Invalid type ' . gettype($mime) .
                ', expected array for request parameters'
            );
        }
        $mime = $mime ?: $this->defaultMime;
        if ($mime !== null && !is_string($mime)) {
            throw new Exception(
                'Invalid type ' . gettype($mime) .
                ', expected string for mime'
            );
        }
        if (function_exists('curl_init')) {
            $opts = array(
                CURLOPT_CUSTOMREQUEST   => $method,
                CURLOPT_HEADER          => false,
                CURLOPT_HTTPHEADER      => $this->combineHeaders($this->headers, 'array'),
                CURLOPT_FAILONERROR     => true,
                CURLOPT_FOLLOWLOCATION  => true,
                CURLOPT_RETURNTRANSFER  => true,
                CURLOPT_PROXY           => $this->proxyURL,
                CURLOPT_TIMEOUT         => 10,
                CURLOPT_CONNECTTIMEOUT  => 5,
            );
            if ($this->allowInsecure) {
                $opts += array(
                    CURLOPT_SSL_VERIFYPEER  => false,
                    CURLOPT_SSL_VERIFYHOST  => false,
                );
            }
            // Only send content in PUT and POST requests
            if (in_array(strtoupper($method), array("PUT", "POST"))){
                $opts[CURLOPT_POSTFIELDS] = http_build_query($params, '', '&');
            } else {
                $uri .= "?" . http_build_query($params);
            }
            // Start the connection
            $ch = curl_init($uri);
            // Make sure we can connect
            if (($ch = curl_init($uri)) === false) {
                throw new RuntimeException("Cannot connect to HOST: {$uri}");
            }
            // Try to make the request and get data out
            if (curl_setopt_array($ch, $opts) === false || ($data = curl_exec($ch)) === false) {
                $err = curl_error($ch);
                curl_close($ch);
                throw new RuntimeException("{$err} "{$uri}"");
            }
        } elseif (ini_get('allow_url_fopen')) {
            if (in_array(strtoupper($method), array("PUT", "POST"))) {
                $this->headers["Content-Type"] = "application/x-www-form-urlencoded";
                $opts['http']['content'] = http_build_query($request, '', '&');
            } else if (strpos($uri, '?') === false) {
                $uri .= "?" . http_build_query($params);
            }
            $opts = array(
                'http' => array(
                    'header'            => $this->combineHeaders($this->headers, 'string'),
                    'method'            => $method,
                    'user_agent'        => $this->userAgent,
                    'proxy'             => $this->proxyURL,
                    'timeout'           => 5,
                ),
            );
            if ($this->allowInsecure) {
                $opts['ssl'] = array(
                    "verify_peer"       => false,
                    "verify_peer_name"  => false,
                );
            }
            $context = stream_context_create($opts);
            if (($data = @file_get_contents($uri, false, $context)) === false) {
                $error = error_get_last()['message'];
                preg_match("/(?:HTTP request failed! HTTP/[0-9].[0-9] ([0-9a-zA-Z ]+))/", $error, $specific);
                $error = (@$specific[1] ?: $error);
                throw new RuntimeException("Cannot connect to HOST as $error: {$uri}");
            }
        } else {
            throw new RuntimeException('No means of communication with REST API, please enable CURL or HTTP Stream Wrappers');
        }
        if (!$data) {
            throw RuntimeException("The response was empty");
        }
        $decoder = $this->getDecoder($mime);
        if (!$decoder) {
            throw new RuntimeException("No decoder is present for mime type {$mime}");
        }
        $decoded = $decoder($data);
        if (!$decoded) {
            throw new RuntimeException("The response cannot be decoded into the mime type {$mime}. Response: {$data}");
        }
        return $decoded;
    }
    /**
     * Combines headers into a string
     * @param  array  $headers Dictionary of header keys and values
     * @param  string $type    Return type
     * @return mixed           String or Array containing combined KVPs
     */
    public function combineHeaders($headers, $type = 'string') {
        foreach($headers as $key => &$value) {
            if (is_string($key)) {
                $value = "$key: $value";
            }
        }
        if ($type == 'string') {
            // returns 'User-Agent: ChromenHost: localhostn' etc...
            return implode(array_values($headers), "n");
        } else if ($type == 'array') {
            // returns array('User-Agent: Chrome', 'Host: localhost'), etc...
            return array_values($headers);
        } else {
            throw new Exception('Invalid combineHeaders type');
        }
    }
    /**
     * Parse headers from a string into an array.
     * Not yet implemented
     * @return [type] [description]
     */
    public function parseHeaders() {
        // TODO?
        throw new Exception('Not yet implemented');
    }
    /**
     * Adds a KVP to the headers for future requests.
     * @param string $key   Header key
     * @param string $value Header value
     */
    public function addHeader($key, $value) {
        $this->headers[$key] = $value;
        return $this;
    }
    /**
     * Remove a KVP from the headers for future requests.
     * @param string $key   Header key
     * @param string $value Header value
     */
    public function removeHeader($key) {
        if (isset($this->headers[$key])) {
            unset($this->headers[$key]);
        }
        return $this;
    }
    /**
     * This removes any authorization header currently being used.
     * @return $this
     */
    public function removeAuthorization() {
        $this->authorize = null;
        return $this;
    }
    /**
     * Sets basic authorization for username and password
     * @param string $username User's Username
     * @param string $password User's password
     * @return $this
     */
    public function setBasicAuthorization($username, $password) {
        $this->authorize = "Basic " . base64_encode("{$username}:{$password}");
        return $this;
    }
    /**
     * Set authorization header with authorization string (e.g. token)
     * @param string $auth authorization string
     * @return $this
     */
    public function setOtherAuthorization($auth) {
        $this->authorize = $auth;
        return $this;
    }
    /**
     * Sets the default mime type.
     * @param string $mime Default mime
     * @return $this
     */
    public function setDefaultMime($mime) {
        if (is_string($mime)) {
            $this->defaultMime = $mime;
        }
        return $this;
    }
    /**
     * Adds a decoding mechanism to the supported list of decoders
     * @param string  $mime        The mime type in the format of <MIME_type/MIME_subtype>
     * @param closure $decodeLamda The decoding mechanism to support the mime type
     * @return $this
     */
    public function addDecoder($mime, $decodeLamda){
        $this->decoders[$mime] = $decodeLamda;
        return $this;
    }
    /**
     * Gets a decoding lamda mechanism for a known mime type
     * @param  string  $mime The mime type in the format of <MIME_type/MIME_subtype>
     * @return closure       The decoding mechanism
     */
    public function getDecoder($mime) {
        if (array_key_exists($mime, $this->decoders)){
            return $this->decoders[$mime];
        } else {
            return null;
        }
    }
    /**
     * Returns all known mime types supported by the REST API
     * @return array list of <MIME_type/MIME_subtype>
     */
    public function getMimeTypes(){
        return array_keys($this->decoders);
    }
    // @see https://gist.github.com/rubo77/6821632 to skip max_input_vars error
    /**
    * @param $string
    * @return array|bool
    */
    function parseUrl($string) {
        if($string==='') {
            return false;
        }
        $result = array();
        // Find the pairs "name=value"
        $pairs = explode('&', $string);
        foreach ($pairs as $pair) {
            $dynamicKey = (false !== strpos($pair, '[]=')) || (false !== strpos($pair, '%5B%5D='));
            // use the original parse_str() on each element
            parse_str($pair, $params);
            $k = key($params);
            if (!isset($result[$k])) {
                $result += $params;
            } else {
                $result[$k] = $this->arrayMergeRecursiveDistinct($result[$k], $params[$k], $dynamicKey);
            }
        }
        return $result;
    }
    /**
    * @param array $array1
    * @param array $array2
    * @param $dynamicKey
    * @return array
    */
    function arrayMergeRecursiveDistinct(array &$array1, array &$array2, $dynamicKey) {
        $merged = $array1;
        foreach ($array2 as $key => &$value) {
            if (is_array($value) && isset($merged[$key]) && is_array($merged[$key])) {
                $merged[$key] = $this->arrayMergeRecursiveDistinct($merged[$key], $value, $dynamicKey);
            } else {
                if ($dynamicKey) {
                    if (!isset( $merged[$key])) {
                        $merged[$key] = $value;
                    } else {
                        if (is_array($merged[$key])) {
                            $merged[$key] = array_merge_recursive($merged[$key], $value);
                        } else {
                            $merged[] = $value;
                        }
                    }
                } else {
                    $merged[$key] = $value;
                }
            }
        }
        return $merged;
    }
}

Data.php

require('request.php');

$api = new Request('https', 'tarktee.ee', '/api/v1/datex');
$api->setDefaultMime('application/xml'); 
$api->addHeader('X-DATEX-API-KEY', 'EQci9Ia76RKXTOb8Rw4BbE');


try{
   $request = $api->makeRequest('/safetyData'); 
   $situations = $request['payloadPublication']['situation'];
                    
   for ($x = 0; $x <= 15; $x++){
      $situations = $request['payloadPublication']['situation'][$x];
      $oht1 = $situations['situationRecord']['environmentalObstructionType'];
      $oht2 = $situations['situationRecord']['obstructionType'];
      $teatav1 = $situations['situationRecord']['source']['sourceName']['values']['value'][0]; 
      $teatav2 = $situations['situationRecord']['source']['sourceIdentification'];

   echo 'OHT1: '.$oht1.'<br>';
   echo 'OHT2: '.$oht2.'<br>';
   echo 'TEA1: '.$teatav1.'<br>';
   echo 'TEA2: '.$teatav2.'<br>';

   }

}catch(Exception $e){ echo "Vabandame! Päringu viga. Põhjus: " . $e->getMessage(); }

how to match two tables’s column’s value and get the result from perticular column’s value in laravel relationship?

how to compaire two tables value and get the result of particular column value from both tables in laravel relationship method? I don’t know how to do it with relationship, at the same time I don’t know whether it is based on many to many or one to many relationship. at the same time I have to do it with where condition.
here is my mormal query example for my requested code:
select teacher.teacher_name, subject. subject_name from teacher join subject on teacher.subject_token = subject.token where teacher.teacher_token = ‘1’;

Laravel Fortify and JSON based registering result in CRSF mismatch

I’m currently toying with Laravel 9.x and Fortify.

For the starter here my environnement :

  • Laravel 9.19
  • Fortify 1.14
  • Postgre 15

I try to achieve something I thought was possible from reading the Fortify doc, using a third-party UI (e.g.: Mobile App) to register and login user.

So, following the documentation guide I deactivated the views generation, and migrated the tables and launched my test server using php artisan serve.

Then I try using postman to post the following json to the /register route provided by Fortify.

Postman has been setup with the following headers:

  • Content-Type: application/json
  • Accept: application/json
{
  "name": "test1",
  "email": "[email protected]",
  "password": "MyPassw0rd!",
  "password_confirmation": "MyPassw0rd!"
}

The response returned by the request was an error 419 CSRF Token mismatch, which I understand since Laravel enforce the use of CSRF token.

Therefor I tried to add the /register route to the except array inside the middleware VerifyCsrfToken and tried again and this time I got a 201 created response.

From my understanding since the /register route exists within the web guard hence the CSRF token mechanic.

Since my final goal is to use Fortify with third-party frontend, how can achieve that without putting the route inside the except array (if possible)?

Is there a parameter to change inside config/fortify.php to allow this behavior?

Thanks for reading.

Arrays: Join two arrays in one

I have two arrays:

$array1 = 
   [
     0 =>
       [
         'data1' => value1
       ],
     1 =>
       [
          'data1' => value2
       ]
   ];



   $array2 = 
   [
     0 =>
       [
         'data2' => value1
       ],
     1 =>
       [
          'data2' => value2
       ]
   ];   

Only i want create this:

   $arrayFinish = 
   [
     0 =>
       [
         'data1' => value1,
         'data2' => value1
       ],
     1 =>
       [
          'data1' => value2
          'data2' => value2
       ]
   ];    

I am trying to do it using PHP. I am blocked right now, i am sure that that the solution is using two loops, but i am doing any bad.

thank u for the help.

I have Xampp installed. In a php file, if I run “error_log(“aãa”);” it outputs “axc3xa3a”. Please help me fix it

The error_log problem isn’t my actual problem, though. I’m trying to figure out the following problem:

I have quilljs running on a page.

I type accents, like “aãa” above.

I grab it with getText, send it to php with $.post (ajax, I believe)

Whatever I try to do with it, it comes out garbled like that.

Specifically what I’m trying to do is this: array_count_values(str_word_count($text, 1));

To find repeated words and later highlight them in the text, basic stuff, only the character encoding problem is making it harder than it should be.

Goddamit are character encoding problems annoying.

I’ve made sure php.ini, my.ini and the html file all have utf-8 encoding. I’m at my wit’s end, please send help.