@Nisal-Vimukthi puluwan
-
on laravel8 framework , can anyone help me with this i also used ,
this way but still it doesn't work
https://stackoverflow.com/questions/22615926/migration-cannot-add-foreign-key-constraintCannot add foreign key constraint..
Error is as below SQLSTATE[HY000]: General error: 1215 Cannot add foreign key constraint (SQL: alter table `products` add constraint `products_category_id_foreign` foreign key (`category_id`) references `categories` (`id`)) at vendor/laravel/framework/src/Illuminate/Database/Connection.php:678 674▕ // If an exception occurs when attempting to run a query, we'll format the error 675▕ // message to include the bindings with SQL, which will make this exception a 676▕ // lot more helpful to the developer instead of just the database's errors. 677▕ catch (Exception $e) { ➜ 678▕ throw new QueryException( 679▕ $query, $this->prepareBindings($bindings), $e 680▕ ); 681▕ } 682▕ +9 vendor frames 10 database/migrations/2021_01_19_074944_create_products_table.php:38 Illuminate\Support\Facades\Facade::__callStatic("create") +21 vendor frames 32 artisan:37 Illuminate\Foundation\Console\Kernel::handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))code on the migration
<?php use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; class CreateProductsTable extends Migration { /** * Run the migrations. * * @return void */ public function up() { Schema::create('products', function (Blueprint $table) { $table->id(); $table->string('name'); $table->string('slug')->unique(); $table->string('Short_Description')->nullable(); $table->string('description'); $table->decimal('regular_price'); $table->decimal('sale_price')->nullable(); $table->string('SKU'); $table->enum('stock_status',['instock','outstock']); $table->boolean('Featured')->default(false); $table->unsignedInteger('quantity')->default(10); $table->string('image')->nullable(); $table->string('images')->nullable(); $table->integer('category_id')->nullable()->unsigned(); $table->foreign('category_id')->references('id')->on('categories')->onDelete('cascade'); $table->timestamps(); }); } /** * Reverse the migrations. * * @return void */ public function down() { Schema::dropIfExists('products'); } } -
-
-
Mage requirement eka,
Laravel Controller eka use karala wena site ehekata POST method eken Data Post karanna
<form action="anotherweb.com" method="post"> <input type="hhh" value="ccc"> ..... <button type="submit"></button> </formUda code eke tiyenne view eken another site ehekata data post karanna form eken, But mata one view eken nathuwa controller eka use karala uda code eke tiyena ekama karanna
Ai mata ehema karanna onePayhere Integration ekata, Js ekak dala payhere submit karanna puluwan but eka security less, Js code eka run wenna yana time eke page eke code eka view karala url blind karala less payment ekak karanna puluwan
$client = new GuzzleHttp\Client(); $response = $client->request('POST', 'http://httpbin.org/post', [ 'form_params' => [ 'field_name' => 'abc', 'other_field' => '123', 'nested_field' => [ 'nested' => 'hello' ] ] ]);Mama guzzle try kara but, meka wor karanne na methanadi wenne post method eka ape site eka request karana eka, Site ekata request karata wadak naha payhere support naha
Controller eka athule idan payhere or wena onema site ekakata data form ekak post karanne kohomada? -
-
-
I have two separate logins using guards which customer & adminuser. I have checkRole middleware for adminuser login and it works perfectly. I used guest middleware (RedirectifAuthenticated) to customer login. When customer login check with Auth::guard($guard)->check() it always returns false. But Auth::guard('customer')->attempt returns true. I can't find a solution.
here is the login controller for customer
class LoginController extends Controller { use AuthenticatesUsers; public function __construct() { $this->middleware('guest:customer')->except('customerlogout'); } //login the customer public function customerLogin(Request $request) { $email = $request->get('email'); $password = $request->get('password'); //Getting user inputs and authenticate the customer $status = Auth::guard('customer')->attempt([ 'email' => $email, 'password' => $password ] ); //Check login if ($status) { //if login pass,redirect to customer account page return redirect()->intended('/customer_account'); }else{ //if login fail,redirect back to home page return redirect()->back(); } } //logout the customer public function customerlogout(Request $request) { Auth::guard('customer')->logout(); $request->session()->flush(); return redirect('/index'); } }here is the guest middleware
public function handle($request, Closure $next, $guard = null) { if ($guard === "customer" && Auth::guard($guard)->check()) { return redirect('/customer_account'); } if (!Auth::guard($guard)->check()) { return redirect('/index'); } return $next($request); }Any help is appreciated, thanks!
-
 image url)
Mage laravel website eka MongoDb cluster ekka connect kranna giyama me error eka enava.
laravel version eka 6 mage.code eka config my conf/database.php vala
'mongodb_conn' => [ 'driver' => 'mongodb', 'dsn'=>'mongodb+srv://myusername:[email protected]/test?retryWrites=true&w=majority', 'database' => 'mydbname', ],.env eke code eka
APP_NAME=My_laravel_web APP_ENV=local APP_KEY=base64:jtvoXduyfwnIB6A5pCy8Cfa9bJYRvNgMKeRFdfiYYyc= APP_DEBUG=true APP_URL=http://localhost LOG_CHANNEL=stack DB_CONNECTION=mongodb_conn' DB_HOST=xxxx-shard-00-00-uggj0.mongodb.net DB_PORT=27017 DB_DATABASE=mydbname DB_USERNAME=myusername DB_PASSWORD=mypassword BROADCAST_DRIVER=log CACHE_DRIVER=file QUEUE_CONNECTION=sync SESSION_DRIVER=file SESSION_LIFETIME=120 REDIS_HOST=127.0.0.1 REDIS_PASSWORD=null REDIS_PORT=6379meka fix karanne kohomada
error message eka
php artisan serve InvalidArgumentException : Database [mongodb_conn'] not configured. at C:\xampp\htdocs\bloodDonation\vendor\laravel\framework\src\Illuminate\Database\DatabaseManager.php:152 148| // If the configuration doesn't exist, we'll throw an exception and bail. 149| $connections = $this->app['config']['database.connections']; 151| if (is_null($config = Arr::get($connections, $name))) { > 152| throw new InvalidArgumentException("Database [{$name}] not configured."); 153| } 154| 155| return (new ConfigurationUrlParser) 156| ->parseConfiguration($config); Exception trace: 1 Illuminate\Database\DatabaseManager::configuration("mongodb_conn'") C:\xampp\htdocs\bloodDonation\vendor\laravel\framework\src\Illuminate\Database\DatabaseManager.php:115 2 Illuminate\Database\DatabaseManager::makeConnection("mongodb_conn'") C:\xampp\htdocs\bloodDonation\vendor\laravel\framework\src\Illuminate\Database\DatabaseManager.php:86 Please use the argument -v to see more details. -
Laravel walin develop karapu web site ekak Node.js Api ekata connect kranna ona CURD operations karanna and authentication ekata. denata website ekata local mysql db ekata thama connect krala thiyenne . mata denaganna ona website eken http requests yavanne komada kiyala API ekata authentications ekka sessions ema weda karanna ?