Tech
Batal
KATEGORI
link has been copied
3950
Lapor Hansip
30-12-2012 23:20

[Comunity] Laravel A Framework For Web Artisans :: Belajar, Diskusi, Tanya, dll.

Hallo Gan, berhubung di kaskus ini saya ubek2 belum ada thread yang membahas Laravel, maka dari itu saya ijin untuk membuat threadnya untuk keperluan Belajar, Diskusi dan Tanya-jawab.



Diubah oleh aa_pratomo
profile-picture
profile-picture
profile-picture
iisirawan dan 2 lainnya memberi reputasi
3
Masuk atau Daftar untuk memberikan balasan
[Comunity] Laravel A Framework For Web Artisans :: Belajar, Diskusi, Tanya, dll.
19-08-2018 22:10
Selamat malem gan, setelah ubek2 selama 2 hari akhirnya ane hampir nyerah.
Sebelumnya maaf kalo pertanyaan saia nanti ini pemula banget, soalnya baru belajar seminggu

JUDULNYA : Setiap Submit Form, Laravel langsung Logout
apa ada yang salah ya dari codingannya, mohon bantuannya di periksa, berikut codingan saia

Web.php
Code:

<?php
Route::get('/', 'PostController@index')->name('home');

Route::get('/posts','PostController@index');
Route::get('/posts/create','PostController@create');
Route:emoticon-Stick Out Tongueost('/posts','PostController@store');
Route::get('/posts/{id}/reply','ReplyController@create');
Route:emoticon-Stick Out Tongueost('/posts/{id}/reply','ReplyController@store');

Route::get('/register','RegisterController@create')->name('register.create');
Route:emoticon-Stick Out Tongueost('/register','RegisterController@store')->name('register');
Route::get('/login','LoginController@create')->name('login');
Route:emoticon-Stick Out Tongueost('/login','LoginController@store')->name('login.store');
Route::get('/password/reset','LoginController@reset')->name('password.request');

Route:emoticon-Stick Out Tongueost('/logout','LoginController@destroy')->name('logout');


PostController.php
Code:
<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Auth;
use App\Post;
use App\Category;
use App\Topic;

class PostController extends Controller
{

public function __construct(){
$this->middleware('auth')->except(['index','store']);
}

public function index()
{
$posts = Post:emoticon-Stick Out Tongueaginate(5);
return view('posts.index',compact('posts'));

}

public function create()
{
$categories = Category::all();
$topics = Topic::all();

return view('posts.create',compact('categories','topics'));
}

public function store(Request $request)
{


$post = new Post;
$post->post_no = $rand->random_num;
$post->id_category = $request->input('id_category');
$post->title = $request->input('title');
$post->contents = $request->input('contents');
$post->id_user = $request->input('id_user');
$post->id_status = 1;
$post->save();

return view('posts.index')->with('success','Your question is submitted successfully');
}

}


Mohon bantuannya
0 0
0
icon-hot-thread
Hot Threads
obrolan-hangat-logo
Obrolan Hangat
Copyright © 2020, Kaskus Networks, PT Darta Media Indonesia