I am getting App/Models error every time . I have tried the previous solutions given for this problem but none of them could help me. I have changed the name of the model and controller for several times to check whether it is a naming convention problem but could not solve it.
in model:
<?php
namespace App\models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\DB;
class Newmod extends Model
{
public function add()
{DB::connection('lara1')->insert("insert into abc (id, name) values (?,
?)', [2, 'pqr']);")}
}
}
in controller:
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Models\NewMod ;
class NewModController extends Controller
{
public function add()
{
/*$a= $_GET["name"];
DB::insert('insert into abc (id, name) values (?, ?)', [2, $a]);*/
$l= new NewMod();
$l->add;
echo "record inserted ";
}
}
in route:
Route::get('ax', 'NewModController@add');
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire