رفتن به مطلب
انجمن پشتیبانی لاراول ایران

هاست لاراول با پشتیبانی 24 ساعته و امکانات کامل از مدیرهاست

Recommended Posts

هاست لاراول با پشتیبانی 24 ساعته و امکانات کامل از مدیرهاست

من هم روتم از نوع پست هم متد ارسال فرمم از نوع پست در پایین کدام براتون میفرستم

در ابتدا فایل web.apo:

<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/
Auth::routes();
Route::get('/category','CategoryController@create')->name('create');
Route::get('/','CategoryController@index')->name('home');
//Route::get('/','indexCont@welcome')->name('home');
Route::get('/index/{id}', 'indexCont@index')->name('index');
Route::get('/database','indexCont@db')->name('db');
Route::get('/category/show','CategoryController@show')->name('show');
Route::get('/category/edit','CategoryController@edit')->name('edit');
Route::get('/category/destroy','CategoryController@destroy')->name('destroy');
Route::get('/category/create','indeCont@create')->name('creat');
 
Route::put('/category/update','CategoryController@update')->name('update');
Route::post('/category/store','CategoryController@store')->name('store');


واما create.blade.php:

<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>new data</title>
</head>
<body>
<form action="{{route('store')}}" methood='post'>
    @csrf
name of framework:<input name="name" type="text"><br>
name of mother:<input name="mother" type="text"><br>
        <select name='iw'>
is for web?<option value="1">yes</option>
            <option value="0">no</option>
        </select>
<input type="submit" value="save!">
</form>
</body>
</html>
و در آخر categorycontroller:
<?php

namespace App\Http\Controllers;
 
use App\category;
use Illuminate\Http\Request;
 
class CategoryController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        $pt="page title";
        $db=category::get();
        return view('category',compact('db','pt'));
    }
 
    /**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function create()
    {
        return view('create');
 
    }
 
    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function store(Request $request)
    {
        dd($request);
        $category=new category([
            'nameofframwork'=>$request->get('name'),
            'mother'=>$request->get('mother'),
            'isforweb'=>$request->get('iw')
            ]);
        $category->save();
    }
 
    /**
     * Display the specified resource.
     *
     * @param  \App\category  $category
     * @return \Illuminate\Http\Response
     */
    public function show(category $category)
    {
        //
    }
 
    /**
     * Show the form for editing the specified resource.
     *
     * @param  \App\category  $category
     * @return \Illuminate\Http\Response
     */
    public function edit(category $category)
    {
        //
    }
 
    /**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \App\category  $category
     * @return \Illuminate\Http\Response
     */
    public function update(Request $request, category $category)
    {
        //
    }
 
    /**
     * Remove the specified resource from storage.
     *
     * @param  \App\category  $category
     * @return \Illuminate\Http\Response
     */
    public function destroy(category $category)
    {
        //
    }
}

 

Share this post


Link to post
Share on other sites
در 19 دقیقه قبل، ابوالفضل طالبی گفته است :

اطلاعات فرم خودتونو با متد post ارسال کنید

همینطور route خودتونو چک کنید که post باشه

 

در 2 دقیقه قبل، مهدی گفته است :

و یه مسله دیگه اینه که @csrfنمیشناسه و مرورگر اونو به صورت یه تکست نشون میده

 

Share this post


Link to post
Share on other sites

وارد این گفتگو شوید

میتوانید پیام خود را ارسال کنید و بعد ثبت نام نمایید. در صورتی که حساب کاربری دارید, هم اکنون وارد شوید و در این گفتگو شرکت کنید.

مهمان
پاسخ به این موضوع ...

×   شما در حال چسباندن محتوایی با قالب بندی هستید.   حذف قالب بندی

  Only 75 emoji are allowed.

×   لینک شما به صورت اتوماتیک جایگذاری شد.   نمایش به عنوان یک لینک به جای

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • جدید...