I want to make a trigger .After creating php make:migration AddTrigger and writing the code when I write php artisan migrate in cmd I get the following error : Symfony\Component\Debug\Exception\FatalThrowableError : syntax error, unexpected 'receiver' (T_STRING), expecting ')'
at E:\laravel project folder\blood\database\migrations\2019_06_14_173818_add_trigger.php:16 12| * @return void 13| */ 14| public function up() 15| {
16| DB::unprepared('CREATE TRIGGER amount AFTER INSERT ON 'receiver' FOR EACH ROW 17| BEGIN 18| INSERT INTO 'receipt' ('r_id') VALUES (10); 19| END'); 20| }
Exception trace:
1 Illuminate\Filesystem\Filesystem::requireOnce("E:\laravel project folder\blood\database\migrations/2019_06_14_173818_add_trigger.php") E:\laravel project folder\blood\vendor\laravel\framework\src\Illuminate\Database\Migrations\Migrator.php:475
2 Illuminate\Database\Migrations\Migrator::requireFiles() E:\laravel project folder\blood\vendor\laravel\framework\src\Illuminate\Database\Migrations\Migrator.php:105
Please use the argument -v to see more details.
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class AddTrigger extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
DB::unprepared('CREATE TRIGGER amount AFTER INSERT ON 'receiver' FOR
EACH ROW
BEGIN
INSERT INTO 'receipt' ('r_id') VALUES (10);
END');
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
DB::unprepared('DROP TRIGGER 'amount'');
}
}
I have used a controller named PageController where I used the function to insert into receiver .
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire