/** * Store a newly created resource in storage. * * @param Request $request * @return Response */ public function store(AdminChannelRequest $request) { $newChannel = Channel::create(['shorthand' => $request->shorthand, 'description' => $request->description, 'color' => $request->color]); $newChannel->parent()->associate($request->parent_id); $newChannel->save(); return Redirect::Route('admin.channels.index')->withMessage('Success!'); }
public function submitRegister(Request $request) { //Check input against validator $v = $this->validator($request->input()); //Let the user know what error(s) appeared if any, otherwise continue with registration if ($v->fails()) { return redirect()->back()->withInput($request->except('password'))->withErrors($v); } else { //Prevent Reserved URL's from being registered if ($request->input('url') == 'auth' || $request->input('url') == 'admin' || $request->input('url') == 'lesson' || $request->input('url') == 'lessons' || $request->input('url') == 'channel' || $request->input('url') == 'channels') { return redirect()->back()->withInput($request->except('password', 'url'))->withErrors(['That URL is reserved, please choose another']); } //Create new user $user = User::create(['url' => strtolower($request->input('url')), 'email' => $request->input('email'), 'password' => bcrypt($request->input('password'))]); //if create user was successful try to create a channel if ($user) { $bid = uniqid($request->input('url')); $channel = Channel::create(['user_id' => $user->id, 'url' => $user->url, 'public' => '1', 'message' => ' ', 'broadcast_id' => $bid, 'receive_id' => md5($bid), 'last_active' => '0']); if ($channel) { //if creating channel (and user) was successful then redirect to admin page, otherwise let the user know to try again Auth::login($user); return redirect('/admin'); } else { $user->delete(); return redirect()->back()->withInput($request->except('password'))->withErrors(['Internal Error (AC-2), please try again']); } } else { return redirect()->back()->withInput($request->except('password'))->withErrors(['Internal Error (AC-1), please try again']); } } }
/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { $validator = Validator::make($request->all(), ['name' => 'required|max:255']); if ($validator->fails()) { return response()->json(['message' => $validator->errors(), 'code' => 422], 422); } // create new channel $channel = Channel::create(["name" => $request->name]); return response()->json(['message' => "Channel {$request->name} has been created", 'data' => $channel, 'code' => 201], 201); }
/** * Execute the console command. * * @return mixed */ public function handle() { $this->comment('Getting Main Channels'); $oldChannels = array(array('name' => 'columnists', 'description' => 'Columnists', 'icon' => 'fa-quote-right', 'color' => '#29639E'), array('name' => 'design', 'description' => 'Marketing & Design', 'icon' => 'fa-picture-o', 'color' => '#EFC050'), array('name' => 'fashion', 'description' => 'Fashion & Style', 'icon' => 'fa-umbrella', 'color' => '#C50161'), array('name' => 'food', 'description' => 'Food & Health', 'icon' => 'fa-coffee', 'color' => '#FF851B'), array('name' => 'society', 'description' => 'Society & Fun', 'icon' => 'fa-smile-o', 'color' => '#3D9970'), array('name' => 'politics', 'description' => 'Politics & News', 'icon' => 'fa-globe', 'color' => '#A76336'), array('name' => 'tech', 'description' => 'Tech & Business', 'icon' => 'fa-laptop', 'color' => '#6C88A0'), array('name' => 'media', 'description' => 'Music, TV & Film', 'icon' => 'fa-music', 'color' => '#02A7A7')); foreach ($oldChannels as $key => $channel) { $this->info('Creating Channel [ ' . $channel['name'] . ' ]'); Channel::create(['shorthand' => $channel['name'], 'description' => $channel['description'], 'color' => $channel['color']]); } //////////////////////////// //Now Import Sub Channels // //////////////////////////// $subChannels = array('style' => 'fashion', 'health' => 'food', 'family' => 'society', 'business' => 'tech', 'music' => 'media', 'tv' => 'media', 'film' => 'media', 'advertising' => 'design', 'photography' => 'design', 'art' => 'design'); foreach ($subChannels as $subChannel => $channel) { // get id of parent channel; $id = Channel::where('shorthand', $channel)->first()->id; $this->info('Creating SubChannel [ ' . $subChannel . ' ]'); Channel::create(['shorthand' => $subChannel, 'parent_id' => $id]); } }
/** * Save a new channel * @param $request */ private function createChannel(ChannelRequest $request) { $channel = Channel::create($request->all()); // $channel = Auth::user()->articles()->create($request->all()); $this->syncTags($channel, $request->input('tag_list')); }
/** * Run the database seeds. * * @return void */ public function run() { Channel::create(['domain' => 'peakpromos.app', 'title' => 'Peak Promos', 'slug' => 'peakpromos', 'theme' => 'whats-my-prize']); Channel::create(['domain' => 'peakpromos1.app', 'title' => 'Peak1', 'slug' => 'peakpromos1', 'theme' => 'vip-rsvp']); Channel::create(['domain' => 'peakpromos2.app', 'title' => 'Peak2', 'slug' => 'peakpromos2']); }
/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { $this->validate($request, ['name' => 'required|string|not_in:<script>|max:255']); Channel::create($request->all()); return redirect()->action('Admin\\CatgWebboardController@index'); }